Skip to content

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

Merged
darccio merged 8 commits into
mainfrom
mtoff/log_nooptracer_startspan
Apr 4, 2025
Merged

tracer: Log a warning on NoopTracer.StartSpan()#2991
darccio merged 8 commits into
mainfrom
mtoff/log_nooptracer_startspan

Conversation

@mtoffl01

@mtoffl01 mtoffl01 commented Nov 25, 2024

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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

darccio commented Dec 5, 2024

Copy link
Copy Markdown
Member

@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
Copy Markdown
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

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

Copy link
Copy Markdown

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

pr-commenter Bot commented Dec 17, 2024

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2025-04-03 17:46:30

Comparing candidate commit 69e63be in PR branch mtoff/log_nooptracer_startspan with baseline commit 8819cd7 in branch main.

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

scenario:BenchmarkStartRequestSpan-24

  • 🟥 allocated_mem [+400 bytes; +401 bytes] or [+156.460%; +156.665%]
  • 🟥 allocations [+5; +5] or [+71.429%; +71.429%]
  • 🟥 execution_time [+704.293ns; +706.347ns] or [+159.458%; +159.923%]

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

darccio commented Jan 6, 2025

Copy link
Copy Markdown
Member

@mtoffl01 We should fix the benchmarks' issue before merging, as these logging statements have a small impact and in benchmarks add up very quickly.

@mtoffl01
mtoffl01 marked this pull request as draft January 8, 2025 20:21
@datadog-datadog-prod-us1

datadog-datadog-prod-us1 Bot commented Mar 28, 2025

Copy link
Copy Markdown

Datadog Report

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

✅ 0 Failed, 5505 Passed, 72 Skipped, 3m 5.73s Total Time

@mtoffl01
mtoffl01 marked this pull request as ready for review March 28, 2025 15:49
@darccio

darccio commented Apr 4, 2025

Copy link
Copy Markdown
Member

Benchmark results are caused by the logger's usage of fmt.Sprintf. Another PR fixes this #3365.

As the release branch for v1.73.0 was already created, we'll have to cherry-pick this before the dogfooding process next week.

@darccio
darccio merged commit 885aaa2 into main Apr 4, 2025
@darccio
darccio deleted the mtoff/log_nooptracer_startspan branch April 4, 2025 07:46
darccio added a commit that referenced this pull request Apr 4, 2025
darccio added a commit that referenced this pull request Apr 4, 2025
mtoffl01 added a commit that referenced this pull request Apr 4, 2025
mtoffl01 added a commit that referenced this pull request Apr 17, 2025
mtoffl01 added a commit that referenced this pull request May 21, 2025
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