Skip to content

Commit

Permalink
fix(breaking): sampling ratio yaml config (#3034)
Browse files Browse the repository at this point in the history
  • Loading branch information
markphelps authored May 1, 2024
1 parent e262e82 commit 188a072
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions config/flipt.schema.cue
Original file line number Diff line number Diff line change
Expand Up @@ -282,9 +282,9 @@ import "strings"
}

#tracing: {
enabled?: bool | *false
exporter?: *"jaeger" | "zipkin" | "otlp"
samplingRatio?: float & >=0 & <=1 | *1
enabled?: bool | *false
exporter?: *"jaeger" | "zipkin" | "otlp"
sampling_ratio?: float & >=0 & <=1 | *1
propagators?: [
..."tracecontext" | "baggage" | "b3" | "b3multi" | "jaeger" | "xray" | "ottrace" | "none",
] | *["tracecontext", "baggage"]
Expand Down
2 changes: 1 addition & 1 deletion config/flipt.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -977,7 +977,7 @@
"enum": ["jaeger", "zipkin", "otlp"],
"default": "jaeger"
},
"samplingRatio": {
"sampling_ratio": {
"type": "number",
"default": 1,
"minimum": 0,
Expand Down
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:"sampling_ratio" 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 188a072

Please sign in to comment.