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

Implement the slog Handler functionality #5314

Merged
merged 11 commits into from
Mar 28, 2024

Conversation

MrAlias
Copy link
Contributor

@MrAlias MrAlias commented Mar 19, 2024

Part of #5195

This adds the types that hold groups and attributes within the Handler. The kvBuffer is just a wrapper around []log.KeyValue and group is a linked list of embedded group structure (see type comment for next field for mapping information).

This does not include complete coverage of the added functionality. That is left for a follow-on PR. See #5195 for planned tests.

@MrAlias MrAlias added Skip Changelog Allow PR to succeed without requiring an addition to the CHANGELOG bridge: slog Related to the slog bridge labels Mar 19, 2024
Copy link

codecov bot commented Mar 19, 2024

Codecov Report

Attention: Patch coverage is 83.96947% with 21 lines in your changes are missing coverage. Please review.

Project coverage is 61.6%. Comparing base (46d20ec) to head (cb99e54).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##            main   #5314     +/-   ##
=======================================
+ Coverage   61.3%   61.6%   +0.2%     
=======================================
  Files        186     186             
  Lines      11253   11382    +129     
=======================================
+ Hits        6907    7019    +112     
- Misses      4147    4161     +14     
- Partials     199     202      +3     
Files Coverage Δ
bridges/otelslog/handler.go 88.0% <83.9%> (+1.0%) ⬆️

... and 1 file with indirect coverage changes

@MrAlias MrAlias marked this pull request as ready for review March 19, 2024 20:20
@MrAlias MrAlias requested a review from a team March 19, 2024 20:20
bridges/otelslog/handler.go Show resolved Hide resolved
bridges/otelslog/handler.go Outdated Show resolved Hide resolved
bridges/otelslog/handler.go Show resolved Hide resolved
bridges/otelslog/handler.go Outdated Show resolved Hide resolved
bridges/otelslog/handler.go Show resolved Hide resolved
@MrAlias MrAlias merged commit 3ca855b into open-telemetry:main Mar 28, 2024
23 checks passed
@MrAlias MrAlias deleted the grp-attr-handler branch March 28, 2024 18:34
@MrAlias MrAlias added this to the v1.25.0 milestone Apr 4, 2024
@pellared pellared mentioned this pull request Apr 8, 2024
New: func() any {
// Based on slog research (https://go.dev/blog/slog#performance), 95%
// of use-cases will use 5 or less attributes.
return newKVBuffer(5)
Copy link

Choose a reason for hiding this comment

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

I used 5 for the array inside a Record because there was a tradeoff: using too much space would hurt performance. There's no similar tradeoff here, so you could make this a bit larger. Maybe 10?

if b == nil {
return nil
}
return &kvBuffer{data: slices.Clone(b.data)}
Copy link

Choose a reason for hiding this comment

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

You lose any extra capacity when you clone b.data, so the subsequent AddAttrs will always allocate. (I think.)

In general though, it's probably best not to worry too much about these details. You can always tweak the performance later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bridge: slog Related to the slog bridge Skip Changelog Allow PR to succeed without requiring an addition to the CHANGELOG
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants