Skip to content

tracer: Log a warning on NoopTracer.StartSpan() (#2991) (#3378)#3449

Merged
mtoffl01 merged 6 commits into
mainfrom
mtoff/v2/noop-tracer-warning
May 21, 2025
Merged

tracer: Log a warning on NoopTracer.StartSpan() (#2991) (#3378)#3449
mtoffl01 merged 6 commits into
mainfrom
mtoff/v2/noop-tracer-warning

Conversation

@mtoffl01

@mtoffl01 mtoffl01 commented Apr 17, 2025

Copy link
Copy Markdown
Contributor

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.Start when NoopTracer.StartSpan is invoked.

Motivation

Users commonly forget to call tracer.Start before 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.Start is invoked, the globaltracer object is set to NoopTracer. It doesn't change to tracer until tracer.Start is run. So any time the StartSpan method is invoked on the NoopTracer, we know that tracer.Start has not yet been called.

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 golangci-lint run 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!

@datadog-datadog-prod-us1

datadog-datadog-prod-us1 Bot commented Apr 17, 2025

Copy link
Copy Markdown

Datadog Report

Branch report: mtoff/v2/noop-tracer-warning
Commit report: f563240
Test service: dd-trace-go

✅ 0 Failed, 4518 Passed, 65 Skipped, 3m 49.68s Total Time

@pr-commenter

pr-commenter Bot commented Apr 17, 2025

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2025-05-21 21:04:01

Comparing candidate commit 43d4ac9 in PR branch mtoff/v2/noop-tracer-warning with baseline commit d3a2c04 in branch main.

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

@darccio

darccio commented May 9, 2025

Copy link
Copy Markdown
Member

@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.

@darccio

darccio commented May 14, 2025

Copy link
Copy Markdown
Member

Relevant customer feedback: #3515

@mtoffl01
mtoffl01 marked this pull request as ready for review May 21, 2025 11:18
@mtoffl01
mtoffl01 requested review from a team as code owners May 21, 2025 11:18
@mtoffl01
mtoffl01 enabled auto-merge (squash) May 21, 2025 20:53
@mtoffl01
mtoffl01 merged commit 42de058 into main May 21, 2025
@mtoffl01
mtoffl01 deleted the mtoff/v2/noop-tracer-warning branch May 21, 2025 21:10
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