Class: OpenObserve::Sourcemaps
- Defined in:
- lib/openobserve/sourcemaps.rb
Overview
JavaScript source maps, uploaded so RUM can turn a minified browser stack trace back into readable file names and line numbers.
OpenObserve files an archive under a service/env/version triplet and applies it
only to events carrying the very same three values. Nothing validates the match: an
upload under a triplet no event ever reports answers 200 and symbolicates nothing, so
the caller owns the correspondence with what the browser SDK is configured to report.
Enterprise only, and the one domain built against no spec. POST /api/{org}/sourcemaps
is absent from the pinned OpenAPI document, which publishes the open source surface. Its
absence is therefore not the spec defect the layering note in CLAUDE.md describes — no
spec bump would ever bring it in — so the path is built here by hand, from the product
documentation. OpenObserve serves the route on the Enterprise build alone, to a token
carrying the sourcemaps RBAC permission; on an open source build these calls raise.
Constant Summary
Constants inherited from Resource
Instance Method Summary collapse
-
#upload(archive_path, service:, env:, version:) ⇒ void
Upload one archive for one service.
-
#upload_all(archive_path, services:, env:, version:) ⇒ Array<String>
Upload the same archive once per service.
Methods inherited from Resource
Constructor Details
This class inherits a constructor from OpenObserve::Resource
Instance Method Details
#upload(archive_path, service:, env:, version:) ⇒ void
This method returns an undefined value.
Upload one archive for one service.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/openobserve/sourcemaps.rb', line 29 def upload(archive_path, service:, env:, version:) raise Client::Error, "source map archive not readable: #{archive_path}" unless File.readable?(archive_path) # Opened as a handle rather than handed over as a path: the transport turns anything # responding to `read` into a multipart FilePart, and passes a String through as a # literal form value — which would upload the path itself, as text. The block form # closes it on the way out, failed upload included. File.open(archive_path, 'rb') do |file| call do connection.call( :POST, sourcemaps_path, type: nil, auth: AUTH, form: { 'file' => file, 'service' => service, 'env' => env, 'version' => version } ) end end nil end |
#upload_all(archive_path, services:, env:, version:) ⇒ Array<String>
Upload the same archive once per service.
Every instance serves the same compiled packs, while the SDK reports a distinct service name per instance, so one upload would leave every other instance minified.
59 60 61 62 63 |
# File 'lib/openobserve/sourcemaps.rb', line 59 def upload_all(archive_path, services:, env:, version:) Array(services).each do |service| upload(archive_path, service: service, env: env, version: version) end end |