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

[exporter/prometheusremotewrite] Collector crashes while Scraping Histogram Metrics #12777

Closed
ramyasree0299 opened this issue Jul 29, 2022 · 5 comments · Fixed by #12854
Closed
Assignees
Labels

Comments

@ramyasree0299
Copy link

ramyasree0299 commented Jul 29, 2022

Describe the bug
I'm running Opentelemetry collector contrib v0.56.0 Windows Amd64 binary with OTLP Receiver in Windows machine and have a client application in Spring boot v2.6.9 using Micrometer Registry OTLP v1.9.2 to publish metrics to collector binary in OTLP Format. But as soon as client application starts publishing the metrics, the collector Crashes.
Related to #7149

Steps to reproduce

  1. Start otel collector binary with provided config below.
  2. From https://start.spring.io/ start a new Spring boot project with v2.6.9 and add below micrometer Dependency
    <dependency>
      <groupId>io.micrometer</groupId>
      <artifactId>micrometer-registry-otlp</artifactId>
      <version>1.9.2</version>
    </dependency>
  1. Create a OTLPMeterRegistry Bean to start exposing the metrics in OTLP format and start the application.(The collector publish endpoint will be default i.e; http://localhost:4318/v1/metrics)
    @Bean
    public OtlpMeterRegistry otlpMeterRegistry(){
        return new OtlpMeterRegistry();
    }

What did you expect to see?
Metrics to be remote written to the specified remote write endpoint.

What did you see instead?
Collector crashes with below exception

panic: runtime error: index out of range [-1]

goroutine 138 [running]:
go.opentelemetry.io/collector/pdata/internal.ImmutableUInt64Slice.At(...)
        go.opentelemetry.io/collector/pdata@v0.56.0/internal/generated_immutable_slice.go:125
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/prometheusremotewrite.addSingleHistogramDataPoint({0xc0002df6d8?}, {0x4591ed?}, {0xc000b3acc0?}, {{0x0?, 0x40e2c5?}, 0xc000285aa0?}, 0x50?)
        github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/prometheusremotewrite@v0.56.0/helper.go:346 +0xf65
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/prometheusremotewrite.FromMetrics({0x9?}, {{0x0?, 0xb3ebe1c?}, 0xc000285aa0?})
        github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/prometheusremotewrite@v0.56.0/metrics_to_prw.go:88 +0x74a
github.com/open-telemetry/opentelemetry-collector-contrib/exporter/prometheusremotewriteexporter.(*prwExporter).PushMetrics(0xc000147b90, {0x6179b98, 0xc000b41080}, {0x6179bd0?})
        github.com/open-telemetry/opentelemetry-collector-contrib/exporter/prometheusremotewriteexporter@v0.56.0/exporter.go:137 +0xd3
go.opentelemetry.io/collector/exporter/exporterhelper.(*metricsRequest).export(0x6179bd0?, {0x6179b98?, 0xc000b41080?})
        go.opentelemetry.io/collector@v0.56.0/exporter/exporterhelper/metrics.go:65 +0x34
go.opentelemetry.io/collector/exporter/exporterhelper.(*timeoutSender).send(0xc000462750, {0x618ecf0, 0xc0001624e0})
        go.opentelemetry.io/collector@v0.56.0/exporter/exporterhelper/common.go:225 +0x96
go.opentelemetry.io/collector/exporter/exporterhelper.(*retrySender).send(0xc000147c20, {0x618ecf0, 0xc0001624e0})
        go.opentelemetry.io/collector@v0.56.0/exporter/exporterhelper/queued_retry.go:176 +0x556
go.opentelemetry.io/collector/exporter/exporterhelper.(*metricsSenderWithObservability).send(0xc001018450, {0x618ecf0, 0xc0001624e0})
        go.opentelemetry.io/collector@v0.56.0/exporter/exporterhelper/metrics.go:132 +0x88
go.opentelemetry.io/collector/exporter/exporterhelper.(*queuedRetrySender).start.func1({0x51e46e0?, 0xc0001624e0})
        go.opentelemetry.io/collector@v0.56.0/exporter/exporterhelper/queued_retry_inmemory.go:119 +0x5c
go.opentelemetry.io/collector/exporter/exporterhelper/internal.consumerFunc.consume(0xc0003a7200?, {0x51e46e0?, 0xc0001624e0?})
        go.opentelemetry.io/collector@v0.56.0/exporter/exporterhelper/internal/bounded_memory_queue.go:82 +0x2c
go.opentelemetry.io/collector/exporter/exporterhelper/internal.(*boundedMemoryQueue).StartConsumers.func2()
        go.opentelemetry.io/collector@v0.56.0/exporter/exporterhelper/internal/bounded_memory_queue.go:69 +0xcd
created by go.opentelemetry.io/collector/exporter/exporterhelper/internal.(*boundedMemoryQueue).StartConsumers
        go.opentelemetry.io/collector@v0.56.0/exporter/exporterhelper/internal/bounded_memory_queue.go:63 +0x98

What version did you use?
Version: 0.56.0

What config did you use?
Config:

receivers:
  otlp:
    protocols:
      grpc:
      http:
  zipkin:

exporters:
  prometheusremotewrite:
    endpoint: "https://remotewriteurl"
  jaeger:
    endpoint: "some.jaeger.endpoint"
  prometheus:
    endpoint: "127.0.0.1:9091"
  file:
    path: otel-logs.txt

processors:
  batch:

extensions:
  health_check:
  pprof:
  zpages:

service:
  extensions: [ pprof, zpages, health_check ]
  pipelines:
    metrics:
      receivers: [ otlp ]
      exporters: [ prometheus, file, prometheusremotewrite ]
    traces:
      receivers: [ otlp,zipkin ]
      exporters: [ jaeger, file ]
  telemetry:
    logs:
      level: "debug"

Environment
OS: Windows

@github-actions
Copy link
Contributor

Pinging code owners: @Aneurysm9. See Adding Labels via Comments if you do not have permissions to add labels yourself.

@codeboten
Copy link
Contributor

Pinging @dashpole @bertysentry as well as owners of the translator

@bertysentry
Copy link
Contributor

This is the offending code in function addSingleHistogramDataPoint() in /pkg/translator/prometheusremotewrite/helper.go:

	// add le=+Inf bucket
	infBucket := &prompb.Sample{
		Timestamp: time,
	}
	if pt.Flags().HasFlag(pmetric.MetricDataPointFlagNoRecordedValue) {
		infBucket.Value = math.Float64frombits(value.StaleNaN)
	} else {
		cumulativeCount += pt.BucketCounts().At(pt.BucketCounts().Len() - 1) // panic: runtime error: index out of range [-1]
		infBucket.Value = float64(cumulativeCount)
	}

This part of the code is out of my scope of expertise, I'm sorry! @Aneurysm9 @dmitryax Any idea?

@dashpole dashpole self-assigned this Aug 1, 2022
@dashpole
Copy link
Contributor

dashpole commented Aug 1, 2022

Looks like it can panic on histograms without any buckets

@dashpole
Copy link
Contributor

dashpole commented Aug 1, 2022

Fix: #12854

gouthamve added a commit to grafana/mimir that referenced this issue Jan 4, 2023
We were running into open-telemetry/opentelemetry-collector-contrib#12777
This was fixed by open-telemetry/opentelemetry-collector-contrib#12854
which was released in v0.57.2 which this upgrades to.

Ideally #3852 should be merged but
its a big PR, hence also sending this to make sure merging is quicker.

Signed-off-by: Goutham Veeramachaneni <gouthamve@gmail.com>
johannaratliff pushed a commit to grafana/mimir that referenced this issue Jan 4, 2023
grafanabot pushed a commit to grafana/mimir that referenced this issue Jan 5, 2023
We were running into open-telemetry/opentelemetry-collector-contrib#12777
This was fixed by open-telemetry/opentelemetry-collector-contrib#12854
which was released in v0.57.2 which this upgrades to.

(cherry picked from commit bed543c)
grafanabot pushed a commit to grafana/mimir that referenced this issue Jan 5, 2023
We were running into open-telemetry/opentelemetry-collector-contrib#12777
This was fixed by open-telemetry/opentelemetry-collector-contrib#12854
which was released in v0.57.2 which this upgrades to.

(cherry picked from commit bed543c)
colega pushed a commit to grafana/mimir that referenced this issue Jan 5, 2023
We were running into open-telemetry/opentelemetry-collector-contrib#12777
This was fixed by open-telemetry/opentelemetry-collector-contrib#12854
which was released in v0.57.2 which this upgrades to.

(cherry picked from commit bed543c)

Co-authored-by: Goutham Veeramachaneni <gouthamve@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
4 participants