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

Logging bridge for logr #5357

Closed

Conversation

scorpionknifes
Copy link
Member

@scorpionknifes scorpionknifes commented Apr 3, 2024

Towards #5192

Looking to do benchmarks in a different PR

Notes:

  • slogSink converts any non string value to slog.Any which is handled with fmt.Sprintf("%+v", v) by otelslog. This PR does not do the above and instead opts to use convertValue to get the convert based on type which maybe less performant 🤔
  • convertValue - follows how funcr handle interface{}
  • currently it's designed to convert nested values recursively with convertValue, is there a max depth for converted attributes?
  • kvBuffer - is used in otelslog, I propose to move kvBuffer to internal pkg and reused it here too?

Copy link

codecov bot commented Apr 3, 2024

Codecov Report

Attention: Patch coverage is 99.45055% with 1 line in your changes missing coverage. Please review.

Project coverage is 65.8%. Comparing base (b058429) to head (beae842).
Report is 350 commits behind head on main.

Files with missing lines Patch % Lines
bridges/otellogr/logsink.go 99.4% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##            main   #5357     +/-   ##
=======================================
+ Coverage   65.3%   65.8%   +0.4%     
=======================================
  Files        203     204      +1     
  Lines      12780   12962    +182     
=======================================
+ Hits        8348    8529    +181     
- Misses      4189    4190      +1     
  Partials     243     243             
Files with missing lines Coverage Δ
bridges/otellogr/logsink.go 99.4% <99.4%> (ø)

@scorpionknifes scorpionknifes changed the title WIP: Logging bridge for logr Logging bridge for logr Apr 9, 2024
@scorpionknifes scorpionknifes marked this pull request as ready for review April 9, 2024 15:29
@scorpionknifes scorpionknifes requested a review from a team April 9, 2024 15:29
@scorpionknifes scorpionknifes requested a review from pellared April 11, 2024 15:40
bridges/otelslog/example_test.go Outdated Show resolved Hide resolved
bridges/otellogr/logsink.go Outdated Show resolved Hide resolved
Copy link
Member

@pellared pellared left a comment

Choose a reason for hiding this comment

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

I made a quick review.

bridges/otellogr/logsink.go Outdated Show resolved Hide resolved
CODEOWNERS Outdated Show resolved Hide resolved
@scorpionknifes scorpionknifes requested a review from XSAM as a code owner July 16, 2024 02:00
bridges/otellogr/logsink.go Outdated Show resolved Hide resolved
bridges/otellogr/version.go Outdated Show resolved Hide resolved
// log sends a log record to the OpenTelemetry logger.
func (l *LogSink) log(err error, msg string, serverity log.Severity, kvList ...any) {
var record log.Record
record.SetTimestamp(time.Now())
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
record.SetTimestamp(time.Now())

As in #5918 (comment)
The API implementation will set the timestamp to time.Now() already. So we can rely on that default.

Copy link
Member

@pellared pellared Jul 17, 2024

Choose a reason for hiding this comment

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

Maybe we should respect the following conventions https://pkg.go.dev/github.com/go-logr/logr#hdr-Key_Naming_Conventions?

"level": the log level
"logger": the name of the associated logger
"ts": the timestamp for a log line

Better as a separate PR.

bridges/otellogr/logsink.go Outdated Show resolved Hide resolved
bridges/otellogr/logsink.go Outdated Show resolved Hide resolved
bridges/otellogr/logsink.go Outdated Show resolved Hide resolved
@scorpionknifes scorpionknifes force-pushed the feature/impl-otellogr branch from ccbce1e to 1f341c7 Compare July 25, 2024 14:10
@scorpionknifes scorpionknifes requested a review from pellared July 25, 2024 14:16
@pellared pellared mentioned this pull request Jul 25, 2024
5 tasks
@scorpionknifes scorpionknifes requested a review from pellared July 29, 2024 15:52
@dmathieu
Copy link
Member

dmathieu commented Jul 30, 2024

@scorpionknifes After chatting with @pellared we think it would be easier for us to review this PR if you split it into smaller ones, like we did for zap and zerolog.

If you want an example, you can look at the various

@pellared
Copy link
Member

Changing this PR to draft per #5357 (comment).

Use this PR as a reference for new PRs.

@pellared pellared marked this pull request as draft July 30, 2024 08:15
@pellared
Copy link
Member

pellared commented Sep 3, 2024

@scorpionknifes, are you able to follow up with creating smaller PRs or can we use your PR to start creating them ourselves (we can still add you as code owner)?

@scorpionknifes
Copy link
Member Author

I apologize for being slow on this. I’ll look at it over the weekend. I’ll keep you posted! Thanks for your patience

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