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

tracer: Check for nil interface types in span.Finish(WithError()) #2036

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

ajgajg1134
Copy link
Contributor

What does this PR do?

Fixes a bug where if a user created a nil type of their own implementation of the error interface the nil check we do is not sufficient to ensure we do not panic later. (For context checkout this old thread which includes a playground link)

Motivation

Closes #2029

Describe how to test/QA your changes

Covered with Unit test

Reviewer's Checklist

  • Changed code has unit tests for its functionality.
  • If this interacts with the agent in a new way, a system test has been added.

@pr-commenter
Copy link

pr-commenter bot commented Jun 12, 2023

Benchmarks

Benchmark execution time: 2024-01-10 19:56:21

Comparing candidate commit f5901b4 in PR branch andrew.glaude/nilSpanError with baseline commit c07107d in branch main.

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

scenario:BenchmarkTracerAddSpans-24

  • 🟥 allocated_mem [+2.380KB; +2.381KB] or [+107.430%; +107.473%]
  • 🟥 allocations [+16; +16] or [+64.000%; +64.000%]
  • 🟥 execution_time [+8.718µs; +8.791µs] or [+211.952%; +213.710%]

@ajgajg1134 ajgajg1134 marked this pull request as ready for review June 12, 2023 19:06
@ajgajg1134 ajgajg1134 requested a review from a team June 12, 2023 19:06
katiehockman
katiehockman previously approved these changes Jun 12, 2023
@katiehockman
Copy link
Contributor

@ajgajg1134 did you ultimately decide to abandon this PR, or do you still want review in it's current state? I remember there being discussion, but don't recall our final decision on that.

ddtrace/tracer/option.go Show resolved Hide resolved
ddtrace/tracer/option.go Outdated Show resolved Hide resolved
@ajgajg1134
Copy link
Contributor Author

@ajgajg1134 did you ultimately decide to abandon this PR, or do you still want review in it's current state? I remember there being discussion, but don't recall our final decision on that.

I believe we decided to move forward with our best effort approach here, but I had some unresolved (and unposted) comments in my review here from our discussion. I've just posted and addressed them so I would say this is ready for final review.

@ajgajg1134
Copy link
Contributor Author

In looking at this again I realized our existing benchmarks didn't actually really cover this WithError case. Modifying the benchmark to create only non-nil error spans gives the following:

benchstat original.out withReflect.out
goos: darwin
goarch: arm64
pkg: gopkg.in/DataDog/dd-trace-go.v1/ddtrace/tracer
                  │ original.out │          withReflect.out          │
                  │    sec/op    │   sec/op     vs base              │
TracerAddSpans-10    5.013µ ± 1%   5.047µ ± 0%  +0.68% (p=0.035 n=6)

This seems like a reasonable change to me? Less than 1% and it's only incurred when the error is non-nil

@katiehockman
Copy link
Contributor

I realized our existing benchmarks didn't actually really cover this WithError case.

@ajgajg1134 do you want to add those benchmarks here, so we don't lose them? Agreed that 1% isn't a big enough concern to worry about here, so should be good to merge it.

@ajgajg1134 ajgajg1134 requested a review from a team as a code owner January 10, 2024 19:38
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.

proposal: ddtrace/tracer: check for nil pointer in interface.
3 participants