Skip to content

Commit

Permalink
feat: implement trace sampling (#356)
Browse files Browse the repository at this point in the history
  • Loading branch information
rbarabas committed Jul 12, 2022
1 parent dcb7f72 commit a7fc79e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
14 changes: 8 additions & 6 deletions server/config/options.go
Expand Up @@ -53,12 +53,13 @@ type CdcConfig struct {
}

type TracingConfig struct {
Enabled bool `mapstructure:"enabled" yaml:"enabled" json:"enabled"`
CodeHotspotsEnabled bool `mapstructure:"codehotspots_enabled" yaml:"codehotspots_enabled" json:"codehotspots_enabled"`
EndpointsEnabled bool `mapstructure:"endpoints_enabled" yaml:"endpoints_enabled" json:"endpoints_enabled"`
WithUDS string `mapstructure:"agent_socket" yaml:"agent_socket" json:"agent_socket"`
WithAgentAddr string `mapstructure:"agent_addr" yaml:"agent_addr" json:"agent_addr"`
WithDogStatsdAddr string `mapstructure:"dogstatsd_addr" yaml:"dogstatsd_addr" json:"dogstatsd_addr"`
Enabled bool `mapstructure:"enabled" yaml:"enabled" json:"enabled"`
SampleRate float64 `mapstructure:"sample_rate" yaml:"sample_rate" json:"sample_rate"`
CodeHotspotsEnabled bool `mapstructure:"codehotspots_enabled" yaml:"codehotspots_enabled" json:"codehotspots_enabled"`
EndpointsEnabled bool `mapstructure:"endpoints_enabled" yaml:"endpoints_enabled" json:"endpoints_enabled"`
WithUDS string `mapstructure:"agent_socket" yaml:"agent_socket" json:"agent_socket"`
WithAgentAddr string `mapstructure:"agent_addr" yaml:"agent_addr" json:"agent_addr"`
WithDogStatsdAddr string `mapstructure:"dogstatsd_addr" yaml:"dogstatsd_addr" json:"dogstatsd_addr"`
}

type ProfilingConfig struct {
Expand Down Expand Up @@ -119,6 +120,7 @@ var DefaultConfig = Config{
},
Tracing: TracingConfig{
Enabled: false,
SampleRate: 0.01,
CodeHotspotsEnabled: true,
EndpointsEnabled: true,
},
Expand Down
2 changes: 2 additions & 0 deletions server/tracing/tracing.go
Expand Up @@ -9,9 +9,11 @@ import (

func getTracingOptions(c *config.Config) []tracer.StartOption {
var opts []tracer.StartOption
rules := []tracer.SamplingRule{tracer.ServiceRule(util.Service, c.Tracing.SampleRate)}
opts = append(opts, tracer.WithTraceEnabled(c.Tracing.Enabled))
opts = append(opts, tracer.WithProfilerEndpoints(c.Tracing.EndpointsEnabled))
opts = append(opts, tracer.WithProfilerCodeHotspots(c.Tracing.CodeHotspotsEnabled))
opts = append(opts, tracer.WithSamplingRules(rules))
opts = append(opts, tracer.WithService(util.Service))
opts = append(opts, tracer.WithEnv(config.GetEnvironment()))
opts = append(opts, tracer.WithServiceVersion(util.Version))
Expand Down

0 comments on commit a7fc79e

Please sign in to comment.