Skip to content

ddtrace/tracer: implement peer.service#1975

Merged
rarguelloF merged 5 commits into
mainfrom
rarguelloF/add-peer-service
Jun 14, 2023
Merged

ddtrace/tracer: implement peer.service#1975
rarguelloF merged 5 commits into
mainfrom
rarguelloF/add-peer-service

Conversation

@rarguelloF

@rarguelloF rarguelloF commented May 10, 2023

Copy link
Copy Markdown
Contributor

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.

@pr-commenter

pr-commenter Bot commented May 10, 2023

Copy link
Copy Markdown

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

@katiehockman katiehockman 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.

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.

@katiehockman katiehockman 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.

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 thread ddtrace/ext/messaging.go
Comment thread ddtrace/ext/messaging.go
Comment thread ddtrace/ext/messaging.go
Comment thread ddtrace/tracer/option.go
Comment thread ddtrace/tracer/option.go
Comment thread ddtrace/tracer/spancontext.go Outdated
Comment thread ddtrace/tracer/spancontext.go Outdated
Comment thread ddtrace/tracer/spancontext.go Outdated
Comment thread ddtrace/tracer/spancontext.go Outdated
Comment thread ddtrace/tracer/option.go
Comment thread ddtrace/tracer/spancontext.go Outdated
Comment thread ddtrace/tracer/spancontext.go
Comment thread ddtrace/tracer/option.go Outdated
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
Copy Markdown
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?

Comment thread ddtrace/tracer/spancontext.go Outdated
if hn := tr.hostname(); hn != "" {
s.setMeta(keyTracerHostname, hn)
}
setPeerService(s, tr.config)

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.

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.

Comment thread ddtrace/tracer/spancontext_test.go Outdated
Comment thread ddtrace/tracer/spancontext_test.go Outdated
@rarguelloF
rarguelloF force-pushed the rarguelloF/add-peer-service branch from 13bb529 to dc44b3e Compare June 2, 2023 17:23
Comment thread ddtrace/tracer/spancontext.go Outdated
Comment thread ddtrace/tracer/option.go Outdated
Comment thread ddtrace/tracer/option.go
Comment thread ddtrace/tracer/spancontext.go Outdated
Comment thread ddtrace/tracer/spancontext.go
Comment thread ddtrace/tracer/spancontext_test.go Outdated
@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
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.

7 participants