Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

mtoffl01
Copy link
Contributor

@mtoffl01 mtoffl01 commented Nov 25, 2024

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.
  • 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!

@mtoffl01
Copy link
Contributor Author

I cannot access gitlab so I'm not sure if the failure is significant.

@mtoffl01 mtoffl01 marked this pull request as ready for review November 26, 2024 19:59
@mtoffl01 mtoffl01 requested a review from a team as a code owner November 26, 2024 19:59
@darccio
Copy link
Member

darccio commented Dec 5, 2024

@mtoffl01 It actually looks relevant:

pkg: gopkg.in/DataDog/dd-trace-go.v1/contrib/internal/httptrace
cpu: Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz
BenchmarkStartRequestSpan-24    	2024/11/26 18:10:05 Datadog Tracer v1.71.0-dev WARN: Tracer must be started before starting a span; Review the docs for more information: https://docs.datadoghq.com/tracing/trace_collection/library_config/go/
2024/11/26 18:10:05 Datadog Tracer v1.71.0-dev WARN: Tracer must be started before starting a span; Review the docs for more information: https://docs.datadoghq.com/tracing/trace_collection/library_config/go/
2024/11/26 18:10:05 Datadog Tracer v1.71.0-dev WARN: Tracer must be started before starting a span; Review the docs for more information: https://docs.datadoghq.com/tracing/trace_collection/library_config/go/
2024/11/26 18:10:05 Datadog Tracer v1.71.0-dev WARN: Tracer must be started before starting a span; Review the docs for more information: https://docs.datadoghq.com/tracing/trace_collection/library_config/go/
2024/11/26 18:10:05 Datadog Tracer v1.71.0-dev WARN: Tracer must be started before starting a span; Review the docs for more information: https://docs.datadoghq.com/tracing/trace_collection/library_config/go/
2024/11/26 18:10:05 Datadog Tracer v1.71.0-dev WARN: Tracer must be started before starting a span; Review the docs for more information: https://docs.datadoghq.com/tracing/trace_collection/library_config/go/
[...]
2024/11/26 18:10:05 Datadog Tracer v1.71.0-dev WARN: Tracer must be started before starting a span; Review the docs for more information: https://docs.datadoghq.com/tracing/trace_collection/library_config/go/
2024/11/26 18:10:05 Datadog Tracer v1.71.0-dev WARN: Tracer must be started before starting a span; Review the docs for more information: https://docs.datadoghq.com/tracing/trace_collection/library_config/go/
2024/11/26 18:10:05 Dat
�[33;1mJob's log exceeded limit of 33554432 bytes.
Job execution will continue but no more output will be collected.�

I guess it's just a matter of starting the tracer properly in that benchmark.

@mtoffl01
Copy link
Contributor Author

Moving this to draft while I work on gitlab access.

@mtoffl01 mtoffl01 marked this pull request as draft December 10, 2024 14:08
@datadog-datadog-prod-us1
Copy link

datadog-datadog-prod-us1 bot commented Dec 17, 2024

Datadog Report

Branch report: mtoff/log_nooptracer_startspan
Commit report: d2c05b0
Test service: dd-trace-go

✅ 0 Failed, 5113 Passed, 70 Skipped, 2m 40.23s Total Time

@pr-commenter
Copy link

pr-commenter bot commented Dec 17, 2024

Benchmarks

Benchmark execution time: 2024-12-17 19:00:05

Comparing candidate commit 57e0ce5 in PR branch mtoff/log_nooptracer_startspan with baseline commit e8b2b8c in branch main.

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

scenario:BenchmarkSetTagMetric-24

  • 🟥 execution_time [+3.351ns; +6.069ns] or [+2.636%; +4.773%]

scenario:BenchmarkSetTagString-24

  • 🟥 execution_time [+12.520ns; +14.940ns] or [+11.069%; +13.208%]

scenario:BenchmarkSetTagStringPtr-24

  • 🟥 execution_time [+8.249ns; +10.851ns] or [+4.766%; +6.269%]

scenario:BenchmarkSetTagStringer-24

  • 🟥 execution_time [+8.276ns; +14.644ns] or [+5.758%; +10.188%]

scenario:BenchmarkStartRequestSpan-24

  • 🟥 allocated_mem [+2.465KB; +2.465KB] or [+1400.311%; +1400.711%]
  • 🟥 allocations [+15; +15] or [+300.000%; +300.000%]

@github-actions github-actions bot added the apm:ecosystem contrib/* related feature requests or bugs label Dec 17, 2024
@mtoffl01 mtoffl01 marked this pull request as ready for review December 17, 2024 18:18
@mtoffl01 mtoffl01 requested a review from a team as a code owner December 17, 2024 18:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
apm:ecosystem contrib/* related feature requests or bugs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants