Skip to content

Provide a way to opt-out or filter Start dispatching and Finished dispatching activity events #7689

@irinascurtu

Description

@irinascurtu

Describe the suggested improvement

Is your improvement related to a problem? Please describe.

When using NServiceBus with an OpenTelemetry exporter (e.g. Azure Monitor/Application Insights), a "Start dispatching" and "Finished dispatching" ActivityEvent are added to the incoming message span on every processed message. In telemetry backends that charge per ingested record, these events accumulate cost with little diagnostic value. There is currently no way to opt out of them at the NServiceBus configuration level.
Reference: https://discuss.particular.net/t/filter-opentelemetry-tracing-events/4590

Describe the suggested solution

Add a TracingSettings class accessible via an extension method on EndpointConfiguration: endpointConfiguration.Tracing().DisableDispatchingActivityEvents(); This suppresses the two dispatching ActivityEvents without affecting spans, metrics, or any other telemetry. Opt-out keeps the behavior unchanged for existing users

Describe alternatives you've considered

  • Filter at the exporter/backend level - Azure Data Collection Rules can drop these records after ingestion, but you still pay for the ingestion cost. It also leaks an NServiceBus implementation detail into infrastructure config.
  • Custom ActivitySource wrapping NServiceBus - the workaround the customer ended up using. Fragile because it must track internal NServiceBus tracing changes manually.
  • OTel SDK sampler - samplers operate on spans (Activities), not on events within a span, so they cannot target these specific events.

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions