new tracing system

This commit is contained in:
Joe Kralicky 2025-01-09 19:25:49 +00:00
parent b87d940d11
commit a6f43f3c3c
No known key found for this signature in database
GPG key ID: 75C4875F34A9FB79
127 changed files with 7509 additions and 1454 deletions

View file

@ -0,0 +1,64 @@
package upstreams
import (
oteltrace "go.opentelemetry.io/otel/trace"
"go.opentelemetry.io/otel/trace/noop"
)
type CommonUpstreamOptions struct {
displayName string
clientTracerProviderOverride oteltrace.TracerProvider
serverTracerProviderOverride oteltrace.TracerProvider
delayShutdown bool
}
type CommonUpstreamOption interface {
GRPCUpstreamOption
HTTPUpstreamOption
}
type commonUpstreamOption func(o *CommonUpstreamOptions)
// applyGRPC implements CommonUpstreamOption.
func (c commonUpstreamOption) applyGRPC(o *GRPCUpstreamOptions) { c(&o.CommonUpstreamOptions) }
// applyHTTP implements CommonUpstreamOption.
func (c commonUpstreamOption) applyHTTP(o *HTTPUpstreamOptions) { c(&o.CommonUpstreamOptions) }
func WithDisplayName(displayName string) CommonUpstreamOption {
return commonUpstreamOption(func(o *CommonUpstreamOptions) {
o.displayName = displayName
})
}
func WithNoClientTracing() CommonUpstreamOption {
return commonUpstreamOption(func(o *CommonUpstreamOptions) {
o.clientTracerProviderOverride = noop.NewTracerProvider()
})
}
func WithNoServerTracing() CommonUpstreamOption {
return commonUpstreamOption(func(o *CommonUpstreamOptions) {
o.serverTracerProviderOverride = noop.NewTracerProvider()
})
}
func WithClientTracerProvider(tp oteltrace.TracerProvider) CommonUpstreamOption {
return commonUpstreamOption(func(o *CommonUpstreamOptions) {
o.clientTracerProviderOverride = tp
})
}
func WithServerTracerProvider(tp oteltrace.TracerProvider) CommonUpstreamOption {
return commonUpstreamOption(func(o *CommonUpstreamOptions) {
o.serverTracerProviderOverride = tp
})
}
// WithDelayedShutdown keeps the server alive until the test environment has
// fully shut down, instead of stopping it during the shutdown sequence.
func WithDelayedShutdown() CommonUpstreamOption {
return commonUpstreamOption(func(o *CommonUpstreamOptions) {
o.delayShutdown = true
})
}