add traceContinuationStrategy config option; add Span Links API#2692
add traceContinuationStrategy config option; add Span Links API#2692
Conversation
This adds a `traceContinutationStrategy` configuration option to allow some control over how the APM Agent uses incoming trace-context headers for context propagation. The default 'continue_always' value results in the current behaviour of using 'traceparent' and 'tracestate' per the W3C spec. A value of 'restart_always' will result in incoming 'traceparent' and 'tracestate' headers being *ignored*. This can be useful for a service that is receiving problematic tracing headers from an upstream service that is unmonitored (without root transactions in ES, the APM UI has limitations) or otherwise out of the user's control (sampling rate may not be what the user wants). This is currently *experimental* while a design for `trace_continuation_strategy` is being discussed at elastic/apm#286. This currently implements a *subset* of the proposed design there -- `restart_external` is not yet implemented.
astorm
left a comment
There was a problem hiding this comment.
Does what is says and aligns with the spec -- no objections to anything in the implementation. Approving.
|
|
||
| :type-string: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type[<string>] | ||
| :type-string-array: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type[<string[]>] | ||
| :type-array: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array[<Array>] |
There was a problem hiding this comment.
Question -- did not having the Array type here break something or is this just a bit of "fix it as we go" maintenance? (no objection, just curious)
There was a problem hiding this comment.
I had asked Brandon about how to add it and then requested review before I remembered to do that step. Nothing breaks, but the links <Array> rendering in the docs (e.g. at https://apm-agent-nodejs_2692.docs-preview.app.elstc.co/guide/en/apm/agent/nodejs/master/agent-api.html#apm-start-transaction) doesn't look as nice without it.
| // Decide whether to use trace-context headers, if any, for a | ||
| // distributed trace. | ||
| const traceparent = req.headers.traceparent || req.headers['elastic-apm-traceparent'] | ||
| const tracestate = req.headers.tracestate | ||
| const trans = agent.startTransaction(null, null, { |
There was a problem hiding this comment.
Just noting that the change from var to const will block scope these variables, but it doesn't look like they were accessed outside this block so 👍
This adds a 'links' option to `createTransaction` and `createSpan` APIs
for specifying span links.
apm.startSpan('name', { links: [ ... ] })
https://github.com/elastic/apm/blob/main/specs/agents/span-links.md
Span links support is added to the OTel Bridge as well:
tracer.startSpan('name', { links: [ ... ] })
This adds a `traceContinutationStrategy` configuration option to allow
some control over how the APM Agent uses incoming trace-context headers
for context propagation.
https://github.com/elastic/apm/blob/main/specs/agents/trace-continuation.md
This also fixes a whitespace parsing issue in TraceState.
Closes: #2592
Closes: #2673
Closes: #2554
Obsoletes: #2555
This adds a 'links' option to
createTransactionandcreateSpanAPIsfor specifying span links.
apm.startSpan('name', { links: [ ... ] })
https://github.com/elastic/apm/blob/main/specs/agents/span-links.md
Span links support is added to the OTel Bridge as well:
tracer.startSpan('name', { links: [ ... ] })
This adds a
traceContinutationStrategyconfiguration option to allowsome control over how the APM Agent uses incoming trace-context headers
for context propagation.
https://github.com/elastic/apm/blob/main/specs/agents/trace-continuation.md
This also fixes a whitespace parsing issue in TraceState.
Closes: #2592
Closes: #2673
Closes: #2554
Obsoletes: #2555
checklist