Skip to content

Commit

Permalink
sanitize generated river identifiers (#6699)
Browse files Browse the repository at this point in the history
Signed-off-by: erikbaranowski <[email protected]>
  • Loading branch information
erikbaranowski authored Mar 14, 2024
1 parent 18866da commit c5131aa
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
4 changes: 3 additions & 1 deletion internal/converter/internal/otelcolconvert/converter.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"strings"

"github.com/grafana/agent/internal/converter/diag"
"github.com/grafana/agent/internal/converter/internal/common"
"github.com/grafana/river/token/builder"
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/otelcol"
Expand Down Expand Up @@ -130,7 +131,8 @@ func (state *state) flowLabelForComponent(c component.InstanceID) string {
if componentName == "" {
componentName = defaultLabel
}
return fmt.Sprintf("%s_%s", groupName, componentName)
identifier := fmt.Sprintf("%s_%s", groupName, componentName)
return common.SanitizeIdentifierPanics(identifier)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,18 @@ otelcol.connector.spanmetrics "default" {
}
}

otelcol.exporter.otlp "foo_metrics_backend_two" {
otelcol.exporter.otlp "_2_metrics_backend_2" {
client {
endpoint = "database:54317"
}
}

otelcol.connector.spanmetrics "foo_default" {
otelcol.connector.spanmetrics "_2_default" {
histogram {
explicit { }
}

output {
metrics = [otelcol.exporter.otlp.foo_metrics_backend_two.input]
metrics = [otelcol.exporter.otlp._2_metrics_backend_2.input]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ exporters:
sending_queue:
queue_size: 5000

otlp/metrics_backend_two:
otlp/metrics_backend/2:
# Our defaults have drifted from upstream, so we explicitly set our
# defaults below (balancer_name and queue_size).
endpoint: database:54317
Expand All @@ -42,7 +42,7 @@ service:
metrics:
receivers: [spanmetrics]
exporters: [otlp/metrics_backend]
metrics/foo:
metrics/2:
receivers: [spanmetrics]
exporters: [otlp/metrics_backend_two]
exporters: [otlp/metrics_backend/2]

0 comments on commit c5131aa

Please sign in to comment.