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

Remove the TagLoggable tooling #225

Merged
merged 1 commit into from
Apr 12, 2024
Merged

Remove the TagLoggable tooling #225

merged 1 commit into from
Apr 12, 2024

Conversation

pior
Copy link
Member

@pior pior commented Apr 12, 2024

Remove the TagLoggable methods: statsd.WithTagLogFields, statsd.WithTagLoggable, statsd.WatchingTagLoggable.

This API is confusing and the caller can do the same thing by calling both statsd and logger.

WithTagLoggable is even harmful since it will happily add log fields as metric tags.

@pior pior requested review from sdufel and yousifh April 12, 2024 16:43
// WithTagLoggable combines WithTaggable and logger.WithLoggable
// If the Loggable is a Taggable already (implements StatsTags), it will be used directly.
// If StatsTags doesn't exist, LogFields() will be used instead.
func WithTagLoggable(ctx context.Context, l logger.Loggable) context.Context {
Copy link
Member

@yousifh yousifh Apr 12, 2024

Choose a reason for hiding this comment

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

I wonder if it makes sense to rewrite the implementation so it adds the Loggable. Then checks if its Taggable and add it. And remove the tagLoggable concept.

Just as a shorthand for doing

ctx = statsd.WithTaggable(ctx, shop)
ctx = logger.WithLoggable(ctx, shop)

Choose a reason for hiding this comment

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

But I imagine we want to avoid doing this? Make it too easy to add whatever field to both and not think about it.

Choose a reason for hiding this comment

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

unless what you mean is that fields implements loggable and taggle?

Copy link
Member Author

Choose a reason for hiding this comment

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

As a user of this API, I very much prefer to write those two lines than wonder what WithTagLoggable does.

I agree that what you suggest is better than the current API, but I still think that KISS is better.

Copy link
Member

Choose a reason for hiding this comment

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

@hurracrane I meant that the API will first do ctx = logger.WithLoggable(ctx, shop) Then it will try to cast it as Taggable and add it if so.

Basically avoid the fallback of directly adding LogFields as tags.

But I'm ok with us just removing the API

@pior pior merged commit 4be1d82 into main Apr 12, 2024
7 checks passed
@pior pior deleted the remove-tagloggable branch April 12, 2024 17:32
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.

4 participants