Skip to content

refactor(ddtrace/{tracer,mocktracer}): remove SubmitChunk method fromTracer interface#3562

Merged
darccio merged 2 commits into
mainfrom
dario.castane/remove-submitchunk-tracer-ifc
May 28, 2025
Merged

refactor(ddtrace/{tracer,mocktracer}): remove SubmitChunk method fromTracer interface#3562
darccio merged 2 commits into
mainfrom
dario.castane/remove-submitchunk-tracer-ifc

Conversation

@darccio

@darccio darccio commented May 28, 2025

Copy link
Copy Markdown
Member

What does this PR do?

Motivation

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.
  • New code is free of linting errors. You can check this by running golangci-lint run locally.
  • 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 force-pushed the dario.castane/remove-submitchunk-tracer-ifc branch from e7ad507 to 906fda9 Compare May 28, 2025 15:16
@pr-commenter

pr-commenter Bot commented May 28, 2025

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2025-05-28 15:31:32

Comparing candidate commit b0399e9 in PR branch dario.castane/remove-submitchunk-tracer-ifc with baseline commit c05e36c in branch main.

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

Comment on lines +585 to +587
if mtr, ok := tr.(interface{ SubmitChunk(*Chunk) }); ok {
mtr.SubmitChunk(ch)
}

@darccio darccio May 28, 2025

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This could be better, but it does the work without causing a performance regression.

In v1 we didn't do that but we casted the value from internal.GetGlobalTracer to (*tracer), so I think we are on the same situation, just a level deeper.

To remove this we'll need to work on the internal design of spans' finish flow.

We also use this "pry bar interface" pattern for supporting the mocktracer when finishing spans in v2, and we cast to (*tracer) in multiple points in v1 and v2:

image

Praise the crowbar:

image

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Since we are on a timeline, it is okay to cut corners.

However, let's fix this in the longer-term.

To remove this we'll need to work on the internal design of spans' finish flow.

As you suggested here.

We also use this "pry bar interface" pattern for supporting the mocktracer when finishing spans in v2, and we cast to (*tracer) in multiple points in v1 and v2.

We should fix there patterns, again in the long run.

@darccio
darccio marked this pull request as ready for review May 28, 2025 15:40
@darccio
darccio requested a review from a team as a code owner May 28, 2025 15:40

@kakkoyun kakkoyun left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM.

Thanks for simplifying the interface further.

Comment on lines +585 to +587
if mtr, ok := tr.(interface{ SubmitChunk(*Chunk) }); ok {
mtr.SubmitChunk(ch)
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Since we are on a timeline, it is okay to cut corners.

However, let's fix this in the longer-term.

To remove this we'll need to work on the internal design of spans' finish flow.

As you suggested here.

We also use this "pry bar interface" pattern for supporting the mocktracer when finishing spans in v2, and we cast to (*tracer) in multiple points in v1 and v2.

We should fix there patterns, again in the long run.

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