...
1 package fog
2
3 import (
4 "context"
5 "fmt"
6
7 guuid "github.com/google/uuid"
8 )
9
10 type operationCtxKey struct{}
11
12
13
14 func OperationFields(opID string) []interface{} {
15 ret := make([]interface{}, 2)
16 ret[0] = fmt.Sprintf("%sid", gcpOperationKey)
17 ret[1] = opID
18 return ret
19 }
20
21
22 func SetOperationContext(ctx context.Context) context.Context {
23 c := context.WithValue(ctx, operationCtxKey{}, guuid.New().String())
24 return c
25 }
26
27 func OperationID(ctx context.Context) string {
28 if o, ok := ctx.Value(operationCtxKey{}).(string); ok {
29 return o
30 }
31 return ""
32 }
33
View as plain text