Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add harcoded namespace to spanmetrics #540

Merged
merged 3 commits into from
Apr 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ cross-compilation issue, but will return in v0.13.0.

- [ENHANCEMENT] Add `headers` field in `remote_write` config for Tempo. `headers`
specifies HTTP headers to forward to the remote endpoint. (@alexbiehl)
- [CHANGE] Add `tempo_spanmetrics` namespace in spanmetrics (@mapno)

# v0.13.1 (2021-04-09)

Expand Down
2 changes: 2 additions & 0 deletions docs/configuration-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -2074,6 +2074,8 @@ spanmetrics:
metrics_exporter:
[ endpoint: <prometheusexporter.endpoint> ]
[ const_labels: <prometheusexporter.const_labels> ]
# Metrics are namespaced to `tempo_spanmetrics` by default.
# They can be further namespaced, i.e. `{namespace}_tempo_spanmetrics`
[ namespace: <prometheusexporter.namespace> ]
[ send_timestamps: <prometheusexporter.send_timestamps> ]
```
Expand Down
28 changes: 25 additions & 3 deletions pkg/tempo/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,20 @@ type SpanMetricsConfig struct {
LatencyHistogramBuckets []time.Duration `yaml:"latency_histogram_buckets,omitempty"`
Dimensions []spanmetricsprocessor.Dimension `yaml:"dimensions,omitempty"`

// Configuration for Prometheus exporter: https://github.com/open-telemetry/opentelemetry-collector/blob/7d7ae2eb34/exporter/prometheusexporter/README.md.
MetricsExporter map[string]interface{} `yaml:"metrics_exporter,omitempty"`
// MetricsExporter is a Prometheus metrics exporter
MetricsExporter metricsExporterConfig `yaml:"metrics_exporter,omitempty"`
}

// Configuration for Prometheus exporter: https://github.com/open-telemetry/opentelemetry-collector/blob/7d7ae2eb34/exporter/prometheusexporter/README.md.
type metricsExporterConfig struct {
// The address on which the Prometheus scrape handler will be run on.
Endpoint string `yaml:"endpoint"`
// Namespace if set, exports metrics under the provided value.
Namespace string `yaml:"namespace"`
// ConstLabels are values that are applied for every exported metric.
ConstLabels map[string]interface{} `yaml:"const_labels"`
// SendTimestamps will send the underlying scrape timestamp with the export
SendTimestamps bool `yaml:"send_timestamps"`
}

// exporter builds an OTel exporter from RemoteWriteConfig
Expand Down Expand Up @@ -300,7 +312,17 @@ func (c *InstanceConfig) otelConfig() (*configmodels.Config, error) {

if c.SpanMetrics != nil {
// Configure the metrics exporter.
exporters[defaultSpanMetricsExporter] = c.SpanMetrics.MetricsExporter
namespace := "tempo_spanmetrics"
if len(c.SpanMetrics.MetricsExporter.Namespace) != 0 {
namespace = fmt.Sprintf("%s_%s", c.SpanMetrics.MetricsExporter.Namespace, namespace)
}

exporters[defaultSpanMetricsExporter] = map[string]interface{}{
"endpoint": c.SpanMetrics.MetricsExporter.Endpoint,
"namespace": namespace,
"const_labels": c.SpanMetrics.MetricsExporter.ConstLabels,
"send_timestamps": c.SpanMetrics.MetricsExporter.SendTimestamps,
}

processorNames = append(processorNames, "spanmetrics")
processors["spanmetrics"] = map[string]interface{}{
Expand Down
2 changes: 1 addition & 1 deletion pkg/tempo/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ exporters:
max_elapsed_time: 60s
prometheus:
endpoint: "0.0.0.0:8889"
namespace: promexample
namespace: promexample_tempo_spanmetrics
processors:
spanmetrics:
metrics_exporter: prometheus
Expand Down