otel: add options to configure log level and span error status (WithLevel, WithErrorStatusLevel) - #25
Draft
thaJeztah wants to merge 12 commits into
Draft
otel: add options to configure log level and span error status (WithLevel, WithErrorStatusLevel)#25thaJeztah wants to merge 12 commits into
thaJeztah wants to merge 12 commits into
Conversation
thaJeztah
force-pushed
the
integrate_tracing_improve
branch
3 times, most recently
from
August 23, 2026 11:54
187bc04 to
0ae6429
Compare
This adds valuable logging data to the open telemetry traces. When the trace is not recording we don't bother doing anything as it is relatively expensive to convert logrus data to otel just due to the nature of how logrus works. The way this works is that we now set a context on the logrus.Entry that gets passed around which the hook then uses to determine if there is an active span to forward the logs to. Signed-off-by: Brian Goff <cpuguy83@gmail.com>
This fixes the issue with the usage of the deprecated attribute.Any function that original caused build issues. Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Signed-off-by: Swagat Bora <sbora@amazon.com>
Signed-off-by: Swagat Bora <sbora@amazon.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
While the hook is intended to be used with logrus, we don't need to have the direct import; use the aliases provided by the containerd/log module instead. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Check span.IsRecording first, as it's a more lightweight check than span.SpanContext().IsValid() Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Introduce functional options to NewLogrusHook to allow optional Trace ID injection into log fields. This enables log-trace correlation via the [debug] config without breaking existing external consumers of pkg/tracing. Signed-off-by: Hasan Siddiqui <hasiddiqui@google.com>
Make the otel package a separate module, so that containerd/log does not inherit the otel dependencies. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Log fields which contain an error currently fall through to JSON
marshaling, which may produce an unhelpful value such as "{}" instead
of the error message.
Handle error values explicitly and use fmt.Sprint when formatting error
and fmt.Stringer values. Besides preserving their textual
representation, fmt handles typed-nil implementations without
propagating a panic from their Error or String method.
Also simplify the final fmt.Sprintf("%v", v) fallback to fmt.Sprint(v).
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Add WithLevel to configure the minimum log level handled by the OpenTelemetry hook. This allows callers to limit which log entries are recorded as span events, reducing trace noise and overhead when lower-severity logs are not useful for tracing. By default, the hook continues to handle all log levels, preserving the existing behavior. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Add WithErrorStatusLevel to configure the minimum log level that marks an active span with an error status. This allows callers to reflect sufficiently severe log entries in the span status while keeping the behavior independent from attached error fields. By default, log entries continue to leave the span status unchanged. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
thaJeztah
force-pushed
the
integrate_tracing_improve
branch
from
August 23, 2026 15:49
0ae6429 to
15f4ac3
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
otel: add options to configure log level and span error status
These options make the containerd hook flexible enough to replace otellogrus (https://pkg.go.dev/github.com/uptrace/opentelemetry-go-extra/otellogrus) for consumers that currently use it for Logrus/OpenTelemetry integration combined with containerd/log. Callers can preserve their existing log-level filtering and span error-status behavior without needing a second tracing hook implementation.
otel: add option to configure log level
Add WithLevel to configure the minimum log level handled by the
OpenTelemetry hook.
This allows callers to limit which log entries are recorded as span
events, reducing trace noise and overhead when lower-severity logs are
not useful for tracing.
By default, the hook continues to handle all log levels, preserving
the existing behavior.
otel: add option to set span error status
Add WithErrorStatusLevel to configure the minimum log level that marks
an active span with an error status.
This allows callers to reflect sufficiently severe log entries in the
span status while keeping the behavior independent from attached error
fields.
By default, log entries continue to leave the span status unchanged.