gitlab.com/gitlab-org/labkit@v1.21.0/tracing/impl/default_sampling.go (about) 1 package impl 2 3 import ( 4 "github.com/opentracing/opentracing-go" 5 ) 6 7 var IsSampled = func(span opentracing.Span) bool { 8 spanContext := span.Context() 9 10 // Other non-exported context with conditional build tags. They must 11 // implement samplingChecker interface. 12 if spanSampler, ok := spanContext.(samplingChecker); ok { 13 return spanSampler.IsSampled() 14 } 15 16 return false 17 } 18 19 // samplingChecker is an interface consisting of one function that returns 20 // the sampling status. Some implementations follow opentracing. Labkit doesn't 21 // need to convert. Some others, such as stackdriver, implement opentracing 22 // wrappers. Those wrappers are internal, and conditional built when receiving 23 // corresponding build tag. As a result, such wrappers are not available for 24 // casting in IsSampled function above. 25 // Such implementations have to take a detour by implementing this interface. 26 type samplingChecker interface { 27 IsSampled() bool 28 }