Documentation
¶
Index ¶
- Constants
- func NewPlugin(opts ...Option) gorm.Plugin
- func SQLStatementTruncator(maxLength int) func(statement string) string
- func WithSkipSpan(ctx context.Context) context.Context
- type CounterSampler
- type CustomSampler
- type Option
- func WithAttributes(attrs ...attribute.KeyValue) Option
- func WithDBName(name string) Option
- func WithQueryFormatter(queryFormatter func(query string) string) Option
- func WithQueryVariables() Option
- func WithTracerProvider(provider trace.TracerProvider) Option
- func WithoutMetrics() Option
- func WithoutQueryVariables() Option
- type PgxTracer
- func (t *PgxTracer) TraceBatchQuery(ctx context.Context, conn *pgx.Conn, data pgx.TraceBatchQueryData)
- func (t *PgxTracer) TracePrepareStart(ctx context.Context, conn *pgx.Conn, data pgx.TracePrepareStartData) context.Context
- func (t *PgxTracer) TraceQueryStart(ctx context.Context, conn *pgx.Conn, data pgx.TraceQueryStartData) context.Context
- type Tracer
Constants ¶
const DefaultMaxSQLStatementLength = 8 * 1024
DefaultMaxSQLStatementLength caps SQL statement span attributes at 8 KiB.
const TracePaused paused = "trace-paused"
Variables ¶
This section is empty.
Functions ¶
func SQLStatementTruncator ¶ added in v1.0.1348
SQLStatementTruncator returns a query formatter that caps SQL statement size.
Types ¶
type CounterSampler ¶ added in v1.0.325
type CounterSampler struct {
// contains filtered or unexported fields
}
CounterSampler samples spans based on a counter, ensuring a percentage of spans are sampled.
func NewCounterSampler ¶ added in v1.0.325
func NewCounterSampler(percentage float64) *CounterSampler
NewCounterSampler creates a new CounterSampler. `percentage` should be a value between 0 and 100, representing the percentage of spans to sample.
func (*CounterSampler) Description ¶ added in v1.0.325
func (cs *CounterSampler) Description() string
Description returns the description of the sampler.
func (*CounterSampler) ShouldSample ¶ added in v1.0.325
func (cs *CounterSampler) ShouldSample(params trace.SamplingParameters) trace.SamplingResult
ShouldSample decides whether a span should be sampled based on a counter.
type CustomSampler ¶ added in v1.0.325
type CustomSampler struct {
// contains filtered or unexported fields
}
CustomSampler struct holds different samplers.
func NewCustomSampler ¶ added in v1.0.325
func NewCustomSampler(defaultSampler trace.Sampler, samplers map[string]trace.Sampler) *CustomSampler
NewCustomSampler creates a new instance of CustomSampler. `defaultSampler` is used when no specific sampler is found for a span name. `samplers` is a map where keys are span names and values are the specific samplers for those span names.
func (*CustomSampler) Description ¶ added in v1.0.325
func (cs *CustomSampler) Description() string
Description returns a description of the sampler.
func (*CustomSampler) ShouldSample ¶ added in v1.0.325
func (cs *CustomSampler) ShouldSample(params trace.SamplingParameters) trace.SamplingResult
ShouldSample implements the Sampler interface. It delegates the decision to a sampler based on the span name.
type Option ¶
type Option func(p *otelPlugin)
func WithAttributes ¶
WithAttributes configures attributes that are used to create a span.
func WithQueryFormatter ¶
WithQueryFormatter configures a query formatter.
func WithQueryVariables ¶ added in v1.0.1348
func WithQueryVariables() Option
WithQueryVariables configures the db.statement attribute to include query variables. Use it only for explicit local debugging because it can expose secrets.
func WithTracerProvider ¶
func WithTracerProvider(provider trace.TracerProvider) Option
WithTracerProvider configures a tracer provider that is used to create a tracer.
func WithoutMetrics ¶
func WithoutMetrics() Option
WithoutMetrics prevents DBStats metrics from being reported.
func WithoutQueryVariables ¶
func WithoutQueryVariables() Option
WithoutQueryVariables configures the db.statement attribute to exclude query variables. This is the default.
type PgxTracer ¶ added in v1.0.1348
PgxTracer records parameterized SQL shape only and caps SQL attributes.
func NewPgxTracer ¶ added in v1.0.1348
NewPgxTracer returns a pgx tracer with production-safe defaults.