Skip to content

chore(doc): doocument tracer.ContextWithSpan panic #4313

Open
genesor wants to merge 1 commit intomainfrom
ben.db/ctx-with-span
Open

chore(doc): doocument tracer.ContextWithSpan panic #4313
genesor wants to merge 1 commit intomainfrom
ben.db/ctx-with-span

Conversation

@genesor
Copy link
Member

@genesor genesor commented Dec 24, 2025

What does this PR do?

Improve documentation of the tracer.ContextWithSpan function in charge of adding a Span to a context.Context

Motivation

We spent nearly an hour with @igoragoli debugging a future contrib that was not showing this panic properly.
Having clear documentation over a function that can cause a panic is always nice.

Reviewer's Checklist

  • Changed code has unit tests for its functionality at or near 100% coverage.
  • System-Tests covering this feature have been added and enabled with the va.b.c-dev version tag.
  • There is a benchmark for any new code, or changes to existing code.
  • If this interacts with the agent in a new way, a system test has been added.
  • New code is free of linting errors. You can check this by running ./scripts/lint.sh locally.
  • Add an appropriate team label so this PR gets put in the right place for the release notes.
  • Non-trivial go.mod changes, e.g. adding new modules, are reviewed by @DataDog/dd-trace-go-guild.

Unsure? Have a question? Request a review!

@genesor genesor requested a review from igoragoli December 24, 2025 17:13
@genesor genesor requested a review from a team as a code owner December 24, 2025 17:13
@genesor genesor requested a review from mtoffl01 December 24, 2025 17:13
@pr-commenter
Copy link

pr-commenter bot commented Dec 24, 2025

Benchmarks

Benchmark execution time: 2025-12-24 17:26:37

Comparing candidate commit 87be0c5 in PR branch ben.db/ctx-with-span with baseline commit e744f8a in branch main.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 15 metrics, 0 unstable metrics.

@codecov
Copy link

codecov bot commented Dec 24, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 54.80%. Comparing base (e744f8a) to head (87be0c5).
⚠️ Report is 9 commits behind head on main.

Additional details and impacted files
Files with missing lines Coverage Δ
ddtrace/tracer/context.go 61.90% <ø> (ø)

... and 21 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.


// ContextWithSpan returns a copy of the given context which includes the span s.
//
// ctx must be non-nil. If ctx is nil, context.WithValue panics, "cannot create context from nil parent".
Copy link
Member

Choose a reason for hiding this comment

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

Since this already panics, shall we add an explicit hard assertion (panic) that could make it easier to explain.

Copy link
Member Author

Choose a reason for hiding this comment

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

@kakkoyun what kind of assertion are you expecting ? A unit test ?

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