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 context and info to logging interface #237

Merged
merged 5 commits into from
Jan 22, 2024

Conversation

jaronoff97
Copy link
Contributor

Allow the logging interface to propagate context where possible. This will let logging sinks contain richer information about potential opamp IO errors.

Copy link

codecov bot commented Jan 10, 2024

Codecov Report

Attention: 34 lines in your changes are missing coverage. Please review.

Comparison is base (fcfa095) 72.50% compared to head (5211c1e) 72.60%.
Report is 3 commits behind head on main.

Files Patch % Lines
server/serverimpl.go 8.33% 11 Missing ⚠️
client/internal/packagessyncer.go 54.54% 9 Missing and 1 partial ⚠️
client/internal/httpsender.go 40.00% 6 Missing ⚠️
client/internal/receivedprocessor.go 61.53% 5 Missing ⚠️
client/wsclient.go 66.66% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #237      +/-   ##
==========================================
+ Coverage   72.50%   72.60%   +0.09%     
==========================================
  Files          25       25              
  Lines        2022     2022              
==========================================
+ Hits         1466     1468       +2     
+ Misses        446      445       -1     
+ Partials      110      109       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jaronoff97
Copy link
Contributor Author

Before i continue with this... @andykellr @evan-bradley @tigrannajaryan what do you all think of this approach? Propagating the context would make it easier for consumers to understand the potential problems that the impls run in to, but i'm not sure how i feel about the interface. Let me know your thoughts. Thank you.

@tigrannajaryan
Copy link
Member

I have a hard time reviewing the code due to all the junk codecov added. I am going to disable it for now.

@tigrannajaryan
Copy link
Member

The idea to pass the context to logging functions sounds good to me. I am not sure we need a separate set of functions for that. Perhaps just add context parameter to existing functions?

@jaronoff97
Copy link
Contributor Author

@tigrannajaryan sounds good! I'll update to do that.

@mwear
Copy link
Member

mwear commented Jan 11, 2024

One benefit to the current approach is that the interface matches the new Go structured logger, slog. Rather than adding context to the existing functions, it might make more sense to keep the context versions, and remove (or deprecate) the non-context versions. That way you can use any logger that is slog compatible.

@jaronoff97
Copy link
Contributor Author

jaronoff97 commented Jan 11, 2024

yeah that was the intended purpose... I see benefits for both approaches... i'll follow up in slack.

@tigrannajaryan
Copy link
Member

The Logger interface here is not a general-purpose logging API. It is on purpose minimalistic and designed to support only what is needed by opamp implementation and nothing else. If we want to pass the context I am happy to make it a required parameter, I don't see the need to give a choice (side note: I argued that slog also makes it a required parameter, but wasn't able to convince the author).

I prefer to keep Logger interface as small as possible and bridge to any other logging API as needed. Coding a bridge from Logger to slog is so easy that I don't see the need to make the interface identical.

We also do not have stability promises in this repo yet, so I am not too worried about making a breaking change that is very easy to adopt. I don't think we need a deprecations process for this.

@jaronoff97
Copy link
Contributor Author

done! I will also work on the follow up described here which will make these even more valuable.

@jaronoff97 jaronoff97 marked this pull request as ready for review January 19, 2024 16:47
@jaronoff97 jaronoff97 requested a review from a team January 19, 2024 16:47
Copy link
Member

@tigrannajaryan tigrannajaryan left a comment

Choose a reason for hiding this comment

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

Mostly LGTM, except I think we don't need the Infof() for now. Can be added later when needed.

client/types/logger.go Outdated Show resolved Hide resolved
@jaronoff97
Copy link
Contributor Author

the codecov is failing for probably obvious reasons – testing error logs isn't really done right now

@tigrannajaryan
Copy link
Member

This is a breaking change in the API, allowed because the API is not declared stable yet.

@tigrannajaryan tigrannajaryan merged commit c8cc40b into open-telemetry:main Jan 22, 2024
5 of 6 checks passed
@jaronoff97 jaronoff97 deleted the logger-with-context branch January 22, 2024 17:30
tigrannajaryan pushed a commit that referenced this pull request Jan 26, 2024
This is a follow up to #237 and #247, adding context propagation for client methods. 

**This involves a breaking change for the client interfaces**
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