Skip to content

fix: problem getting the sampling priority#205

Merged
joeyzhao2018 merged 3 commits into
mainfrom
joey/fix-sampling
Aug 1, 2025
Merged

fix: problem getting the sampling priority#205
joeyzhao2018 merged 3 commits into
mainfrom
joey/fix-sampling

Conversation

@joeyzhao2018
Copy link
Copy Markdown
Contributor

@joeyzhao2018 joeyzhao2018 commented Jul 31, 2025

TICKET: https://datadoghq.atlassian.net/browse/APMSVLS-135

Background/Motivation

datadog-lambda-go uses dd-trace-go as a dependency. In the release we set dependency dd-trace-go version as 1.72.1 but customers can freely use 1.73.x or 1.74.x etc.
In dd-trace-go 1.74.x, it acts as a shim wrapper to use dd-trace-go v2. And the SpanContext is actually stored in the adapter.

datadog-lambda-go by default uses a feature called Universal Instrumentation. In short, at the beginning of a lambda invocation, it sends the event payload to the agent (extension) and let the agent create the root span. At the end of the invocation, it sends another request with the data about the span created using dd-trace-go back to the agent.

Among the data is the Sampling Priority, which is not accessible directly if the customer uses v1.74.x because it need to get the adapter first.

What does this PR do?

  • This PR adds a logic that if SamplingPriority() failed, try get the sampling priority from the adapter.
  • Add error logging for cases when we fail to get the Sampling Priority. Because this could impact billing directly.
  • Update dd-trace-go from 1.72.1 to 1.73.1 (the last v1 that doesn't use v2)
  • Update go to 1.24 from 1.23

Testing Guidelines

  • Added unittests
  • Tested with a real lambda using 1.74.3

Additional Notes

Types of changes

  • Bug fix
  • New feature
  • Breaking change
  • Misc (docs, refactoring, dependency upgrade, etc.)

Checklist

  • This PR's description is comprehensive
  • This PR contains breaking changes that are documented in the description
  • This PR introduces new APIs or parameters that are documented and unlikely to change in the foreseeable future
  • This PR impacts documentation, and it has been updated (or a ticket has been logged)
  • This PR's changes are covered by the automated tests
  • This PR collects user input/sensitive content into Datadog

@joeyzhao2018 joeyzhao2018 requested a review from a team as a code owner July 31, 2025 15:00
@joeyzhao2018 joeyzhao2018 changed the title fix the sampling issue fix: problem getting the sampling priority Jul 31, 2025
@joeyzhao2018 joeyzhao2018 merged commit e15a16c into main Aug 1, 2025
9 checks passed
@joeyzhao2018 joeyzhao2018 deleted the joey/fix-sampling branch August 1, 2025 23:54
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