Open grandwizard28 opened 2 months ago
What's your pipeline looking like, as in, what processors and exporters did you use after this receiver?
The logs pipeline looks like this:
logs:
receivers: [otlp, customreceiver]
processors: [batch]
exporters: [kafkaexporter]
I have a hunch that doing the below:
logs, err := receiver.parser.Parse(body)
if err != nil {
writeError(w, err, http.StatusBadRequest)
return
}
numLogs := logs.LogRecordCount()
// At this point, the receiver has accepted the payload
ctx := receiver.obsreport.StartLogsOp(req.Context())
err = receiver.nextConsumer.ConsumeLogs(ctx, logs)
receiver.obsreport.EndLogsOp(ctx, metadata.Type.String(), numLogs, err)
will fix the issue. This is basically how it's being done in the otlpreceiver.
That will fix your issue, for sure.
This fixed it @atoulme. Do you think we can make a point somewhere in the documentation for this?
Looks like a relatively common issue, as shown in https://github.com/open-telemetry/opentelemetry-collector-contrib/pull/29274. It would be good to document this somewhere.
Describe the bug On calling LogRecordCount() after Consume in a receiver, the receiver seems to panic and throw a nil pointer error. A redacted version of the receiver looks like this:
The redacted stack trace looks like this:
Steps to reproduce The error is happening at every throughput. [Close to 60K log records]
What did you expect to see? Panic not to happen
What did you see instead? Panic
What version did you use?
Additional context https://github.com/open-telemetry/opentelemetry-collector/pull/10402