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/awsemf] Fix possible panic when using stdout output_destination #26250

Merged
merged 9 commits into from
Sep 7, 2023

Conversation

bryan-aguilar
Copy link
Contributor

@bryan-aguilar bryan-aguilar commented Aug 29, 2023

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

@bryan-aguilar bryan-aguilar requested a review from a team August 29, 2023 03:21
@github-actions github-actions bot added the exporter/awsemf awsemf exporter label Aug 29, 2023
@fatsheep9146 fatsheep9146 added the ready to merge Code review completed; ready to merge by maintainers label Aug 30, 2023
@codeboten codeboten merged commit d722dae into open-telemetry:main Sep 7, 2023
90 checks passed
@github-actions github-actions bot added this to the next release milestone Sep 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
exporter/awsemf awsemf exporter ready to merge Code review completed; ready to merge by maintainers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants