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: dereference pointers to supported types in span.SetTag #2796

Merged
merged 6 commits into from
Aug 5, 2024

Conversation

darccio
Copy link
Member

@darccio darccio commented Jul 23, 2024

What does this PR do?

Adds support for pointer values on setting tags, dereferencing them iff it's a pointer to a supported value in span.SetTag.

Dereferencing more than one level of indirection is out of scope, as there is no way to do it without reflect and/or in an efficient way.

It also adds some of the existing benchmarks for SetTag to make sure the modification doesn't introduce any unnecessary allocation or overhead. They were also fixed as they had an unrelated allocation captured by the benchmark tooling.

Motivation

Protobuf generated code for nullable fields uses pointers. It's easy to forget to dereference the variable to pass the value to SetTag, leading to tags containing strings representing memory addresses instead of the desired value the pointer points to.

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!

@darccio darccio requested review from a team as code owners July 23, 2024 14:38
@pr-commenter
Copy link

pr-commenter bot commented Jul 23, 2024

Benchmarks

Benchmark execution time: 2024-08-05 09:34:08

Comparing candidate commit 8c808b6 in PR branch dario.castane/apmlp-87/handle-ptrs-settag with baseline commit 277ea00 in branch main.

Some scenarios are present only in baseline or only in candidate runs. If you didn't create or remove some scenarios in your branch, this maybe a sign of crashed benchmarks 💥💥💥
Check Gitlab CI job log to find if any benchmark has crashed.

Scenarios present only in candidate:

  • BenchmarkSetTagStringPtr-24

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

scenario:BenchmarkSetTagMetric-24

  • 🟩 allocated_mem [-4 bytes; -4 bytes] or [-100.000%; -100.000%]
  • 🟩 allocations [-1; -1] or [-100.000%; -100.000%]
  • 🟩 execution_time [-14.868ns; -12.372ns] or [-10.843%; -9.022%]

scenario:BenchmarkSetTagString-24

  • 🟩 allocated_mem [-4 bytes; -4 bytes] or [-100.000%; -100.000%]
  • 🟩 allocations [-1; -1] or [-100.000%; -100.000%]
  • 🟩 execution_time [-18.732ns; -17.088ns] or [-13.932%; -12.708%]

scenario:BenchmarkSetTagStringer-24

  • 🟩 allocated_mem [-4 bytes; -4 bytes] or [-100.000%; -100.000%]
  • 🟩 allocations [-1; -1] or [-100.000%; -100.000%]
  • 🟩 execution_time [-17.776ns; -14.624ns] or [-11.220%; -9.230%]

@darccio
Copy link
Member Author

darccio commented Jul 23, 2024

Some scenarios are present only in baseline or only in candidate runs. If you didn't create or remove some scenarios in your branch, this maybe a sign of crashed benchmarks 💥💥💥

The reported benchmark BenchmarkSetTagStringPtr-24 is new and only present in the candidate branch.

ddtrace/tracer/util_test.go Show resolved Hide resolved
Copy link
Contributor

@eliottness eliottness left a comment

Choose a reason for hiding this comment

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

Reviewing for dd-trace-go-guild (.gitlab-ci.yml)

ddtrace/tracer/util.go Outdated Show resolved Hide resolved
.gitlab-ci.yml Outdated Show resolved Hide resolved
@DataDog DataDog deleted a comment from github-actions bot Aug 5, 2024
@DataDog DataDog deleted a comment from github-actions bot Aug 5, 2024
@DataDog DataDog deleted a comment from github-actions bot Aug 5, 2024
@DataDog DataDog deleted a comment from github-actions bot Aug 5, 2024
@DataDog DataDog deleted a comment from github-actions bot Aug 5, 2024
@DataDog DataDog deleted a comment from github-actions bot Aug 5, 2024
@DataDog DataDog deleted a comment from github-actions bot Aug 5, 2024
@DataDog DataDog deleted a comment from github-actions bot Aug 5, 2024
@DataDog DataDog deleted a comment from github-actions bot Aug 5, 2024
@DataDog DataDog deleted a comment from github-actions bot Aug 5, 2024
@DataDog DataDog deleted a comment from github-actions bot Aug 5, 2024
@DataDog DataDog deleted a comment from github-actions bot Aug 5, 2024
@DataDog DataDog deleted a comment from github-actions bot Aug 5, 2024
@DataDog DataDog deleted a comment from github-actions bot Aug 5, 2024
@darccio darccio merged commit 794b629 into main Aug 5, 2024
164 checks passed
@darccio darccio deleted the dario.castane/apmlp-87/handle-ptrs-settag branch August 5, 2024 09:40
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.

3 participants