Skip to content

ddtrace/tracer: add _dd.base_service tag#2175

Merged
rarguelloF merged 19 commits into
mainfrom
rarguelloF/dd-base-service-tag
Sep 5, 2023
Merged

ddtrace/tracer: add _dd.base_service tag#2175
rarguelloF merged 19 commits into
mainfrom
rarguelloF/dd-base-service-tag

Conversation

@rarguelloF

@rarguelloF rarguelloF commented Aug 17, 2023

Copy link
Copy Markdown
Contributor

What does this PR do?

Adds _dd.base_service tag, which is set only for spans that set a service name different than the tracer-level globally configured service name.

Motivation

The tag is used internally to improve service map.

Reviewer's Checklist

  • Changed code has unit tests for its functionality at or near 100% coverage.
  • 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.

@pr-commenter

pr-commenter Bot commented Aug 17, 2023

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2023-09-05 12:14:18

Comparing candidate commit 735d692 in PR branch rarguelloF/dd-base-service-tag with baseline commit 3bd2428 in branch main.

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

@rarguelloF
rarguelloF force-pushed the rarguelloF/dd-base-service-tag branch from 073fa48 to 71587a7 Compare August 30, 2023 10:27
@rarguelloF rarguelloF changed the title WIP: ddtrace/tracer: add _dd.base_service tag ddtrace/tracer: add _dd.base_service tag Aug 30, 2023
@rarguelloF
rarguelloF marked this pull request as ready for review August 30, 2023 11:44
@rarguelloF
rarguelloF requested a review from a team August 30, 2023 11:44

@ahmed-mez ahmed-mez left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BenchmarkPartialFlushing is the most impacted benchmark likely because it calls genBigTraces which uses a custom service name.

Mind pushing a commit with genBigTraces without a the ServiceName("pylons") just to confirm it?

spans := run(t, nil, spanOpts)
for _, s := range spans {
assert.Equal(t, "span-service", s.Service)
assert.NotEmpty(t, s.Meta["_dd.base_service"])

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the expected value here? Can we use assert.Equal?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the fallback default service name value, that we obtain calling filepath.Base(os.Args[0]). I didn't want to assert.Equal to any concrete value because it might change depending on how you run the tests.

I guess an option would be to assert.Equal(t, filepath.Base(os.Args[0]), s.Meta["_dd.base_service"]), but then the test would fail in case we decide to change this logic some day. What do you think?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for explaining, I don't think we should leak the implementation details of the defaulting to this unit test. So you can keep the code as is and just add a comment to say why we are not asserting with Equal.

@ahmed-mez ahmed-mez left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I'm fine with the changes in genBigTraces since it's used for partial flushing benchmarking and not having a custom service per span will not impact partial flushing per se.

I couldn't find a way to improve the perf either, the logic is pretty straightforward and the 3% perf regression is acceptable in this case I believe.

@rarguelloF one final question, did we have any figures on how often this scenario happens in real life? (i.e overriding DD_SERVICE)

@rarguelloF
rarguelloF merged commit b7a1753 into main Sep 5, 2023
@rarguelloF
rarguelloF deleted the rarguelloF/dd-base-service-tag branch September 5, 2023 13:14
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.

2 participants