Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[exporter/awsemf] Fix possible panic when using stdout output_destina…
…tion (#26250) **Description:** It is possible for the awsemf exporter to panic when using the `awsemf.output_destination:stdout` configuration option. I was not able to replicate this in the unit tests. I tried several different metric setups but was not able to find a configuration that caused the translations to to result in a nil message body. After reviewing the translation code I found one possible area where an error was not being returned and a nil `cwlogs.Event` object was returned. I have updated that function signature to return an error in the case where a json marshal error occurs also. **Link to tracking Issue:** none. See stack trace below ``` 2023-08-25 16:00:06 panic: runtime error: invalid memory address or nil pointer dereference 2023-08-25 16:00:06 [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x13765d7] 2023-08-25 16:00:06 2023-08-25 16:00:06 goroutine 74 [running]: 2023-08-25 16:00:06 github.com/open-telemetry/opentelemetry-collector-contrib/exporter/awsemfexporter.(*emfExporter).pushMetricsData(0xc000e50000, {0xc00061d4b0?, 0x53794a?}, {0x4de5a20?}) 2023-08-25 16:00:06 github.com/open-telemetry/opentelemetry-collector-contrib/exporter/awsemfexporter@v0.82.0/emf_exporter.go:108 +0x417 2023-08-25 16:00:06 go.opentelemetry.io/collector/exporter/exporterhelper.(*metricsRequest).Export(0x4de5a20?, {0x4de59e8?, 0xc00089fb90?}) 2023-08-25 16:00:06 go.opentelemetry.io/collector/exporter@v0.82.0/exporterhelper/metrics.go:54 +0x34 2023-08-25 16:00:06 go.opentelemetry.io/collector/exporter/exporterhelper.(*timeoutSender).send(0xc0008ea428, {0x4df9778, 0xc00089fa40}) 2023-08-25 16:00:06 go.opentelemetry.io/collector/exporter@v0.82.0/exporterhelper/common.go:197 +0x96 2023-08-25 16:00:06 go.opentelemetry.io/collector/exporter/exporterhelper.(*retrySender).send(0xc0007ee640, {0x4df9778?, 0xc00089fa40?}) 2023-08-25 16:00:06 go.opentelemetry.io/collector/exporter@v0.82.0/exporterhelper/queued_retry.go:355 +0x190 2023-08-25 16:00:06 go.opentelemetry.io/collector/exporter/exporterhelper.(*metricsSenderWithObservability).send(0xc000ae50c8, {0x4df9778, 0xc00089fa40}) 2023-08-25 16:00:06 go.opentelemetry.io/collector/exporter@v0.82.0/exporterhelper/metrics.go:125 +0x88 2023-08-25 16:00:06 go.opentelemetry.io/collector/exporter/exporterhelper.(*queuedRetrySender).send(0xc000315880, {0x4df9778, 0xc00089fa40}) 2023-08-25 16:00:06 go.opentelemetry.io/collector/exporter@v0.82.0/exporterhelper/queued_retry.go:291 +0x44c 2023-08-25 16:00:06 go.opentelemetry.io/collector/exporter/exporterhelper.NewMetricsExporter.func2({0x4de5a20?, 0xc000e4a5a0}, {0xc000118570?}) 2023-08-25 16:00:06 go.opentelemetry.io/collector/exporter@v0.82.0/exporterhelper/metrics.go:105 +0xca 2023-08-25 16:00:06 go.opentelemetry.io/collector/consumer.ConsumeMetricsFunc.ConsumeMetrics(...) 2023-08-25 16:00:06 go.opentelemetry.io/collector/consumer@v0.82.0/metrics.go:25 2023-08-25 16:00:06 go.opentelemetry.io/collector/internal/fanoutconsumer.(*metricsConsumer).ConsumeMetrics(0xc000e4a4e0, {0x4de5a20, 0xc000e4a5a0}, {0x0?}) 2023-08-25 16:00:06 go.opentelemetry.io/collector@v0.82.0/internal/fanoutconsumer/metrics.go:69 +0x147 2023-08-25 16:00:06 go.opentelemetry.io/collector/processor/batchprocessor.(*batchMetrics).export(0xc000e4a5d0, {0x4de5a20, 0xc000e4a5a0}, 0x2?, 0x1) 2023-08-25 16:00:06 go.opentelemetry.io/collector/processor/batchprocessor@v0.82.0/batch_processor.go:442 +0x117 2023-08-25 16:00:06 go.opentelemetry.io/collector/processor/batchprocessor.(*shard).sendItems(0xc000e50480, 0xc00011873c?) 2023-08-25 16:00:06 go.opentelemetry.io/collector/processor/batchprocessor@v0.82.0/batch_processor.go:256 +0x5f 2023-08-25 16:00:06 go.opentelemetry.io/collector/processor/batchprocessor.(*shard).start(0xc000e50480) 2023-08-25 16:00:06 go.opentelemetry.io/collector/processor/batchprocessor@v0.82.0/batch_processor.go:218 +0x1bc 2023-08-25 16:00:06 created by go.opentelemetry.io/collector/processor/batchprocessor.(*batchProcessor).newShard 2023-08-25 16:00:06 go.opentelemetry.io/collector/processor/batchprocessor@v0.82.0/batch_processor.go:160 +0x1cb ```
- Loading branch information