Skip to content

feat(ddtrace): implement version detection for dd-trace-go v1 non-transitional #3381

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

Merged
merged 2 commits into from
Apr 10, 2025

Conversation

darccio
Copy link
Member

@darccio darccio commented Apr 4, 2025

What does this PR do?

Adds v1 non-transitional versions of dd-trace-go present in the compiled binary.

It also sets the v1 transitional version as the tag version so logging for services instrumented with v1.74.0 and higher show a v1 version, following the principle of least surprise.

Motivation

v1.73.0 and below are not compatible with v2. They can't coexist.

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.
  • For internal contributors, a matching PR should be created to the v2-dev branch and reviewed by @DataDog/apm-go.

Unsure? Have a question? Request a review!

@darccio darccio requested review from a team as code owners April 4, 2025 15:26
@datadog-datadog-prod-us1
Copy link

datadog-datadog-prod-us1 bot commented Apr 4, 2025

Datadog Report

Branch report: dario.castane/v1-mix-warning
Commit report: e0e5caf
Test service: dd-trace-go

✅ 0 Failed, 4475 Passed, 64 Skipped, 3m 40.55s Total Time

minor, _ := strconv.Atoi(captures["mi"])
patch, _ := strconv.Atoi(captures["pa"])
rc, _ := strconv.Atoi(captures["rc"])
return major, minor, patch, rc
Copy link
Member

Choose a reason for hiding this comment

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

Is this an unrelated refactoring? Or was the plan to use parseVersion in v1.go? If yes, why didn't this pan out?

Copy link
Member Author

@darccio darccio Apr 6, 2025

Choose a reason for hiding this comment

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

@felixge I pushed and left behind a change I wanted to introduce to replace the Tag with the v1 transitional version, so logs show the version that users can see in their go.mod as direct dependency (to avoid confusions).

You can see the change at 31564a3.

I'm also wondering if it's the right time to replace this ad hoc code with semver instead. WDYT?

Update: I woke up with an idea about how to refactor it so we check debuginfo once, and also warn on tracer's start: 59b5ceb

Copy link
Member Author

Choose a reason for hiding this comment

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

@felixge I rebased this against main. Please, can you review it again? Thanks!

Copy link
Member

Choose a reason for hiding this comment

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

+1 for using semver

Copy link
Member Author

Choose a reason for hiding this comment

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

@kakkoyun PR is going to have lots of changed go.mod files due to adding a new dependency 😁 But worth it, it looks cleaner.

@pr-commenter
Copy link

pr-commenter bot commented Apr 4, 2025

Benchmarks

Benchmark execution time: 2025-04-10 08:47:54

Comparing candidate commit ef705e9 in PR branch dario.castane/v1-mix-warning with baseline commit 3d0fb01 in branch main.

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

@darccio darccio changed the base branch from v2-dev to main April 7, 2025 09:54
@darccio darccio requested review from a team as code owners April 7, 2025 09:54
@darccio darccio requested a review from juan-fernandez April 7, 2025 09:54
@darccio darccio changed the base branch from main to v2-dev April 7, 2025 09:55
@darccio darccio force-pushed the dario.castane/v1-mix-warning branch from 5b36869 to 63b79ab Compare April 8, 2025 13:08
@darccio darccio changed the base branch from v2-dev to main April 8, 2025 13:09
minor, _ := strconv.Atoi(captures["mi"])
patch, _ := strconv.Atoi(captures["pa"])
rc, _ := strconv.Atoi(captures["rc"])
return major, minor, patch, rc
Copy link
Member

Choose a reason for hiding this comment

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

+1 for using semver


func parseVersion(version string) (int, int, int, int) {
var (
v = semver.MustParse(version)
Copy link
Member Author

Choose a reason for hiding this comment

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

I decided to go with MustParse because this shouldn't fail ever. I consider this a canary.

Copy link
Contributor

@rarguelloF rarguelloF left a comment

Choose a reason for hiding this comment

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

lgtm, left a refactor suggestion

Copy link
Member

@tonyredondo tonyredondo left a comment

Choose a reason for hiding this comment

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

LGTM

@darccio
Copy link
Member Author

darccio commented Apr 9, 2025

Nice:

image

The go.mod:

module go-http-puppy

go 1.23.0

require (
	github.com/DataDog/dd-trace-go/v2 v2.0.0-20250409103927-ac517a28737c
	gopkg.in/DataDog/dd-trace-go.v1 v1.72.2
)

require (
	// [...] snip
)

@darccio darccio force-pushed the dario.castane/v1-mix-warning branch 5 times, most recently from a1c8934 to 757ae2d Compare April 10, 2025 08:14
@darccio darccio force-pushed the dario.castane/v1-mix-warning branch from 757ae2d to ef705e9 Compare April 10, 2025 08:19
@darccio darccio enabled auto-merge (squash) April 10, 2025 16:36
@darccio darccio merged commit e137aa6 into main Apr 10, 2025
178 of 180 checks passed
@darccio darccio deleted the dario.castane/v1-mix-warning branch April 10, 2025 16:53
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.

5 participants