-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Begin prototyping Log API/SDK #3606
Begin prototyping Log API/SDK #3606
Conversation
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #3606 +/- ##
=======================================
- Coverage 78.9% 76.7% -2.3%
=======================================
Files 170 183 +13
Lines 12460 13426 +966
=======================================
+ Hits 9834 10298 +464
- Misses 2417 2899 +482
- Partials 209 229 +20
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not familiar enough with the logging specification to say if this is compliant, but what you have here seems mostly in line with this projects coding standards.
The versioning would be handled by making the log
and sdk/log
packages their own modules so they can be tracked with their own pre-1.0 version.
@MrAlias thanks for reviewing. How do you want to move forward? Do you want me to cleanup this large PR or break it down to smaller ones? I can probably split into 4 PRs:
|
Yeah, breaking down into some smaller PRs would be ideal. Especially when we consider the tests that will be needed. I think the SDK could be broken down a bit more given this is where a lot of testing will be added. Maybe:
We usually track this kind of project with a GitHub project. I think that makes sense here to do that as well. I would also add an issue to the project to include an OTLP exporter as that is the lingua franca of OTel. |
I think the project is a good idea to help scope the work the SIG will need to do to support this. We should then better understand how to prioritize and stage it. |
Thanks for reviewing. I think we have preliminary understanding of the general package structure we can aim for, but there is uncertainty around context support in slog. I am going to close this draft for now until there is more clarity in slog. |
Now that |
|
||
// Log via slog API. Note this will correctly output Span Context (traceid,spanid) in the final output | ||
// if Otel slog Handler is used. | ||
slog.InfoCtx(ctx, "Otel logs via slog and with context!", "source", "slog") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MrAlias See how this correctly does Otel context-aware logging although it is totally unaware of what Otel is!
Should creating connectors, like slog, logrus, logr, etc., be part of the scope of this? |
Yes, likely. I will close this PR for now since it was just a draft to see what the implementation can look like, but never intended to be something we can merge. |
I quickly (~1 hour) looked at the prototype and it looks nice. I think that I am also a little worried about the performance penalty (allocation) caused by having |
@pellared thanks for looking. I mainly mimicked what |
I am totally aware of it, but in some codebases the logging is a lot more "invasive" than metrics and tracing. From https://youtu.be/tC4Jt3i62ns?si=asGFI7Ni-c7sLPDf&t=168:
Thus my proposal. It is more about |
@open-telemetry/go-maintainers This begins implementation of Log API and SDK as defined in the spec https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/logs/README.md, primarily to assess whether the spec is implementable in Go. If we like the code we can keep it and continue working on it to have a complete implementation.
make test
passes successfully. Running namedtracer example will now output logs in addition to spans. Logs will correctly reference the trace and span in the context of which they are emitted.If we are happy with this approach I will tidy up the PR and will mark it as ready for review. There is no need for detailed line-by-line review yet, please just provide a high-level feedback about the approach, structure of packages, etc.
The next thing I would like to confirm is that this API/SDK is suitable for implementing a handler for https://pkg.go.dev/golang.org/x/exp/slog (in a separate PR, this is already too large).
I can also break this down into smaller PRs if you prefer, but I wanted to show the whole picture for now.
Questions: