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 tracing for incoming requests #114

Merged
merged 16 commits into from
Jan 11, 2024
Merged

Add tracing for incoming requests #114

merged 16 commits into from
Jan 11, 2024

Conversation

charleskorn
Copy link
Contributor

Continuation of #101, which was merged and then reverted due to some feedback received after merging.

Comment on lines 37 to 41
oldObj, oldGVK, err := codecs.UniversalDeserializer().Decode(ar.Request.OldObject.Raw, nil, nil)
if err != nil {
return allowErr(logger, "can't decode old object, allowing the change", err)
}
logger = log.With(logger, "request_gvk", oldGVK)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@56quarters commented in #101:

I appreciate trying to minimize changes but it seems weird to use both logger and spanLogger. Can we use just the spanLogger and not keep logger around in these methods?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I kept both to preserve the behaviour of tagging log lines with the attributes added along the way such as request_gvk. The trouble comes from log.With returning a log.Logger, rather than a spanlogger.SpanLogger - so as soon as we call log.With, we lose the ability to set span tags.

One option would be to add another method to SpanLogger that allows us to add a tag and wrap the underlying logger with another attribute, which would tidy this up - what do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

That sounds reasonable but let's not block this PR on it. Thanks 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

grafana/dskit#467 will add the method needed for this to dskit.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

...and #115 will use that method to tidy this up

@charleskorn charleskorn marked this pull request as ready for review January 11, 2024 03:50
@charleskorn charleskorn requested a review from a team as a code owner January 11, 2024 03:50
Comment on lines 37 to 41
oldObj, oldGVK, err := codecs.UniversalDeserializer().Decode(ar.Request.OldObject.Raw, nil, nil)
if err != nil {
return allowErr(logger, "can't decode old object, allowing the change", err)
}
logger = log.With(logger, "request_gvk", oldGVK)
Copy link
Contributor

Choose a reason for hiding this comment

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

That sounds reasonable but let's not block this PR on it. Thanks 👍

@charleskorn charleskorn merged commit eeaf904 into main Jan 11, 2024
6 checks passed
@charleskorn charleskorn deleted the charleskorn/tracing branch January 11, 2024 23:31
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.

None yet

3 participants