github.com/blend/go-sdk@v1.20220411.3/sentry/context_fingerprint.go (about) 1 /* 2 3 Copyright (c) 2022 - Present. Blend Labs, Inc. All rights reserved 4 Use of this source code is governed by a MIT license that can be found in the LICENSE file. 5 6 */ 7 8 package sentry 9 10 import "context" 11 12 type contextFingerprintKey struct{} 13 14 // GetFingerprint gets a context specific fingerprint from the context. 15 // You can set this with `WithFingerprint(...)`. It will override the default behavior 16 // of setting the fingerprint to the logger path + err.Error(). 17 func GetFingerprint(ctx context.Context) []string { 18 if ctx == nil { 19 return nil 20 } 21 if value := ctx.Value(contextFingerprintKey{}); value != nil { 22 if typed, ok := value.([]string); ok { 23 return typed 24 } 25 } 26 return nil 27 } 28 29 // WithFingerprint sets the context fingerprint. You can use this to override the default 30 // fingerprint value submitted by the SDK to sentry. 31 func WithFingerprint(ctx context.Context, fingerprint ...string) context.Context { 32 return context.WithValue(ctx, contextFingerprintKey{}, fingerprint) 33 }