Skip to content

Commit

Permalink
fix: replace trace-id by trace_id
Browse files Browse the repository at this point in the history
  • Loading branch information
samber committed Aug 17, 2024
1 parent 1126498 commit ad1624e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ Attributes will be injected in log payload.
Other global parameters:

```go
sloggin.TraceIDKey = "trace-id"
sloggin.SpanIDKey = "span-id"
sloggin.TraceIDKey = "trace_id"
sloggin.SpanIDKey = "span_id"
sloggin.RequestBodyMaxSize = 64 * 1024 // 64KB
sloggin.ResponseBodyMaxSize = 64 * 1024 // 64KB
sloggin.HiddenRequestHeaders = map[string]struct{}{ ... }
Expand Down
7 changes: 4 additions & 3 deletions middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ const (
)

var (
TraceIDKey = "trace-id"
SpanIDKey = "span-id"
TraceIDKey = "trace_id"
SpanIDKey = "span_id"
RequestIDKey = "id"

RequestBodyMaxSize = 64 * 1024 // 64KB
Expand Down Expand Up @@ -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 {
requestID, ok := c.Get(requestIDCtx)
if !ok {
Expand All @@ -272,6 +272,7 @@ func GetRequestID(c *gin.Context) string {
return ""
}

// AddCustomAttributes adds custom attributes to the request context.
func AddCustomAttributes(c *gin.Context, attr slog.Attr) {
v, exists := c.Get(customAttributesCtxKey)
if !exists {
Expand Down

0 comments on commit ad1624e

Please # to comment.