Skip to content

feat(otel-nestjs-instrumentation): add RPC messaging spans and metrics - #13

Merged
Farenheith merged 4 commits into
mainfrom
feat/rpc-messaging-instrumentation
Sep 4, 2026
Merged

feat(otel-nestjs-instrumentation): add RPC messaging spans and metrics#13
Farenheith merged 4 commits into
mainfrom
feat/rpc-messaging-instrumentation

Conversation

@Farenheith

Copy link
Copy Markdown
Member

Summary

  • Instrument Nest microservice (RPC) handlers with OpenTelemetry messaging semantic conventions (messaging.system, messaging.destination.name, messaging.operation, etc.) for SQS, Kafka, and RabbitMQ transports via duck-typed context inspection.
  • Record messaging.process.duration histogram on RPC completion, gated so HTTP handlers and generic nestjs fallback paths do not emit messaging metrics or duplicate http.server.duration.
  • Restrict forced RPC instrumentation to getType() === 'rpc', propagate trace context from message headers/MessageAttributes, and set CONSUMER span kind for queue-based transports.

Test plan

  • pnpm --filter otel-nestjs-instrumentation test — 121 tests pass
  • Pre-commit turbo build + lint:staged pass
  • After release, bump otel-nestjs-instrumentation in consuming apps (e.g. base-nestjs-app / super-push) and remove transport-specific messaging wrappers
  • Validate NRQL for messaging.process.duration on SQS/Kafka consumers in homologation

Made with Cursor

Farenheith and others added 4 commits September 4, 2026 15:38
Instrument Nest microservice handlers with messaging semantic conventions
and messaging.process.duration for SQS, Kafka, and RabbitMQ transports,
without affecting HTTP handlers or duplicating http.server.duration.

Co-authored-by: Cursor <cursoragent@cursor.com>
context.getType() returns string; only assign when it is http or rpc so
nest build passes strict TypeScript checking in CI.

Co-authored-by: Cursor <cursoragent@cursor.com>
Extract shared consumer metadata and span-attribute helpers, and resolve
RPC messaging metadata once per span to satisfy Sonar duplication limits.

Co-authored-by: Cursor <cursoragent@cursor.com>
…ests

Reuse toMessagingSpanAttributes for metrics recording, consolidate carrier
extraction, and table-drive transport metadata tests to satisfy Sonar.

Co-authored-by: Cursor <cursoragent@cursor.com>
@sonarqubecloud

sonarqubecloud Bot commented Sep 4, 2026

Copy link
Copy Markdown

@Farenheith
Farenheith merged commit b574d78 into main Sep 4, 2026
3 checks passed
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.

1 participant