Skip to content

Commit

Permalink
Move exporter to its own block
Browse files Browse the repository at this point in the history
  • Loading branch information
mapno committed Apr 13, 2021
1 parent afeafa5 commit 6ca6e3e
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 43 deletions.
36 changes: 18 additions & 18 deletions docs/configuration-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -2104,24 +2104,24 @@ tail_sampling:

# Load balancing is done via an otlp exporter.
# The remaining configuration is common with the remote_write block.

# Controls whether compression is enabled.
[ compression: <string> | default = "gzip" | supported = "none", "gzip"]

# Controls whether or not TLS is required. See https://godoc.org/google.golang.org/grpc#WithInsecure
[ insecure: <boolean> | default = false ]

# Disable validation of the server certificate. Only used when insecure is set
# to false.
[ insecure_skip_verify: <bool> | default = false ]

# Sets the `Authorization` header on every trace push with the
# configured username and password.
# password and password_file are mutually exclusive.
basic_auth:
[ username: <string> ]
[ password: <secret> ]
[ password_file: <string> ]
exporter:
# Controls whether compression is enabled.
[ compression: <string> | default = "gzip" | supported = "none", "gzip"]
# Controls whether or not TLS is required. See https://godoc.org/google.golang.org/grpc#WithInsecure
[ insecure: <boolean> | default = false ]
# Disable validation of the server certificate. Only used when insecure is set
# to false.
[ insecure_skip_verify: <bool> | default = false ]
# Sets the `Authorization` header on every trace push with the
# configured username and password.
# password and password_file are mutually exclusive.
basic_auth:
[ username: <string> ]
[ password: <secret> ]
[ password_file: <string> ]

```

Expand Down
14 changes: 6 additions & 8 deletions example/docker-compose/agent/config/agent-scraping-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,31 +34,29 @@ tempo:
key: env
value: prod
remote_write:
- endpoint: tempo:4317
insecure: true
- endpoint: otel-collector:55680
insecure: true
batch:
timeout: 5s
send_batch_size: 100
tail_sampling:
policies:
- name: policy-1
type: always_sample
- always_sample:
# Enter more policies to sample traces (ref: https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/processor/tailsamplingprocessor)
# Example of rate limiting policy. Uncomment to start rate limiting!
# - name: policy-2
# type: rate_limiting
# rate_limiting:
# - spans_per_second: 35
load_balancing:
insecure: true
exporter:
insecure: true
resolver:
static:
hostnames:
- agent-1:9999
- agent-2:9999
- agent-3:9999
- agent-1:4318
- agent-2:4318
- agent-3:4318
spanmetrics:
dimensions:
- name: http.url
Expand Down
8 changes: 8 additions & 0 deletions example/docker-compose/docker-compose.scraping-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,11 @@ services:
- JAEGER_COLLECTOR_URL=http://agent-1:14268
depends_on:
- agent-1

# tracing backend
otel-collector:
image: otel/opentelemetry-collector:0.9.0
volumes:
- ./otel-collector:/etc/otel-collector
command:
- --config=/etc/otel-collector/config.yaml
31 changes: 18 additions & 13 deletions pkg/tempo/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const (
defaultDecisionWait = time.Second * 5

// defaultLoadBalancingPort is the default port the agent uses for internal load balancing
defaultLoadBalancingPort = "9999"
defaultLoadBalancingPort = "4318"
// agent's load balancing options
dnsTagName = "dns"
staticTagName = "static"
Expand Down Expand Up @@ -105,7 +105,7 @@ type InstanceConfig struct {
SpanMetrics *SpanMetricsConfig `yaml:"spanmetrics,omitempty"`

// TailSampling defines a sampling strategy for the pipeline
TailSampling *TailSamplingConfig `yaml:"tail_sampling"`
TailSampling *tailSamplingConfig `yaml:"tail_sampling"`
}

const (
Expand Down Expand Up @@ -185,8 +185,8 @@ type SpanMetricsConfig struct {
MetricsExporter map[string]interface{} `yaml:"metrics_exporter,omitempty"`
}

// TailSamplingConfig is the configuration for tail-based sampling
type TailSamplingConfig struct {
// tailSamplingConfig is the configuration for tail-based sampling
type tailSamplingConfig struct {
// Policies are the strategies used for sampling. Multiple policies can be used in the same pipeline.
// For more information, refer to https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/processor/tailsamplingprocessor
Policies []map[string]interface{} `yaml:"policies"`
Expand All @@ -195,17 +195,22 @@ type TailSamplingConfig struct {
// Port is the port the instance will use to receive load balanced traces
Port string `yaml:"port"`
// LoadBalancing is used to distribute spans of the same trace to the same agent instance
LoadBalancing loadBalancingConfig `yaml:"load_balancing"`
LoadBalancing *loadBalancingConfig `yaml:"load_balancing"`
}

// loadBalancingConfig defines the configuration for load balancing spans between agent instances
// loadBalancingConfig is an OTel exporter's config with extra resolver config
type loadBalancingConfig struct {
Exporter exporterConfig `yaml:"exporter"`
Resolver map[string]interface{} `yaml:"resolver"`
}

// exporterConfig defined the config for a otlp exporter for load balancing
type exporterConfig struct {
Compression string `yaml:"compression,omitempty"`
Insecure bool `yaml:"insecure,omitempty"`
InsecureSkipVerify bool `yaml:"insecure_skip_verify,omitempty"`
BasicAuth *prom_config.BasicAuth `yaml:"basic_auth,omitempty"`
Resolver map[string]interface{} `yaml:"resolver"`
}

// exporter builds an OTel exporter from RemoteWriteConfig
Expand Down Expand Up @@ -312,10 +317,10 @@ func (c *InstanceConfig) loadBalancingExporter() (map[string]interface{}, error)
exporter, err := exporter(RemoteWriteConfig{
// Endpoint is omitted in OTel load balancing exporter
Endpoint: "noop",
Compression: c.TailSampling.LoadBalancing.Compression,
Insecure: c.TailSampling.LoadBalancing.Insecure,
InsecureSkipVerify: c.TailSampling.LoadBalancing.InsecureSkipVerify,
BasicAuth: c.TailSampling.LoadBalancing.BasicAuth,
Compression: c.TailSampling.LoadBalancing.Exporter.Compression,
Insecure: c.TailSampling.LoadBalancing.Exporter.Insecure,
InsecureSkipVerify: c.TailSampling.LoadBalancing.Exporter.InsecureSkipVerify,
BasicAuth: c.TailSampling.LoadBalancing.Exporter.BasicAuth,
})
if err != nil {
return nil, err
Expand Down Expand Up @@ -409,7 +414,7 @@ func (c *InstanceConfig) otelConfig() (*configmodels.Config, error) {
}

if c.SpanMetrics != nil {
// Configure the metrics exporter.
// Configure the metrics Exporter.
exporters[defaultSpanMetricsExporter] = c.SpanMetrics.MetricsExporter

processorNames = append(processorNames, "spanmetrics")
Expand Down Expand Up @@ -445,7 +450,7 @@ func (c *InstanceConfig) otelConfig() (*configmodels.Config, error) {
"decision_wait": wait,
}

if c.TailSampling.LoadBalancing.Resolver != nil {
if c.TailSampling.LoadBalancing != nil {
internalExporter, err := c.loadBalancingExporter()
if err != nil {
return nil, err
Expand All @@ -467,7 +472,7 @@ func (c *InstanceConfig) otelConfig() (*configmodels.Config, error) {
}

pipelines := make(map[string]interface{})
if c.TailSampling != nil && c.TailSampling.LoadBalancing.Resolver != nil {
if c.TailSampling != nil && c.TailSampling.LoadBalancing != nil {
// load balancing pipeline
pipelines["traces/0"] = map[string]interface{}{
"receivers": receiverNames,
Expand Down
9 changes: 5 additions & 4 deletions pkg/tempo/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -549,11 +549,12 @@ tail_sampling:
- value1
- value2
load_balancing:
insecure: true
exporter:
insecure: true
resolver:
dns:
hostname: agent
port: 9999
port: 4318
`,
expectedConfig: `
receivers:
Expand All @@ -563,7 +564,7 @@ receivers:
otlp/lb:
protocols:
grpc:
endpoint: "0.0.0.0:9999"
endpoint: "0.0.0.0:4318"
exporters:
otlp/0:
endpoint: example.com:12345
Expand All @@ -580,7 +581,7 @@ exporters:
resolver:
dns:
hostname: agent
port: 9999
port: 4318
processors:
tail_sampling:
decision_wait: 5s
Expand Down

0 comments on commit 6ca6e3e

Please sign in to comment.