fix: replace trace-id by trace_id
spec: https://opentelemetry.io/docs/specs/otel/compatibility/logging_trace_context
This commit is contained in:
@@ -107,8 +107,8 @@ Attributes will be injected in log payload.
|
|||||||
Other global parameters:
|
Other global parameters:
|
||||||
|
|
||||||
```go
|
```go
|
||||||
sloggin.TraceIDKey = "trace-id"
|
sloggin.TraceIDKey = "trace_id"
|
||||||
sloggin.SpanIDKey = "span-id"
|
sloggin.SpanIDKey = "span_id"
|
||||||
sloggin.RequestBodyMaxSize = 64 * 1024 // 64KB
|
sloggin.RequestBodyMaxSize = 64 * 1024 // 64KB
|
||||||
sloggin.ResponseBodyMaxSize = 64 * 1024 // 64KB
|
sloggin.ResponseBodyMaxSize = 64 * 1024 // 64KB
|
||||||
sloggin.HiddenRequestHeaders = map[string]struct{}{ ... }
|
sloggin.HiddenRequestHeaders = map[string]struct{}{ ... }
|
||||||
|
|||||||
+4
-3
@@ -18,8 +18,8 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
TraceIDKey = "trace-id"
|
TraceIDKey = "trace_id"
|
||||||
SpanIDKey = "span-id"
|
SpanIDKey = "span_id"
|
||||||
RequestIDKey = "id"
|
RequestIDKey = "id"
|
||||||
|
|
||||||
RequestBodyMaxSize = 64 * 1024 // 64KB
|
RequestBodyMaxSize = 64 * 1024 // 64KB
|
||||||
@@ -258,7 +258,7 @@ func NewWithConfig(logger *slog.Logger, config Config) gin.HandlerFunc {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetRequestID returns the request identifier
|
// GetRequestID returns the request identifier.
|
||||||
func GetRequestID(c *gin.Context) string {
|
func GetRequestID(c *gin.Context) string {
|
||||||
requestID, ok := c.Get(requestIDCtx)
|
requestID, ok := c.Get(requestIDCtx)
|
||||||
if !ok {
|
if !ok {
|
||||||
@@ -272,6 +272,7 @@ func GetRequestID(c *gin.Context) string {
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// AddCustomAttributes adds custom attributes to the request context.
|
||||||
func AddCustomAttributes(c *gin.Context, attr slog.Attr) {
|
func AddCustomAttributes(c *gin.Context, attr slog.Attr) {
|
||||||
v, exists := c.Get(customAttributesCtxKey)
|
v, exists := c.Get(customAttributesCtxKey)
|
||||||
if !exists {
|
if !exists {
|
||||||
|
|||||||
Reference in New Issue
Block a user