Skip to content

refactor: adopt OTel semconv v1.40.0 for datastore and external spans#23

Merged
ankurs merged 4 commits intomainfrom
fix/semconv-attributes
Mar 29, 2026
Merged

refactor: adopt OTel semconv v1.40.0 for datastore and external spans#23
ankurs merged 4 commits intomainfrom
fix/semconv-attributes

Conversation

@ankurs
Copy link
Copy Markdown
Member

@ankurs ankurs commented Mar 28, 2026

Summary

  • Datastore spans: use db.system.name, db.collection.name, db.operation.name, db.query.text per DB semconv spec
  • External spans: use url.full and server.address per HTTP client semconv spec; parse hostname from absolute URLs for accurate server.address
  • Gate db.query.text behind datastore span check — non-datastore spans use generic query attribute to avoid semantic mismatch

Test plan

  • make test passes with -race
  • make build compiles cleanly
  • Deploy to staging and verify span attributes in trace backend (Grafana/Jaeger)

ankurs added 2 commits March 28, 2026 23:41
Datastore spans (NewDatastoreSpan, SetQuery):
- store → db.system.name
- collection → db.collection.name
- operation → db.operation.name
- query → db.query.text

External spans (buildExternalSpan):
- url → url.full
- added server.address attribute
Copilot AI review requested due to automatic review settings March 28, 2026 15:42
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 28, 2026

Warning

Rate limit exceeded

@ankurs has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 17 minutes and 27 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 17 minutes and 27 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 0a626e33-bd37-4f7b-9879-8d0b79915132

📥 Commits

Reviewing files that changed from the base of the PR and between 0a557ba and 1b2a09c.

📒 Files selected for processing (1)
  • README.md
📝 Walkthrough

Walkthrough

This PR updates tracing attribute handling to use OpenTelemetry semantic convention helpers in tracing.go and fixes README function/type reference links to updated line ranges in the tracing source.

Changes

Cohort / File(s) Summary
Documentation
README.md
Adjusted markdown anchor targets/line ranges for ClientSpan, GRPCTracingSpan, Span, and New*Span helper references; no code changes.
Tracing / Semconv Migration
tracing.go
Imported OpenTelemetry semantic conventions and replaced custom attributes with semconv helpers: updated (*tracingSpan).SetQuery() to use semconv.DBQueryText when datastore=true (and retain parameterized query storage), switched datastore attributes in NewDatastoreSpan() to semconv.DBSystemNameKey, semconv.DBCollectionName, semconv.DBOperationName, and updated buildExternalSpan() to set semconv.URLFull(url) and semconv.ServerAddress(serverAddr) instead of generic url attribute.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

🐰 I nibbled code by moonlight's glow,
Replaced loose attrs with semconv's show,
Queries tidy, URLs aligned,
Traces hop neat — and brightly signed. ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: adopting OpenTelemetry semantic conventions v1.40.0 for datastore and external spans, which is the primary focus of the changeset.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/semconv-attributes

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

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

Refactors span attribute emission to align datastore and external HTTP spans with OpenTelemetry semantic conventions (semconv) v1.40.0, and updates generated docs accordingly.

Changes:

  • Switch datastore span attributes to db.system.name, db.collection.name, db.operation.name, db.query.text.
  • Switch external span attributes to url.full and server.address.
  • Regenerate README.md to reflect updated line references.

Reviewed changes

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

File Description
tracing.go Replaces custom span attribute keys with OTel semconv v1.40.0 attributes for datastore and external spans.
README.md Updates generated gomarkdoc links/line numbers after code changes.

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

Comment thread tracing.go Outdated
Comment thread tracing.go
Comment thread tracing.go
Comment thread tracing.go
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@tracing.go`:
- Around line 177-181: Replace the invalid semconv usage inside
otelSpan.SetAttributes: change semconv.DBSystemNameKey.String(datastore) to the
function form semconv.DBSystem(datastore) so all DB attributes use the
consistent function patterns; keep or ensure
semconv.DBCollectionName(collection) and semconv.DBOperationName(operation) are
used together in otelSpan.SetAttributes to match semconv v1.40.0 API.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e261fd30-7147-410f-8a59-d86117c3ead4

📥 Commits

Reviewing files that changed from the base of the PR and between a060d9b and 2dc0131.

📒 Files selected for processing (2)
  • README.md
  • tracing.go

Comment thread tracing.go
…from URL

- SetQuery: only set db.query.text for datastore spans; use generic
  "query" attribute for non-datastore spans to avoid semantic mismatch
- buildExternalSpan: parse server.address from URL hostname when an
  absolute URL is provided, instead of always using the name parameter
@ankurs ankurs changed the title refactor: use OTel semconv v1.40.0 for span attributes refactor: adopt OTel semconv v1.40.0 for datastore and external spans Mar 29, 2026
@ankurs ankurs requested a review from Copilot March 29, 2026 05:55
Copy link
Copy Markdown

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

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


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

Comment thread README.md Outdated
Comment thread README.md Outdated
Comment thread README.md Outdated
Comment thread README.md Outdated
Comment thread tracing.go
Comment thread README.md Outdated
Comment thread README.md Outdated
Comment thread README.md Outdated
@ankurs ankurs requested a review from Copilot March 29, 2026 06:10
@ankurs ankurs merged commit 8a11a85 into main Mar 29, 2026
9 checks passed
@ankurs ankurs deleted the fix/semconv-attributes branch March 29, 2026 06:11
Copy link
Copy Markdown

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

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.


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

Comment thread tracing.go
@ankurs ankurs mentioned this pull request Mar 31, 2026
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