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

Add structured logging support to promhttp #1601

Closed
wants to merge 1 commit into from

Conversation

SuperQ
Copy link
Member

@SuperQ SuperQ commented Aug 30, 2024

In order to better support the standard library log/slog add a new interface to the promhttp HandlerOpts.

Copy link

@tjhop tjhop left a comment

Choose a reason for hiding this comment

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

\o/

@SuperQ SuperQ requested a review from ArthurSens August 30, 2024 14:31
@SuperQ SuperQ force-pushed the superq/structured_logger branch from e42eb81 to ce14c97 Compare August 30, 2024 14:42
@SuperQ
Copy link
Member Author

SuperQ commented Aug 30, 2024

We might want to split out the Go version change into a separate PR.

@SuperQ SuperQ force-pushed the superq/structured_logger branch from ce14c97 to 201b770 Compare August 31, 2024 21:15
@SuperQ SuperQ marked this pull request as ready for review August 31, 2024 21:15
@SuperQ
Copy link
Member Author

SuperQ commented Aug 31, 2024

Ok, yaks shaven, this is ready to go.

@SuperQ
Copy link
Member Author

SuperQ commented Aug 31, 2024

Seems like dagger is a bit of technical debt for keeping Go versions up to date as well.

@SuperQ SuperQ force-pushed the superq/structured_logger branch from dc79689 to 51c188e Compare August 31, 2024 21:40
@SuperQ SuperQ mentioned this pull request Sep 1, 2024
In order to better support the standard library `log/slog` add a
new interface to the `promhttp` `HandlerOpts`.

Signed-off-by: SuperQ <superq@gmail.com>
@SuperQ SuperQ force-pushed the superq/structured_logger branch 2 times, most recently from 3d57041 to c652332 Compare September 3, 2024 20:23
@ArthurSens
Copy link
Member

Hmmm, feels strange that we have 2 loggers in the struct now. I'm assuming this is needed somewhere in a different package/repository, could you clarify how you're planning to use this?

@tjhop
Copy link

tjhop commented Sep 4, 2024

Hmmm, feels strange that we have 2 loggers in the struct now. I'm assuming this is needed somewhere in a different package/repository, could you clarify how you're planning to use this?

@SuperQ we're only ever logging at error level here -- maybe we just lean on slog's built in stdlog adapter and avoid the change here altogether? Something like this:

	// make logger with promslog like normal
	slogger := promslog.New(&promslog.Config{})
	// make stdlog adapter from slogger
	logger := slog.NewLogLogger(slogger.Handler(), slog.LevelError)

Bonus points -- log output is still structured

@SuperQ
Copy link
Member Author

SuperQ commented Sep 4, 2024

Yea, I suppose using a stdlib adapter would be fine.

@SuperQ SuperQ closed this Sep 4, 2024
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.

3 participants