Align Mocha Instrumentation with Semantic Conventions#9472
Merged
PascalSenn merged 1 commit intomainfrom Mar 28, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
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.
This was referenced May 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.