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/log/slog: implement handler.WithAttrs #2839

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

shota3506
Copy link

What does this PR do?

implement contrib/log/slog.handler.WithAttrs

Motivation

resolve #2838

Note

In the issue, I mentioned that the handler is replaced by Logger.WithGroup call as well. But I'm not sure if it is fine to implement handler.WithGroup in this case.

If you implement logger.WithGruop like

func (h *handler) WithGroup(name string) slog.Handler {
	return WrapHandler(h.Handler.WithGroup(string))
}

the logger will produce the log with grouped dd attributes.

logger := slog.New(NewJSONHandler(b, nil))
logger := logger.WithGruop("group")
{"time":"2024-08-31T13:14:16.583178+09:00","level":"INFO","msg":"this is an info log with tracing information","group":{"dd.trace_id":1371324856057376362,"dd.span_id":1371324856057376362}}

But I think it is not what datadog expected.

I would like some advice on this.

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!

Copy link

This PR is stale because it has been open 20 days with no activity. Remove stale label or comment or this will be closed in 10 days.

@github-actions github-actions bot added the stale Stuck for more than 1 month label Sep 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale Stuck for more than 1 month
Projects
None yet
1 participant