-
Notifications
You must be signed in to change notification settings - Fork 1.2k
[reflect] sdk/log/xlog: Add FilterProcessor and EnabledParameters #6286
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
Conversation
Co-authored-by: Sam Xie <[email protected]>
Co-authored-by: Sam Xie <[email protected]>
|
I think that we can make it working if we use |
sdk/log/go.mod
Outdated
| go.opentelemetry.io/otel v1.34.0 | ||
| go.opentelemetry.io/otel/log v0.10.0 | ||
| go.opentelemetry.io/otel/sdk v1.34.0 | ||
| go.opentelemetry.io/otel/sdk/log/xlog v0.0.0-00010101000000-000000000000 |
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.
What is interesting if the dependency is used only used in tests then it does not come up as an indirect dependency for modules using go.opentelemetry.io/otel/sdk/log 🎉
It looks like the Go module graph pruning has been improved at some point.
I think that it means that we could get rid of test modules 😉
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.
This is a bit strange. I've just tried that for otelhttp, and the SDK does come as an indirect dependency.
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.
Then I think we cannot rely on the Go modules pruning and I will get rid of this dependency.
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.
Adressed 08ac146
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.
This is a bit strange. I've just tried that for otelhttp, and the SDK does come as an indirect dependency.
@dmathieu , I tried it once more and actually it does NOT come as an indirect dependency.
See: open-telemetry/opentelemetry-go-contrib#6763
I had to run make go-mod-tidy twice. Probably if we used crosslink tidylist then it would not be necessary
We can could consider revert 08ac146. But I am fine with the current approach as well. It looks cleaner. I propose to keep the current way.
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.
Ah, it looks like the difference is that you used a different package name. So that'd be the trick.
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.
Ah, it looks like the difference is that you used a different package name. So that'd be the trick.
I do not follow. The SDK is used in tests of both of otelhttp and otelhttp_test packages.
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.
Yes, but when I tried it, I kept the otelhttp package name for the tests. I think that's why the dependency still showed up.
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.
Some tests still use it. Can you double check it? Make sure to run make go-mod-tidy more than once 😉
| - go.opentelemetry.io/otel/schema | ||
| excluded-modules: | ||
| - go.opentelemetry.io/otel/internal/tools | ||
| - go.opentelemetry.io/otel/sdk/log/xlog |
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 think that relying on git hashes may be very annoying for the users.
It would be hard for them to keep sdk/log and sdk/log/xlog in sync.
- We are making commits very frequently so they may even not bump it
- It would be hard to figure it out which version of
xlogis compatible withlogwith we do any breaking change.
On the other side, we can wait for making a release until people actually complain.
Thoughts?
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.
For comparison, the collector keeps x packages within the normal release process.
I have doubts about the idea, but if we want to allow folks to be able to get very fresh code, we could setup auto nightly/weekly releases for the x packages. Then, they wouldn't rely on commits, but would remain on the latest.
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.
Would it be possible to add a linter to ensure no stable module uses an x one?
Co-authored-by: Damien Mathieu <[email protected]>
I created #6298 to avoid scope creeping. |
|
I think that the performance overhead is huge (probably not acceptable, it would only make sense for users to call in case of enormous log records) and that we should reconsider #6271. |
|
SIG meeting notes: |
Per #6271 (comment) > We agreed that we can move `FilterProcessor` directly to `sdk/log` as Logs SDK does not look to be stabilized soon. - Add the possibility to filter based on the resource and scope which is available for the SDK. The scope information is the most important as it gives the possibility to e.g. filter out logs emitted for a given logger. Thus e.g. open-telemetry/opentelemetry-specification#4364 is not necessary. See open-telemetry/opentelemetry-specification#4290 (comment) for more context. - It is going be an example for open-telemetry/opentelemetry-specification#4363 There is a little overhead (IMO totally acceptable) because of data transformation. Most importantly, there is no new heap allocation. ``` goos: linux goarch: amd64 pkg: go.opentelemetry.io/otel/sdk/log cpu: 13th Gen Intel(R) Core(TM) i7-13800H │ old.txt │ new.txt │ │ sec/op │ sec/op vs base │ LoggerEnabled-20 4.589n ± 1% 319.750n ± 16% +6867.75% (p=0.000 n=10) │ old.txt │ new.txt │ │ B/op │ B/op vs base │ LoggerEnabled-20 0.000Ki ± 0% 1.093Ki ± 13% ? (p=0.000 n=10) │ old.txt │ new.txt │ │ allocs/op │ allocs/op vs base │ LoggerEnabled-20 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=10) ¹ ¹ all samples are equal ``` `Logger.Enabled` is still more efficient than `Logger.Emit` (benchmarks from #6315). ``` goos: linux goarch: amd64 pkg: go.opentelemetry.io/otel/sdk/log cpu: 13th Gen Intel(R) Core(TM) i7-13800H BenchmarkLoggerEmit/5_attributes-20 559934 2391 ns/op 39088 B/op 1 allocs/op BenchmarkLoggerEmit/10_attributes-20 1000000 5910 ns/op 49483 B/op 5 allocs/op BenchmarkLoggerEnabled-20 1605697 968.7 ns/op 1272 B/op 0 allocs/op PASS ok go.opentelemetry.io/otel/sdk/log 10.789s ``` Prior art: - #6271 - #6286 I also created for tracking purposes: - https://github.com/open-telemetry/opentelemetry-go/issues/6328
Per #6271 (comment)
This introduces a new
go.opentelemetry.io/otel/sdk/log/xlogmodule.I created it because of two reasons:
go.opentelemetry.io/otel/sdk/logmodule does not expose these experimental feature in its exported API; it is only available in docs and example test. The user would have to explicitly opt-in by using thego.opentelemetry.io/otel/sdk/log/xlogmodule which will always havev0.x.yversions. Hopefully at some point of time the features are added togo.opentelemetry.io/otel/sdk/log, deprecated ingo.opentelemetry.io/otel/sdk/log/xlogand afterwards removed fromgo.opentelemetry.io/otel/sdk/log/xlog. I think that for at one release we would need to support both the deprecatedgo.opentelemetry.io/otel/sdk/xlog.FilterProcessorand newgo.opentelemetry.io/otel/sdk/log.FilterProcessorto facilitate the migration process. The module name is inspired byxerrors.xlogis undersdk/logso that it could have access to packages undersdk/log/internalif necessary.The SDK supports
xlogusingreflect(duck typing) and thesdk/logproduction code does not depend onxlogso users should never experience build failures because of breaking changes inxlog.EDIT: The performance difference is huge because of using reflect. It makes the feature even almost unusable as in most cases calling Enabled (when all Processors are FilterProcessors) would be a lot more expensive than creating a heavy log record. But maybe it is a cost that we need to accept when providing experimental feature with a new types? The reflect overhead would be removed if the types would be stabilized and moved to
go.opentelemetry.io/otel/sdk/log.Maybe I should just use this PR as a prototype for sake of open-telemetry/opentelemetry-specification#4363. Then we could add the
FilterProcessorstraight to thego.opentelemetry.io/otel/sdk/log. However, then I have no idea how long we would need to wait for stability of Logs SDK.The other alternative is to go with #6271 to achieve performance for the cost of coupling the
sdk/logtosdk/log/xlog(similarly to what Collector does). I think the performance overhead is less acceptable than the potential build failures that users can run into. Trade-offs...