Skip to content

Commit

Permalink
feat(tracing): add sample rate config
Browse files Browse the repository at this point in the history
  • Loading branch information
joaofnds committed Sep 16, 2023
1 parent 705b47c commit c1219c3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
7 changes: 4 additions & 3 deletions adapter/tracing/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ package tracing
import "time"

type Config struct {
Addr string `mapstructure:"addr"`
Secure bool `mapstructure:"secure"`
Timeout time.Duration `mapstructure:"timeout"`
Addr string `mapstructure:"addr"`
Secure bool `mapstructure:"secure"`
Timeout time.Duration `mapstructure:"timeout"`
SampleRate float64 `mapstructure:"sample_rate"`
}
4 changes: 2 additions & 2 deletions adapter/tracing/tracing.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ var Module = fx.Options(
return otlptracegrpc.NewUnstarted(opts...)
}),

fx.Provide(func(exporter *otlptrace.Exporter) *sdktrace.TracerProvider {
fx.Provide(func(config Config, exporter *otlptrace.Exporter) *sdktrace.TracerProvider {
provider := sdktrace.NewTracerProvider(
sdktrace.WithSampler(sdktrace.AlwaysSample()),
sdktrace.WithSampler(sdktrace.TraceIDRatioBased(config.SampleRate)),
sdktrace.WithBatcher(exporter),
sdktrace.WithResource(resource.NewWithAttributes(
semconv.SchemaURL,
Expand Down
1 change: 1 addition & 0 deletions config/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ tracing:
addr: localhost:4317
secure: false
timeout: 1s
sample_rate: 1.0
feature_flags:
polling_interval: 15s
flags:
Expand Down

0 comments on commit c1219c3

Please sign in to comment.