mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Tracing: Improve HTTP request/middleware spans and standalone apiserver (#85715)
Fixes so that auth middleware trace/span doesn't wrap the next handlers. Allow tracing service name to be overridden in standalone apiserver. Change k8s api tracing operation name to KubernetesAPI from grafana-apiserver (which is the service name)
This commit is contained in:
committed by
GitHub
parent
877aaf87d2
commit
3e385763c5
@@ -26,7 +26,8 @@ type TracingOptions struct {
|
||||
OTLPAddress string
|
||||
OTLPPropagation string
|
||||
|
||||
Tags map[string]string
|
||||
ServiceName string
|
||||
Tags map[string]string
|
||||
|
||||
SamplerType string
|
||||
SamplerParam float64
|
||||
@@ -47,6 +48,7 @@ func (o *TracingOptions) AddFlags(fs *pflag.FlagSet) {
|
||||
fs.StringVar(&o.JaegerPropagation, "grafana.tracing.jaeger.propagation", "jaeger", "Tracing Jaeger propagation specifies the text map propagation format, w3c or jaeger.")
|
||||
fs.StringVar(&o.OTLPAddress, "grafana.tracing.otlp.address", "", "Tracing OTLP exporter destination, e.g. localhost:4317.")
|
||||
fs.StringVar(&o.OTLPPropagation, "grafana.tracing.otlp.propagation", "w3c", "Tracing OTLP propagation specifies the text map propagation format, w3c or jaeger.")
|
||||
fs.StringVar(&o.ServiceName, "grafana.tracing.service-name", "grafana-apiserver", "Override the default service name, grafana-apiserver.")
|
||||
fs.StringToStringVar(&o.Tags, "grafana.tracing.tag", map[string]string{}, "Tracing server tag in 'key=value' format. Specify multiple times to add many.")
|
||||
fs.StringVar(&o.SamplerType, "grafana.tracing.sampler-type", "const", "Tracing sampler type specifies the type of the sampler: const, probabilistic, rateLimiting, or remote.")
|
||||
fs.Float64Var(&o.SamplerParam, "grafana.tracing.sampler-param", 0, "Tracing sampler configuration parameter. For 'const' sampler, 0 or 1 for always false/true respectively. For 'rateLimiting' sampler, the number of spans per second. For 'remote' sampler, param is the same as for 'probabilistic' and indicates the initial sampling rate before the actual one is received from the sampling service.")
|
||||
@@ -54,21 +56,25 @@ func (o *TracingOptions) AddFlags(fs *pflag.FlagSet) {
|
||||
}
|
||||
|
||||
func (o *TracingOptions) Validate() []error {
|
||||
errors := []error{}
|
||||
errs := []error{}
|
||||
|
||||
if o.JaegerAddress != "" {
|
||||
if _, err := url.Parse(o.JaegerAddress); err != nil {
|
||||
errors = append(errors, fmt.Errorf("failed to parse tracing.jaeger.address: %w", err))
|
||||
errs = append(errs, fmt.Errorf("failed to parse tracing.jaeger.address: %w", err))
|
||||
}
|
||||
}
|
||||
|
||||
if o.SamplingServiceURL != "" {
|
||||
if _, err := url.Parse(o.SamplingServiceURL); err != nil {
|
||||
errors = append(errors, fmt.Errorf("failed to parse tracing.sampling-service: %w", err))
|
||||
errs = append(errs, fmt.Errorf("failed to parse tracing.sampling-service: %w", err))
|
||||
}
|
||||
}
|
||||
|
||||
return errors
|
||||
if o.ServiceName == "" {
|
||||
errs = append(errs, errors.New("grafana.tracing.service-name cannot be empty"))
|
||||
}
|
||||
|
||||
return errs
|
||||
}
|
||||
|
||||
func (o *TracingOptions) ApplyTo(config *genericapiserver.RecommendedConfig) error {
|
||||
@@ -93,7 +99,7 @@ func (o *TracingOptions) ApplyTo(config *genericapiserver.RecommendedConfig) err
|
||||
return err
|
||||
}
|
||||
|
||||
tracingCfg.ServiceName = "grafana-apiserver"
|
||||
tracingCfg.ServiceName = o.ServiceName
|
||||
tracingCfg.ServiceVersion = setting.BuildVersion
|
||||
|
||||
for k, v := range o.Tags {
|
||||
|
||||
Reference in New Issue
Block a user