Skip to content

feat(tracing-spans): add otel.kind = "client" for OpenTelemetry compatibility#2937

Merged
tyt2y3 merged 1 commit intoSeaQL:masterfrom
uuushiro:fix/add-otel-kind-to-tracing-spans
Feb 27, 2026
Merged

feat(tracing-spans): add otel.kind = "client" for OpenTelemetry compatibility#2937
tyt2y3 merged 1 commit intoSeaQL:masterfrom
uuushiro:fix/add-otel-kind-to-tracing-spans

Conversation

@uuushiro
Copy link
Copy Markdown
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.
@tyt2y3
Copy link
Copy Markdown
Member

tyt2y3 commented Feb 27, 2026

sorry I missed this

@tyt2y3 tyt2y3 merged commit 3cad6c1 into SeaQL:master Feb 27, 2026
38 checks passed
@github-actions
Copy link
Copy Markdown

🎉 Released In 2.0.0-rc.35 🎉

Huge thanks for the contribution!
This feature has now been released, so it's a great time to upgrade.
Show some love with a ⭐ on our repo, every star counts!

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.

3 participants