tracer: Log a warning on NoopTracer.StartSpan() (#2991) (#3378)#3449
Conversation
Co-authored-by: Mikayla Toffler <[email protected]>
Datadog ReportBranch report: ✅ 0 Failed, 4518 Passed, 65 Skipped, 3m 49.68s Total Time |
BenchmarksBenchmark execution time: 2025-05-21 21:04:01 Comparing candidate commit 43d4ac9 in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 21 metrics, 0 unstable metrics. |
|
@mtoffl01 We need to find a different approach. We didn't consider DevEx, as this can be noisy, and we found that can generate lots of logs in production systems that are not running the tracer. It was set as debug log in #3513 and ready for release in case it generates issues to external customers. |
|
Relevant customer feedback: #3515 |
NOTE: This PR cherry-picks a commit that was previously reverted in v2-dev due to test failures.
What does this PR do?
Logs a warning about calling
tracer.StartwhenNoopTracer.StartSpanis invoked.Motivation
Users commonly forget to call
tracer.Startbefore generating spans with a contrib or the trace API. The tracer must be running in order to collect the spans, so this warning message should direct the user to the necessary steps and effectively prevent against this common customer escalation.Background
Until
tracer.Startis invoked, theglobaltracerobject is set toNoopTracer. It doesn't change totraceruntiltracer.Startis run. So any time theStartSpanmethod is invoked on theNoopTracer, we know thattracer.Starthas not yet been called.Reviewer's Checklist
golangci-lint runlocally.Unsure? Have a question? Request a review!