mirror of
https://github.com/compute-blade-community/compute-blade-agent.git
synced 2026-04-16 15:35:42 +02:00
* feat(OpenTelemetry): Integrate OpenTelemetry into agent - integrate OpenTelemetry logging with zap logger for better observability - add OpenTelemetry gRPC middleware for enhanced tracing capabilities - document new OTLP exporter endpoint for better configuration guidance * docs: document OTEL env var --------- Co-authored-by: Cedric Kienzler <cedric@specht-labs.de>
25 lines
514 B
Go
25 lines
514 B
Go
package log
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/spechtlabs/go-otel-utils/otelzap"
|
|
"go.uber.org/zap"
|
|
)
|
|
|
|
type logCtxKey int
|
|
|
|
func IntoContext(ctx context.Context, logger *otelzap.Logger) context.Context {
|
|
return context.WithValue(ctx, logCtxKey(0), logger)
|
|
}
|
|
|
|
func FromContext(ctx context.Context) *otelzap.Logger {
|
|
val := ctx.Value(logCtxKey(0))
|
|
if val != nil {
|
|
return val.(*otelzap.Logger)
|
|
}
|
|
|
|
otelzap.L().WithOptions(zap.AddCallerSkip(1)).Warn("No logger in context, passing default")
|
|
return otelzap.L()
|
|
}
|