Skip to content

Commit

Permalink
otelzerolog: Add otelzerolog under experimental bridge (#5930)
Browse files Browse the repository at this point in the history
Fixes #5405

---------

Co-authored-by: Robert Pająk <[email protected]>
  • Loading branch information
AkhigbeEromo and pellared authored Jul 22, 2024
1 parent 5d2c609 commit 68bd7f2
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
- The `go.opentelemetry.io/contrib/config` package supports configuring `with_resource_constant_labels` for the prometheus exporter. (#5890)
- Add new runtime metrics to `go.opentelemetry.io/contrib/instrumentation/runtime`, which are still disabled by default. (#5870)
- Support for the `OTEL_HTTP_CLIENT_COMPATIBILITY_MODE=http/dup` environment variable in `go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp` to emit attributes for both the v1.20.0 and v1.26.0 semantic conventions. (#5401)
- The `go.opentelemetry.io/contrib/bridges/otelzerolog` module.
This module provides an OpenTelemetry logging bridge for `github.com/rs/zerolog`. (#5405)

### Removed

Expand Down
21 changes: 21 additions & 0 deletions bridges/otelzerolog/hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,27 @@

// Package otelzerolog provides a [Hook], a [zerolog.Hook] implementation that
// can be used to bridge between the [zerolog] API and [OpenTelemetry].
//
// # Record Conversion
//
// The [zerolog.Event] records are converted to OpenTelemetry [log.Record] in
// the following way:
//
// - Message is set as the Body using a [log.StringValue].
// - Level is transformed and set as the Severity. The SeverityText is also
// set.
//
// The Level is transformed to the OpenTelemetry Severity types in the following way.
//
// - [zerolog.DebugLevel] is transformed to [log.SeverityDebug]
// - [zerolog.InfoLevel] is transformed to [log.SeverityInfo]
// - [zerolog.WarnLevel] is transformed to [log.SeverityWarn]
// - [zerolog.ErrorLevel] is transformed to [log.SeverityError]
// - [zerolog.PanicLevel] is transformed to [log.SeverityFatal1]
// - [zerolog.FatalLevel] is transformed to [log.SeverityFatal2]
//
// NOTE: Fields are not transformed because of https://github.com/rs/zerolog/issues/493.
//
// [OpenTelemetry]: https://opentelemetry.io/docs/concepts/signals/logs/
package otelzerolog // import "go.opentelemetry.io/contrib/bridges/otelzerolog"

Expand Down
1 change: 0 additions & 1 deletion versions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ module-sets:
modules:
- go.opentelemetry.io/contrib/detectors/azure/azurevm
excluded-modules:
- go.opentelemetry.io/contrib/bridges/otelzerolog
- go.opentelemetry.io/contrib/instrgen
- go.opentelemetry.io/contrib/instrgen/driver
- go.opentelemetry.io/contrib/instrgen/testdata/interface

0 comments on commit 68bd7f2

Please sign in to comment.