Skip to content

Single AppContext switch for the OpenTelemetry v11 behaviors - #7955

Open
ramonsmits wants to merge 2 commits into
otel-ambient-baggagefrom
otel-v11-switch
Open

ramonsmits wants to merge 2 commits into
otel-ambient-baggagefrom
otel-v11-switch

Conversation

@ramonsmits

Copy link
Copy Markdown
Member

Several OpenTelemetry behaviors become the only behavior in v11. There is no option to opt in or opt out in v11. Until v11, one AppContext switch enables all of them together:

AppContext.SetSwitch("NServiceBus.Core.OpenTelemetry.UseV11Behavior", true);

When the switch is on:

  • Trace context and baggage use DistributedContextPropagator (W3C baggage format).
  • Handler spans come from the NServiceBus.Core.Handler ActivitySource.
  • An ambient transport SDK receive span becomes the parent of the incoming span. The sender span becomes a link.
  • Span names include the destination or the message type, for example process orders, send Payment.
  • The incoming span does not get the Start dispatching and Finished dispatching events.
  • The metrics do not get the execution.result tag.
  • Failures do not get the otel.status_code and otel.status_description tags and the exception.escaped attribute.

Removed:

  • The switches UseDistributedContextPropagator, UseHandlerActivitySource and UseTransportActivityAsParent.
  • The options UseMessageTypeNamesInSpanNames, EmitMessageDispatchingEvents and Meters.EmitExecutionResultTags. None of these shipped.

Not changed: PublishTraceMode. It keeps its option in v11.

File layout:

  • obsoletes-v10.cs holds code that is obsolete in v10 and removed in v11. All v11 scaffolding now lives there, including V11BehaviorSwitch. OpenTelemetry/Tracing/obsolete_v11.cs is deleted.
  • OpenTelemetry/Tracing/obsolete_v12.cs is renamed to obsoletes-v11.cs.
  • The test projects get an obsoletes-v10.cs with the [OpenTelemetryV11Defaults] attribute. It runs a test with the switch on. Tests are named for the behavior; the attribute marks the mode.

Stacked on:

Matches the root obsoletes-v10.cs convention where obsoletes-vN.cs holds
code that is obsolete in vN and removed in vN+1. The ExceptionRecordingMode
environment variable scaffold is removed in v12, so it belongs in obsoletes-v11.cs.
Several OpenTelemetry behaviors become the only behavior in v11 with no
option left to opt in or out. Until then they are gated behind one
AppContext switch, NServiceBus.Core.OpenTelemetry.UseV11Behavior, so an
endpoint adopts the v11 behavior as a whole instead of per feature:

- DistributedContextPropagator-based trace context and baggage propagation
- handler spans from the NServiceBus.Core.Handler ActivitySource
- ambient transport SDK receive span as parent of the incoming span
- destination and message type in span names
- no Start/Finished dispatching events on the incoming span
- no execution.result metric tag
- no legacy otel.status_code/otel.status_description tags and no
  exception.escaped attribute

Replaces the UseDistributedContextPropagator, UseHandlerActivitySource and
UseTransportActivityAsParent switches and removes the unreleased
UseMessageTypeNamesInSpanNames, EmitMessageDispatchingEvents and
Meters.EmitExecutionResultTags options. PublishTraceMode keeps its public
option in v11 and is not governed by the switch.

All v11 scaffolding now lives in the root obsoletes-v10.cs, replacing
OpenTelemetry/Tracing/obsolete_v11.cs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants