Conversation
This commit is a first stab that is mostly just stubbing out adding
global providers (e.g. `api.trace.setGlobalTracerProvider`). It
includes a first very incomplete Tracer.startSpan() such that this:
cd examples/otelbridge1
npm install
node -r elastic-apm-node/opentelemetry.js example-http-request.js
yields a trace like:
trace 266fcd
`- transaction ba0b1f "makeRequest" (218.075ms, outcome=unknown)
IOW, context management isn't being handled yet, so instrumentation that
adds spans does nothing.
…ntext class; add no-op setValue et al to RunContext so it supports OTel 'Context' interface
The examples/otelbridge/example-http-request.js now generates:
trace 2f773e
`- transaction f87f78 "makeRequest" (125.801ms, outcome=unknown)
`- span c4b91a "GET httpstat.us" (121.768ms, http)
because the otel.trace.with() context (with the transaction) is
now passed through properly.
Also drop eapm from simple test case to not confuse the issue and to ensure there is no future accidental side-effect on having directly imported the APM agent.
…geNonRecordingSpan concept (probably still underdeveloped)
Also implement the {get,set,delete}Value methods on RunContext so that
OTel Context values are now propagated.
…ons with OTel Bridge
…t being an ended Transaction
This takes the coming changes from #2653 so that tests pass with this restriction lifted.
…Time,attributes} support
|
The user docs and changelog entry remain, but otherwise this is ready for review. |
astorm
left a comment
There was a problem hiding this comment.
I've left some comments with minor places things might be improved but I'm generally OK with getting this going in as-is once we've
- Documented the new configuration for enabling/disabling
- Added a change log entry
With this many files/new lines-of-code I kept my review more on a macro level -- I focused on ensuring the examples/apis worked/behaved logically and ensuring that the new code wouldn't impact the current agent behavior/stability in a negative way.
From what I can see the configuration does isolate most of the the new behavior, and things that cross over (introduction of the root context, serializing/encoding the additional span information, etc.) make sense and stable to me.
If there's a specific area of the bridge you think needs eyes on it please let me know and I'll take a deeper look, otherwise 👍
| const transOpts = otelSpanOptions.startTime === undefined | ||
| ? {} | ||
| : { startTime: epochMsFromOTelTimeInput(otelSpanOptions.startTime) } | ||
| newTransOrSpan = this._ins.createTransaction(name, transOpts) |
There was a problem hiding this comment.
That is my understanding of the OTel tracing spec: https://github.com/elastic/apm/blob/main/specs/agents/tracing-api-otel.md#compatibility-mapping
There is an inference algorithm for setting transaction.type. It defaults to 'unknown' (rather than our API's effective default of 'custom' for apm.startTransaction(name)) unless there are some particular span kind and attribute values.
I'd considered a separate package, but ultimately rejected it. Here are my notes from that: Notes on whether to have a separate package for the OTel Bridge(For comparison, the old OpenTracing bridge is/was a separate package.) Separate package, e.g. '@elastic/opentelemetry-sdk-node' or whatever name, or just a part of current 'elastic-apm-node'? Pros (for a separate package):
Cons:
Pro or Con? Not sure:
|
Added in 8ed5623 Rendered version here: https://apm-agent-nodejs_2641.docs-preview.app.elstc.co/diff |

The APM agent can act as an OpenTelemetry JS SDK that can be started with:
node -r elastic-apm-node/opentelemetry-sdk myapp.js
The usual OTel JS API can then be used in myapp.js for manual tracing.
Currently just OTel tracing, the OTel metrics API isn't yet supported.
Fixes: #2369
Current status
All working. I need to add user docs and the changelog entry. I need to check if there are any TypeScript snafus -- I don't think there should be, given it is just the straight
@opentelemetry/apiAPI.Reviewer notes
Start here: https://github.com/elastic/apm-agent-nodejs/blob/trentm/otel-bridge/lib/opentelemetry-bridge/README.md
Checklist