-
Notifications
You must be signed in to change notification settings - Fork 2k
Description
Describe the bug
When Collector uses prometheusremotewriteexporter, metric names longer than 6 characters cause it to crash
2021-03-03 09:30:54
panic: runtime error: slice bounds out of range [-1:]
2021-03-03 09:30:54
goroutine 97 [running]:
2021-03-03 09:30:54
go.opentelemetry.io/collector/exporter/prometheusremotewriteexporter.getPromMetricName(0xc0003df7c0, 0x0, 0x0, 0x6, 0x6)
Seems to be caused by this logic which checks for "total" at the end of the metric name:
| isCounter = isCounter && name[len(name)-len(totalStr):] != totalStr |
Steps to reproduce
Enable Prometheus Remote Write exporter, send OTLP metrics to collector with names shorter than 6 characters
What version did you use?
Version: 0.16.0
What config did you use?
Config:
extensions:
health_check:
port: 13133
receivers:
otlp:
protocols:
grpc:
endpoint: 0.0.0.0:4317
http:
processors:
batch:
exporters:
logging:
logLevel: warn
prometheusremotewrite:
endpoint: "http://127.0.0.1:9201/write"
service:
pipelines:
traces:
receivers: [otlp]
processors: [batch]
exporters: [logging]
metrics:
receivers: [otlp]
processors: [batch]
exporters: [logging, prometheusremotewrite]
extensions: [health_check]
Environment
OS: alpine:3.12 (Docker)