mirror of
https://github.com/pomerium/pomerium.git
synced 2025-08-02 00:10:45 +02:00
set default tracing sample rate to 1.0
This commit is contained in:
parent
86bf8a1d5f
commit
61e56b6e42
4 changed files with 18 additions and 10 deletions
|
@ -56,8 +56,17 @@ func applyTracingConfig(
|
|||
maxPathTagLength = max(64, uint32(num))
|
||||
}
|
||||
}
|
||||
sampleRate := 1.0
|
||||
if value, ok := os.LookupEnv("OTEL_TRACES_SAMPLER_ARG"); ok {
|
||||
if rate, err := strconv.ParseFloat(value, 64); err == nil {
|
||||
sampleRate = rate
|
||||
}
|
||||
}
|
||||
if opts.TracingSampleRate != nil {
|
||||
sampleRate = *opts.TracingSampleRate
|
||||
}
|
||||
mgr.Tracing = &envoy_extensions_filters_network_http_connection_manager.HttpConnectionManager_Tracing{
|
||||
RandomSampling: &envoy_type_v3.Percent{Value: opts.TracingSampleRate * 100},
|
||||
RandomSampling: &envoy_type_v3.Percent{Value: max(0.0, min(1.0, sampleRate)) * 100},
|
||||
Verbose: true,
|
||||
SpawnUpstreamSpan: wrapperspb.Bool(true),
|
||||
Provider: &tracev3.Tracing_Http{
|
||||
|
|
|
@ -210,10 +210,10 @@ type Options struct {
|
|||
MetricsClientCA string `mapstructure:"metrics_client_ca" yaml:"metrics_client_ca,omitempty"`
|
||||
MetricsClientCAFile string `mapstructure:"metrics_client_ca_file" yaml:"metrics_client_ca_file,omitempty"`
|
||||
|
||||
TracingSampleRate float64 `mapstructure:"tracing_sample_rate" yaml:"tracing_sample_rate,omitempty"`
|
||||
TracingProvider string `mapstructure:"tracing_provider" yaml:"tracing_provider,omitempty"`
|
||||
TracingOTLPEndpoint string `mapstructure:"tracing_otlp_endpoint" yaml:"tracing_otlp_endpoint,omitempty"`
|
||||
TracingOTLPProtocol string `mapstructure:"tracing_otlp_protocol" yaml:"tracing_otlp_protocol,omitempty"`
|
||||
TracingSampleRate *float64 `mapstructure:"tracing_sample_rate" yaml:"tracing_sample_rate,omitempty"`
|
||||
TracingProvider string `mapstructure:"tracing_provider" yaml:"tracing_provider,omitempty"`
|
||||
TracingOTLPEndpoint string `mapstructure:"tracing_otlp_endpoint" yaml:"tracing_otlp_endpoint,omitempty"`
|
||||
TracingOTLPProtocol string `mapstructure:"tracing_otlp_protocol" yaml:"tracing_otlp_protocol,omitempty"`
|
||||
|
||||
// Deprecated: this field is ignored.
|
||||
// Configure tracing using the OTLP options or environment variables.
|
||||
|
@ -313,7 +313,6 @@ var defaultOptions = Options{
|
|||
GRPCAddr: ":443",
|
||||
GRPCClientTimeout: 10 * time.Second, // Try to withstand transient service failures for a single request
|
||||
AuthenticateCallbackPath: "/oauth2/callback",
|
||||
TracingSampleRate: 0.0001,
|
||||
|
||||
AutocertOptions: AutocertOptions{
|
||||
Folder: dataDir(),
|
||||
|
@ -1518,7 +1517,7 @@ func (o *Options) ApplySettings(ctx context.Context, certsIndex *cryptutil.Certi
|
|||
set(&o.TracingProvider, settings.TracingProvider)
|
||||
set(&o.TracingOTLPEndpoint, settings.TracingOtlpEndpoint)
|
||||
set(&o.TracingOTLPProtocol, settings.TracingOtlpProtocol)
|
||||
set(&o.TracingSampleRate, settings.TracingSampleRate)
|
||||
setOptional(&o.TracingSampleRate, settings.TracingSampleRate)
|
||||
set(&o.TracingDatadogAddress, settings.TracingDatadogAddress)
|
||||
set(&o.TracingJaegerCollectorEndpoint, settings.TracingJaegerCollectorEndpoint)
|
||||
set(&o.TracingJaegerAgentEndpoint, settings.TracingJaegerAgentEndpoint)
|
||||
|
@ -1608,7 +1607,7 @@ func (o *Options) ToProto() *config.Config {
|
|||
settings.MetricsCertificate = toCertificateOrFromFile(o.MetricsCertificate, o.MetricsCertificateKey, o.MetricsCertificateFile, o.MetricsCertificateKeyFile)
|
||||
copySrcToOptionalDest(&settings.MetricsClientCa, valueOrFromFileBase64(o.MetricsClientCA, o.MetricsClientCAFile))
|
||||
copySrcToOptionalDest(&settings.TracingProvider, &o.TracingProvider)
|
||||
copySrcToOptionalDest(&settings.TracingSampleRate, &o.TracingSampleRate)
|
||||
settings.TracingSampleRate = o.TracingSampleRate
|
||||
copySrcToOptionalDest(&settings.TracingOtlpEndpoint, &o.TracingOTLPEndpoint)
|
||||
copySrcToOptionalDest(&settings.TracingOtlpProtocol, &o.TracingOTLPProtocol)
|
||||
copySrcToOptionalDest(&settings.TracingDatadogAddress, &o.TracingDatadogAddress)
|
||||
|
|
|
@ -599,7 +599,6 @@ func (e *environment) Start() {
|
|||
log.AccessLogFieldUserAgent,
|
||||
log.AccessLogFieldClientCertificate,
|
||||
}
|
||||
cfg.Options.TracingSampleRate = 1.0
|
||||
|
||||
e.src = &configSource{cfg: cfg}
|
||||
e.AddTask(TaskFunc(func(ctx context.Context) error {
|
||||
|
|
|
@ -193,7 +193,8 @@ func (s *SamplingTestSuite) SetupTest() {
|
|||
s.notSampled.Store(0)
|
||||
|
||||
s.env.Add(testenv.ModifierFunc(func(_ context.Context, cfg *config.Config) {
|
||||
cfg.Options.TracingSampleRate = 0.5
|
||||
half := 0.5
|
||||
cfg.Options.TracingSampleRate = &half
|
||||
}))
|
||||
s.env.Add(scenarios.NewIDP([]*scenarios.User{
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue