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: add log/slog instrumentation #2765

Merged
merged 2 commits into from
Jul 1, 2024

Conversation

rarguelloF
Copy link
Contributor

@rarguelloF rarguelloF commented Jul 1, 2024

What does this PR do?

Adds a new instrumentation for https://pkg.go.dev/log/slog
This instrumentation provides log / trace correlation for log/slog users: https://docs.datadoghq.com/tracing/other_telemetry/connect_logs_and_traces/

Motivation

Solves #2077

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!

@github-actions github-actions bot added the apm:ecosystem contrib/* related feature requests or bugs label Jul 1, 2024
@rarguelloF rarguelloF changed the title contrib: add log/slog integration contrib: add log/slog instrumentation Jul 1, 2024
@rarguelloF rarguelloF marked this pull request as ready for review July 1, 2024 11:59
@rarguelloF rarguelloF requested review from a team as code owners July 1, 2024 11:59
@pr-commenter
Copy link

pr-commenter bot commented Jul 1, 2024

Benchmarks

Benchmark execution time: 2024-07-01 12:02:12

Comparing candidate commit 21aa203 in PR branch rarguelloF/AIDM-126/add-slog-integration with baseline commit bdc072c in branch main.

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

Copy link
Member

@darccio darccio left a comment

Choose a reason for hiding this comment

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

LGTM

@rarguelloF rarguelloF merged commit 974aea6 into main Jul 1, 2024
166 checks passed
@rarguelloF rarguelloF deleted the rarguelloF/AIDM-126/add-slog-integration branch July 1, 2024 14:27

// WrapHandler enhances the given logger handler attaching tracing information to logs.
func WrapHandler(h slog.Handler) slog.Handler {
return &handler{h}

Choose a reason for hiding this comment

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

I think this may be an unnecessary heap allocation

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.

3 participants