Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions go/logger/logger.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package logger

import (
"context"

"github.com/vmware/alb-sdk/go/models"
)

func GetTraceID(ctx context.Context) string {
traceIDType := ctx.Value(models.TraceID)
traceID, ok := traceIDType.(string)
if !ok {
return ""
}
return traceID
}

func SetTraceID(ctx context.Context, traceID string) context.Context {
return context.WithValue(ctx, models.TraceID, traceID)
}
5 changes: 5 additions & 0 deletions go/models/logger.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package models

type TraceIDType string

const TraceID TraceIDType = "trace-id"