Skip to content

Commit

Permalink
fix: sampling ratio yaml config
Browse files Browse the repository at this point in the history
  • Loading branch information
markphelps committed Apr 30, 2024
1 parent e262e82 commit 240e48d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion internal/config/testdata/tracing/otlp.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
tracing:
enabled: true
exporter: otlp
samplingRatio: 0.5
sampling_ratio: 0.5
otlp:
endpoint: http://localhost:9999
headers:
Expand Down
2 changes: 1 addition & 1 deletion internal/config/testdata/tracing/wrong_sampling_ratio.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
tracing:
enabled: true
samplingRatio: 1.1
sampling_ratio: 1.1
8 changes: 4 additions & 4 deletions internal/config/tracing.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@ type TracingConfig struct {
Enabled bool `json:"enabled" mapstructure:"enabled" yaml:"enabled"`
Exporter TracingExporter `json:"exporter,omitempty" mapstructure:"exporter" yaml:"exporter,omitempty"`
Propagators []TracingPropagator `json:"propagators,omitempty" mapstructure:"propagators" yaml:"propagators,omitempty"`
SamplingRatio float64 `json:"samplingRatio,omitempty" mapstructure:"samplingRatio" yaml:"samplingRatio,omitempty"`
SamplingRatio float64 `json:"samplingRatio,omitempty" mapstructure:"samplingRatio" yaml:"sampling_ratio,omitempty"`
Jaeger JaegerTracingConfig `json:"jaeger,omitempty" mapstructure:"jaeger" yaml:"jaeger,omitempty"`
Zipkin ZipkinTracingConfig `json:"zipkin,omitempty" mapstructure:"zipkin" yaml:"zipkin,omitempty"`
OTLP OTLPTracingConfig `json:"otlp,omitempty" mapstructure:"otlp" yaml:"otlp,omitempty"`
}

func (c *TracingConfig) setDefaults(v *viper.Viper) error {
v.SetDefault("tracing", map[string]any{
"enabled": false,
"exporter": TracingJaeger,
"samplingRatio": 1,
"enabled": false,
"exporter": TracingJaeger,
"sampling_ratio": 1,
"propagators": []TracingPropagator{
TracingPropagatorTraceContext,
TracingPropagatorBaggage,
Expand Down

0 comments on commit 240e48d

Please sign in to comment.