-
Notifications
You must be signed in to change notification settings - Fork 445
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
ddtrace/tracer: add integration tag to spans_started/finished #3023
base: main
Are you sure you want to change the base?
Conversation
Datadog ReportBranch report: ✅ 0 Failed, 5211 Passed, 72 Skipped, 2m 46.57s Total Time |
BenchmarksBenchmark execution time: 2025-02-24 20:15:18 Comparing candidate commit 3ce582f in PR branch Found 1 performance improvements and 9 performance regressions! Performance is the same for 51 metrics, 1 unstable metrics. scenario:BenchmarkOTelApiWithCustomTags/datadog_otel_api-24
scenario:BenchmarkOTelApiWithCustomTags/otel_api-24
scenario:BenchmarkPartialFlushing/Disabled-24
scenario:BenchmarkPartialFlushing/Enabled-24
scenario:BenchmarkSetTagStringer-24
scenario:BenchmarkSingleSpanRetention/no-rules-24
scenario:BenchmarkSingleSpanRetention/with-rules/match-all-24
scenario:BenchmarkSingleSpanRetention/with-rules/match-half-24
scenario:BenchmarkStartRequestSpan-24
scenario:BenchmarkStartSpan-24
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, so you're reporting spansStarted/spansFinished on span.Start/span.Finished if the integration is not empty, and leaving the chunk reporting to any spans that are manual... I understand why you did this but not totally sure about the approach.
span.Start and span.Stop are typically called quite frequently, so if a majority of the spans are from automatic integrations, this will be very noisy (and defeats the purpose of reporting the metrics at a specified interval, to reduce noise)
One alternative idea:
Change the way we track spansStarted and spansFinished to be some kind of counter map that includes the integration name, e.g. map[string]uint32
where the key is the integration name and the value is the count of spans started/finished that integration name. Then, in this goroutine, we'll have to iterate over the map and report the spans started/finished per integration
(or some other idea I haven't thought of?)
@mtoffl01 Good points! A map would probably work better; I was hesitant at first since I didn't want to change too much of what already exists, but knowing that these metrics are pretty old... I'm more down to change it up now. |
@hannahkm I'm approving this but we should investigate why the benchmarks report the increased allocations. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, I definitely have some concerns 🤔 Maybe you can write some additional tests to provide peace of mind....
- Tests designed to try and make the system fail -- what happens when you have multiple goroutines access a start span / finish span method, can we prove that we've protected against a race condition?
- Maybe you want to write dedicated benchmarks to show how much performance is impacted
ec199cc
to
d0ab157
Compare
2302f9e
to
5020281
Compare
What does this PR do?
Add a
integration
tag to the existingdatadog.tracer.spans_started
anddatadog.tracer.spans_finished
metrics. The value of the tag will be the name of the component from which the span was started. For example, for a contrib, it will be the name of the contrib package (chi
,net/http
, etc). For spans that were created manually, the tag will saymanual
.For the purpose of adding tags, we move the logic of counting finished spans to
span.finish()
rather thantrace.finishChunk()
. Since we must read theintegration
data from each individual span, we would rather increment our counter each time one span finishes. Counting infinishChunk()
as we did previously would require a for loop, which might impact efficiency.Motivation
We want to know, in addition to when a span is started, where the span originated from. This could be a contrib or a manual implementation.
Reviewer's Checklist
v2-dev
branch and reviewed by @DataDog/apm-go.Unsure? Have a question? Request a review!