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

ddtrace/tracer: implement peer.service #1975

Merged
merged 5 commits into from
Jun 14, 2023
Merged

Conversation

rarguelloF
Copy link
Contributor

@rarguelloF rarguelloF commented May 10, 2023

What does this PR do?

  • Implement peer.service defaults calculation in the tracer.
  • Some config flags added:
    • DD_TRACE_PEER_SERVICE_DEFAULTS_ENABLED: default value is false and only applies when DD_TRACE_SPAN_ATTRIBUTE_SCHEMA == 0. In other case, peer.service defaults calculation is always enabled.
    • DD_TRACE_PEER_SERVICE_MAPPING: same behavior as DD_SERVICE_MAPPING but for peer.service.
  • Internal tags that are tracked:
    • _dd.peer.service.source: the precursor tag that was used to set peer.service.
    • _dd.peer.service.remapped_from: the previous value before remapping happened (if applies).

Motivation

Implement peer.service as it will be used in different parts of the product.

Describe how to test/QA your changes

Reviewer's Checklist

  • Changed code has unit tests for its functionality.
  • If this interacts with the agent in a new way, a system test has been added.

Sorry, something went wrong.

@pr-commenter
Copy link

pr-commenter bot commented May 10, 2023

Benchmarks

Benchmark execution time: 2023-06-14 09:26:42

Comparing candidate commit e101abc in PR branch rarguelloF/add-peer-service with baseline commit b9a86a0 in branch main.

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

scenario:BenchmarkConcurrentTracing-24

  • 🟩 execution_time [-0.145ms; -0.115ms] or [-11.176%; -8.840%]

@rarguelloF rarguelloF changed the title WIP: implement peer.service Implement peer.service May 11, 2023
@rarguelloF rarguelloF marked this pull request as ready for review May 11, 2023 17:18
@rarguelloF rarguelloF requested a review from a team May 11, 2023 17:18
@rarguelloF rarguelloF changed the title Implement peer.service ddtrace/tracer: implement peer.service May 12, 2023
Copy link
Contributor

@katiehockman katiehockman left a comment

Choose a reason for hiding this comment

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

I don't see DD_TRACE_PEER_SERVICE_DEFAULTS_ENABLED discussed anywhere in the RFCs/docs. Can you add this to the specification first? I'm not so sure about the naming.
Or maybe we don't even want this at all. Perhaps using this is contingent on setting DD_TRACE_SPAN_ATTRIBUTE_SCHEMA=v1, with no other way to configure it. Let's discuss that offline.

Copy link
Contributor

@katiehockman katiehockman left a comment

Choose a reason for hiding this comment

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

I don't see DD_TRACE_PEER_SERVICE_DEFAULTS_ENABLED discussed anywhere in the RFCs/docs. Can you add this to the specification first? I'm not so sure about the naming.
Or maybe we don't even want this at all. Perhaps using this is contingent on setting DD_TRACE_SPAN_ATTRIBUTE_SCHEMA=v1, with no other way to configure it. Let's discuss that offline.

Comment on lines 243 to 251
// peer.service tag is always enabled if using attribute schema >= 1
c.peerServiceDefaultsEnabled = true
if c.spanAttributeSchemaVersion == int(namingschema.SchemaV0) {
c.peerServiceDefaultsEnabled = internal.BoolEnv("DD_TRACE_PEER_SERVICE_DEFAULTS_ENABLED", false)
}
c.peerServiceMappings = make(map[string]string)
if v := os.Getenv("DD_TRACE_PEER_SERVICE_MAPPING"); v != "" {
internal.ForEachStringTag(v, func(key, val string) { c.peerServiceMappings[key] = val })
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add a unit test to cover this?

@@ -414,10 +415,86 @@ func (t *trace) finishedOne(s *span) {
if hn := tr.hostname(); hn != "" {
s.setMeta(keyTracerHostname, hn)
}
setPeerService(s, tr.config)
Copy link
Contributor

Choose a reason for hiding this comment

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

I just tested this for a service in dd-go, and this never get executed. In almost all cases the peer.service needs to be set on a leaf span, but because of the condition at line 404 if len(t.spans) != t.finished { return }, this function is never reached.

@rarguelloF rarguelloF force-pushed the rarguelloF/add-peer-service branch from 13bb529 to dc44b3e Compare June 2, 2023 17:23
@rarguelloF rarguelloF merged commit 087eb5a into main Jun 14, 2023
@rarguelloF rarguelloF deleted the rarguelloF/add-peer-service branch June 14, 2023 09:42
dianashevchenko pushed a commit that referenced this pull request Jun 14, 2023
Co-authored-by: Kyle Nusbaum <kyle@datadog.com>
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.

None yet

7 participants