From 68bd7f27cf5ff65b26665daa1a56034bd18abf61 Mon Sep 17 00:00:00 2001 From: Akhigbe Eromosele David Date: Mon, 22 Jul 2024 09:39:15 +0100 Subject: [PATCH] otelzerolog: Add otelzerolog under experimental bridge (#5930) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #5405 --------- Co-authored-by: Robert PajÄ…k --- CHANGELOG.md | 2 ++ bridges/otelzerolog/hook.go | 21 +++++++++++++++++++++ versions.yaml | 1 - 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0f3818a79bc..1c5d1a37850 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/bridges/otelzerolog/hook.go b/bridges/otelzerolog/hook.go index 5f8327f1f01..f9b2b5cb2c4 100644 --- a/bridges/otelzerolog/hook.go +++ b/bridges/otelzerolog/hook.go @@ -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" diff --git a/versions.yaml b/versions.yaml index a66ee6e247c..0013dc4fa17 100644 --- a/versions.yaml +++ b/versions.yaml @@ -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