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

contrib/slog: clone record before calling Add #2929

Merged
merged 2 commits into from
Oct 16, 2024
Merged

Conversation

felixge
Copy link
Member

@felixge felixge commented Oct 15, 2024

What does this PR do?

Fix a bug that could manifest itself when a slog Record is modified concurrently (A) with our handler.Handle implementation (B). If A completes before B, then B will overwrite the attribute added by A. This is caused by both copies of the record sharing the same underlaying slice array.

Add test case demonstrating the issue.

Fixes #2918

Motivation

#2918

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.

Unsure? Have a question? Request a review!

Fix a bug that could manifest itself when a slog Record is modified
concurrently (A) with our handler.Handle implementation (B). If A
completes before B, then it might overwrite an attribute added by A.

Add test case demonstrating the issue.

Fixes #2918
@felixge felixge requested review from a team as code owners October 15, 2024 11:16
@github-actions github-actions bot added the apm:ecosystem contrib/* related feature requests or bugs label Oct 15, 2024
@pr-commenter
Copy link

pr-commenter bot commented Oct 15, 2024

Benchmarks

Benchmark execution time: 2024-10-15 12:00:43

Comparing candidate commit 7362172 in PR branch gh-2918-slog-add-clone with baseline commit 93311db in branch main.

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

@felixge felixge enabled auto-merge (squash) October 16, 2024 12:28
@felixge felixge merged commit 51abc7b into main Oct 16, 2024
144 of 146 checks passed
@felixge felixge deleted the gh-2918-slog-add-clone branch October 16, 2024 12:34
MNThomson pushed a commit to agilebits/dd-trace-go that referenced this pull request Oct 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
apm:ecosystem contrib/* related feature requests or bugs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Should clone record before calling .Add on it for the Go "slog" integration
3 participants