Skip to content

Conversation

@buztard
Copy link
Contributor

@buztard buztard commented May 12, 2025

Use a custom context key type to prevent key collisions.

See go blog for details

Use a custom context key type to prevent key collisions.
Comment on lines +24 to +29
type contextKey int8

const (
tracerName = "github.com/exaring/otelpgx"
meterName = "github.com/exaring/otelpgx"
startTimeCtxKey = "otelpgxStartTime"
startTimeCtxKey = contextKey(0)
Copy link
Member

Choose a reason for hiding this comment

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

Thanks for the suggestion! That makes sense!
However: since we're touching this, it would probably make sense to replace it with a struct{}, so that it uses no memory?

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.

2 participants