Skip to content

Conversation

@uuushiro
Copy link
Contributor

@uuushiro uuushiro commented Feb 1, 2026

Summary

This PR adds otel.kind = "client" to the db_span! macro, ensuring DB spans are properly recognized as Client spans by OpenTelemetry-compatible APM tools.

Problem

When using tracing-opentelemetry as the bridge between tracing and OpenTelemetry, DB spans created by sea-orm are not recognized as database client calls because:

  • tracing-opentelemetry uses the otel.kind field to determine SpanKind
  • Without this field, spans default to SpanKind::Internal
  • APM tools (Datadog, Jaeger, etc.) use SpanKind::Client + db.system attribute to identify DB operations

Solution

Add otel.kind = "client" to the db_span! macro. This is the documented approach for setting SpanKind via tracing spans.

Changes

::tracing::info_span!(
    $name,
    otel.kind = "client",  // Added
    db.system = ...,
    db.operation = ...,
    ...
)

…ility

This ensures DB spans are recognized as Client spans by OpenTelemetry-compatible
APM tools (Datadog, Jaeger, etc.), enabling proper DB span visualization and
SQL query tracking.

The tracing-opentelemetry crate uses the otel.kind field to determine SpanKind.
Without this, spans default to Internal and may not be properly categorized
as database operations by APM backends.
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