Documentation
¶
Index ¶
- Variables
- func Init(config Config)
- func IsEnabled() bool
- func NewGRPCStreamClientInterceptor(options ...GRPCOption) grpc.StreamClientInterceptor
- func NewGRPCStreamServerInterceptor(options ...GRPCOption) grpc.StreamServerInterceptor
- func NewGRPCUnaryClientInterceptor(options ...GRPCOption) grpc.UnaryClientInterceptor
- func NewGRPCUnaryServerInterceptor(options ...GRPCOption) grpc.UnaryServerInterceptor
- func NewKafkaProducerHook() xkafka.ProducerHook
- func NewWebClientMiddleware() webclient.Middleware
- func NewWebMiddleware(options ...WebOption) app.HandlerFunc
- type Config
- type Content
- type GRPCOption
- type HttpClientHook
- type KafkaProducerSpan
- type Option
- func WithAttributes(attrs ...attribute.KeyValue) Option
- func WithDBName(name string) Option
- func WithFormattedQueries(format bool) Option
- func WithMeterProvider(mp metric.MeterProvider) Option
- func WithSpanNameFormatter(f func(*bun.QueryEvent) string) Option
- func WithTracerProvider(tp trace.TracerProvider) Option
- type QueryHook
- type TracingHook
- type WebOption
Constants ¶
This section is empty.
Variables ¶
var DefaultClient *client
Functions ¶
func NewGRPCStreamClientInterceptor ¶
func NewGRPCStreamClientInterceptor(options ...GRPCOption) grpc.StreamClientInterceptor
NewGRPCStreamClientInterceptor returns a grpc.StreamClientInterceptor that records a client span and injects W3C trace context into outgoing metadata. The span ends when the stream finishes normally or with an error.
func NewGRPCStreamServerInterceptor ¶
func NewGRPCStreamServerInterceptor(options ...GRPCOption) grpc.StreamServerInterceptor
NewGRPCStreamServerInterceptor returns a grpc.StreamServerInterceptor that extracts W3C trace context from incoming metadata and records a server span.
func NewGRPCUnaryClientInterceptor ¶
func NewGRPCUnaryClientInterceptor(options ...GRPCOption) grpc.UnaryClientInterceptor
NewGRPCUnaryClientInterceptor returns a grpc.UnaryClientInterceptor that records a client span and injects W3C trace context into outgoing metadata.
func NewGRPCUnaryServerInterceptor ¶
func NewGRPCUnaryServerInterceptor(options ...GRPCOption) grpc.UnaryServerInterceptor
NewGRPCUnaryServerInterceptor returns a grpc.UnaryServerInterceptor that extracts W3C trace context from incoming metadata and records a server span.
func NewKafkaProducerHook ¶
func NewKafkaProducerHook() xkafka.ProducerHook
NewKafkaProducerHook returns a ProducerHook that enables OpenTelemetry tracing for kafka producers. Callers opt in by registering it with producer.AddHook(otel.NewKafkaProducerHook()).
func NewWebClientMiddleware ¶
func NewWebClientMiddleware() webclient.Middleware
NewWebClientMiddleware returns tracing middleware for web/app/client. Register it with client.Use():
c.Use(otel.NewWebClientMiddleware())
func NewWebMiddleware ¶
func NewWebMiddleware(options ...WebOption) app.HandlerFunc
NewWebMiddleware returns tracing middleware that can be registered with RouterGroup.Use() or Engine.Use(). Request and response bodies are disabled by default because they frequently contain PII or credentials.
Types ¶
type Config ¶
type Config struct {
Enabled bool `yaml:"enabled" json:"enabled"`
Endpoint string `yaml:"endpoint" json:"endpoint"`
Protocol string `yaml:"protocol" json:"protocol"`
ServiceName string `yaml:"serviceName" json:"serviceName"`
ServiceVersion string `yaml:"serviceVersion" json:"serviceVersion"`
DeploymentEnv string `yaml:"deploymentEnv" json:"deploymentEnv"`
}
type GRPCOption ¶
type GRPCOption func(*grpcTraceOptions)
GRPCOption configures how gRPC calls are traced.
func WithGRPCSkipMethods ¶
func WithGRPCSkipMethods(methods ...string) GRPCOption
WithGRPCSkipMethods skips tracing for the given full method paths, for example "/pkg.Service/Check". The leading slash is optional.
func WithGRPCSkipServicePrefixes ¶
func WithGRPCSkipServicePrefixes(prefixes ...string) GRPCOption
WithGRPCSkipServicePrefixes skips tracing for every method whose service name starts with one of the given prefixes, for example "pkg.Health".
type HttpClientHook ¶
type HttpClientHook struct {
}
func NewHttpClientHook ¶
func NewHttpClientHook() *HttpClientHook
func (*HttpClientHook) AfterRequest ¶
func (*HttpClientHook) BeforeRequest ¶
type KafkaProducerSpan ¶
type KafkaProducerSpan struct {
// contains filtered or unexported fields
}
KafkaProducerSpan represents one producer send operation. Complete ends the span as soon as Send or AsyncSend returns; per-message delivery results are intentionally not part of the send span.
func StartKafkaProducerSpan ¶
func StartKafkaProducerSpan(topic, key string, messageCount int) *KafkaProducerSpan
func (*KafkaProducerSpan) Complete ¶
func (span *KafkaProducerSpan) Complete(err error)
func (*KafkaProducerSpan) MessageDone ¶
func (span *KafkaProducerSpan) MessageDone(err error)
MessageDone is a no-op because the span is finished by Complete and does not wait for per-message delivery results.
type Option ¶
type Option func(h *QueryHook)
func WithAttributes ¶
WithAttributes configures attributes that are used to create a span.
func WithFormattedQueries ¶
WithFormattedQueries enables formatting of the query that is added as the statement attribute to the trace. This means that all placeholders and arguments will be filled first and the query will contain all information as sent to the database.
func WithMeterProvider ¶
func WithMeterProvider(mp metric.MeterProvider) Option
WithMeterProvider returns an Option to use the MeterProvider when creating a Meter.
func WithSpanNameFormatter ¶
func WithSpanNameFormatter(f func(*bun.QueryEvent) string) Option
WithSpanNameFormatter takes a function that determines the span name for a given query event.
func WithTracerProvider ¶
func WithTracerProvider(tp trace.TracerProvider) Option
WithTracerProvider returns an Option to use the TracerProvider when creating a Tracer.
type QueryHook ¶
type QueryHook struct {
// contains filtered or unexported fields
}
func NewQueryHook ¶
func (*QueryHook) AfterQuery ¶
func (h *QueryHook) AfterQuery(ctx context.Context, event *bun.QueryEvent)
func (*QueryHook) BeforeQuery ¶
type TracingHook ¶
type TracingHook struct{}
func NewTracingHook ¶
func NewTracingHook() *TracingHook
func (TracingHook) DialHook ¶
func (TracingHook) DialHook(next redis.DialHook) redis.DialHook
DialHook implements the v9 redis.Hook interface. It passes through to the next dialer.
func (TracingHook) ProcessHook ¶
func (TracingHook) ProcessHook(next redis.ProcessHook) redis.ProcessHook
ProcessHook implements the v9 redis.Hook interface using the middleware/wrapper pattern. It creates a tracing span before the command executes and ends it after.
func (TracingHook) ProcessPipelineHook ¶
func (TracingHook) ProcessPipelineHook(next redis.ProcessPipelineHook) redis.ProcessPipelineHook
ProcessPipelineHook implements the v9 redis.Hook interface for pipeline commands.
type WebOption ¶
type WebOption func(*webTraceOptions)
func WithAllowedHeaders ¶
WithAllowedHeaders restricts captured request and response headers. By default no headers are captured.
func WithDeniedHeaders ¶
WithDeniedHeaders adds request and response headers to the built-in sensitive header list.
func WithRequestBody ¶
WithRequestBody controls capturing the first maxSize bytes of a request body. A non-positive maxSize uses the default limit.
func WithResponseBody ¶
WithResponseBody controls capturing response data. A non-positive maxSize uses the default limit.