mirror of
https://github.com/foomo/keel.git
synced 2025-10-16 12:35:34 +00:00
feat: add server name field
This commit is contained in:
parent
45e7d058e4
commit
f50d266e1f
@ -5,6 +5,9 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
// HTTPServerNameKey represents the name of the service handling the request
|
||||
HTTPServerNameKey = "http_server_name"
|
||||
|
||||
// HTTPMethodKey represents the HTTP request method.
|
||||
HTTPMethodKey = "http_method"
|
||||
|
||||
@ -44,6 +47,10 @@ const (
|
||||
HTTPSessionIDKey = "http_session_id"
|
||||
)
|
||||
|
||||
func FHTTPServerName(id string) zap.Field {
|
||||
return zap.String(HTTPServerNameKey, id)
|
||||
}
|
||||
|
||||
func FHTTPRequestID(id string) zap.Field {
|
||||
return zap.String(HTTPRequestIDKey, id)
|
||||
}
|
||||
|
||||
@ -17,11 +17,15 @@ func WithError(l *zap.Logger, err error) *zap.Logger {
|
||||
return l.With(FError(err))
|
||||
}
|
||||
|
||||
func WithHTTPServerName(l *zap.Logger, name string) *zap.Logger {
|
||||
return l.With(FHTTPServerName(name))
|
||||
}
|
||||
|
||||
func WithServiceName(l *zap.Logger, name string) *zap.Logger {
|
||||
return l.With(FServiceName(name))
|
||||
}
|
||||
|
||||
func WithTraceID(l *zap.Logger, ctx context.Context) *zap.Logger { //nolint:revive
|
||||
func WithTraceID(l *zap.Logger, ctx context.Context) *zap.Logger {
|
||||
if spanCtx := trace.SpanContextFromContext(ctx); spanCtx.IsValid() {
|
||||
l = l.With(FTraceID(spanCtx.TraceID().String()))
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user