Skip to content

Align Mocha Instrumentation with Semantic Conventions#9472

Merged
PascalSenn merged 1 commit intomainfrom
pse/fix-mocha-tracing-spans
Mar 28, 2026
Merged

Align Mocha Instrumentation with Semantic Conventions#9472
PascalSenn merged 1 commit intomainfrom
pse/fix-mocha-tracing-spans

Conversation

@PascalSenn
Copy link
Copy Markdown
Member

@PascalSenn PascalSenn commented Mar 28, 2026

No description provided.

Copilot AI review requested due to automatic review settings March 28, 2026 12:27
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates Mocha’s OpenTelemetry instrumentation span naming to better match messaging semantic convention patterns (destination/subject first, operation verb last) across saga execution, bus diagnostics, and outbox dispatch.

Changes:

  • Renames saga Activities to a consistent {SagaName} <operation> ... pattern.
  • Renames receive/consume/dispatch Activities to {target} <operation> ordering.
  • Reduces outbox send span-name cardinality by removing the message id from the Activity name.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
src/Mocha/src/Mocha/Sagas/Saga.cs Updates saga-related Activity names (process/persist/create/transition/enter/reply).
src/Mocha/src/Mocha/Observability/OpenTelemetryDiagnosticObserver.cs Updates receive/consume/dispatch Activity names and dispatch operationName formatting.
src/Mocha/src/Mocha.EntityFrameworkCore.Postgres/Outbox/OutboxProcessor.cs Changes outbox send Activity name to a low-cardinality value.
Comments suppressed due to low confidence (1)

src/Mocha/src/Mocha/Observability/OpenTelemetryDiagnosticObserver.cs:158

  • In DispatchActivity the span/operation name uses the verb "publish" (via _operationType), but the semantic-convention operation type tag and metrics are recorded as MessagingOperationType.Send. This creates inconsistent telemetry (queries on messaging.operation.type vs span name won't line up). Consider aligning the verb used in the operation/span name with the operation type you're tagging/recording (e.g., use "send" consistently or introduce a distinct operation type/tag for publish if you need to preserve that distinction).
            _operationType = "publish"; // TODO we need to get this from the route i guess
            _startTime = Stopwatch.GetTimestamp();
            _context = context;

            // Start activity early but don't enrich with state yet
            // State will be captured in Dispose() after all middlewares have run
            var operationName = $"{context.DestinationAddress} {_operationType}";
            _activity = OpenTelemetry
                .Source.StartActivity(operationName, ActivityKind.Producer)
                ?.SetOperationName(operationName)
                .SetOperationType(MessagingOperationType.Send)
                .EnrichMessageDefault();

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/Mocha/src/Mocha/Sagas/Saga.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