Skip to content

Conversation

joeyzhao2018
Copy link
Contributor

@joeyzhao2018 joeyzhao2018 commented Aug 1, 2025

What does this PR do?

  • This PR will update this repo to use dd-trace-go v2 instead of v1
  • Make the Client-side trace stats computation default off unless DD_TRACE_STATS_COMPUTATION_ENABLED explicitly set.

Motivation

#204

Implementation Details

  • "gopkg.in/DataDog/dd-trace-go.v1/ddtrace/tracer" => "github.com/DataDog/dd-trace-go/v2/ddtrace/tracer"
  • ddtrace.Span => *tracer.Span
  • Previously an interface now a struct
  • spanContext.TraceID() returns a string now. Previously uint64
  • spanContext.SamplingPriority() directly available. Previously not available in Spancontext interface
  • functionExecutionSpan.Context() still works the same
  • type FinishConfig struct remains the same. ddtrace.FinishConfig => tracer.FinishConfig
  • Though tracer.ChildOf(psc) is deprecated, it's still used here because the span is not available here for us to use Span.StartChild. In "Serverless Universal Instrumentation", that span is created in the agent instead of the tracer.

Testing Guidelines

  • Updated the unittests
  • Updated the integration tests
  • Smoke-tested in a real lambda.
    • Tested both case for using and not using universal instrumentation for a hello world lambda
    • Tested the case where the upstream tracecontext exists. (Note: it seems that there's an existing issue with the upstream lambda's trace. Need to confirm before merging.)

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 August 1, 2025 17:10
@joeyzhao2018 joeyzhao2018 changed the title adapting to dd-trace-go v2 feat: use dd-trace-go v2 Aug 1, 2025
@happynancee
Copy link
Contributor

dd-trace-go v2.1.0 enables client-side stats computation by default. Can we turn it off by default?

@joeyzhao2018
Copy link
Contributor Author

joeyzhao2018 commented Aug 1, 2025

dd-trace-go v2.1.0 enables client-side stats computation by default. Can we turn it off by default?

Updated accordingly.

@joeyzhao2018 joeyzhao2018 reopened this Aug 1, 2025
@happynancee
Copy link
Contributor

@joeyzhao2018 i think we also need to disable telemetry by default too DataDog/dd-trace-go#3808

@magnetikonline
Copy link

That would be fantastic @happynancee if we could also land that change 👍

i think we also need to disable telemetry by default too DataDog/dd-trace-go#3808

@joeyzhao2018
Copy link
Contributor Author

That would be fantastic @happynancee if we could also land that change 👍

i think we also need to disable telemetry by default too DataDog/dd-trace-go#3808

I explicitly set DD_INSTRUMENTATION_TELEMETRY_ENABLED to false in the tracer initialization code block.

@magnetikonline
Copy link

I explicitly set DD_INSTRUMENTATION_TELEMETRY_ENABLED to false in the tracer initialization code block.

Thanks @joeyzhao2018 - can see the change in 4d70949. 👍

} else {
logger.Error(fmt.Errorf("could not get sampling priority from getSamplingPriority()"))
}
logger.Error(fmt.Errorf("could not get sampling priority from spanContext.SamplingPriority()"))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

spanContext.SamplingPriority is directly available in dd-trace-go v2. No longer need the handling for the adapter case

Copy link
Contributor

@purple4reina purple4reina left a comment

Choose a reason for hiding this comment

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

This all looks great!

One question. For a customer who is currently using the v1 tracer in their lambda code, how will upgrading to this new version affect them? Will their spans all of a sudden be orphaned? Will their code even compile?

This is an important question for go because our customers will rely heavily on adding their own custom instrumentation to their functions.

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.

4 participants