Skip to content

[receiver/awslambda] Adopt streaming for AWS Lambda receiver#46608

Merged
atoulme merged 6 commits into
open-telemetry:mainfrom
Kavindu-Dodan:feat/aws-lambda-receiver-stream-support
Mar 12, 2026
Merged

[receiver/awslambda] Adopt streaming for AWS Lambda receiver#46608
atoulme merged 6 commits into
open-telemetry:mainfrom
Kavindu-Dodan:feat/aws-lambda-receiver-stream-support

Conversation

@Kavindu-Dodan

@Kavindu-Dodan Kavindu-Dodan commented Mar 3, 2026

Copy link
Copy Markdown
Contributor

Description

This PR adopts streaming support introduced by AWS encoding extensions (refer #46214 )

This PR adopt streaming by,

  • For S3 triggers, use S3 stream reader so we won't load entire object into memory
  • For CloudWatch triggers, we load entire message into memory however, streaming support is there for batching needs.
  • Utilize xstreamencoding helpers to adopt streaming support for non-streaming extensions
  • To provide consistency and help implementation, default handling behaviour (when no extension is set) is extracted to built-in default decoders.

Above approach allows to use the receiver with a streaming or non-streaming encoding extension.

Testing

Unit tests to validate API contracts changed/added by this PR

Documentation

Updated documents to highlight streaming encoding support

@Kavindu-Dodan Kavindu-Dodan force-pushed the feat/aws-lambda-receiver-stream-support branch 5 times, most recently from 75b0c51 to fc28403 Compare March 3, 2026 22:34

@MichaelKatsoulis MichaelKatsoulis left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @Kavindu-Dodan

Overall your approach looks very good. I just left some suggestions!

One minor concern I have is what if an encoding extension at the top level advertises LogsDecoderExtension but some of the formats (example of awslogs encoding extension) do not support streaming. In that case we will get an error that streaming not supported for format and not a backward compatibility with usage of legacy unmarshaler.
Any way maybe that could be handled best in the encoding extension itself and not in the receiver.

Comment thread receiver/awslambdareceiver/internal/decoder_wrapper.go Outdated
Comment thread receiver/awslambdareceiver/handler.go Outdated
@Kavindu-Dodan Kavindu-Dodan changed the title WIP : Adopt streaming for AWS Lambda receiver [receiver/awslambda] Adopt streaming for AWS Lambda receiver Mar 4, 2026
@Kavindu-Dodan Kavindu-Dodan marked this pull request as ready for review March 4, 2026 21:23
@Kavindu-Dodan Kavindu-Dodan requested review from a team, axw and pjanotti as code owners March 4, 2026 21:23
@Kavindu-Dodan Kavindu-Dodan force-pushed the feat/aws-lambda-receiver-stream-support branch from ef26253 to 66c6900 Compare March 4, 2026 21:25
@Kavindu-Dodan

Kavindu-Dodan commented Mar 4, 2026

Copy link
Copy Markdown
Contributor Author

Thank you @Kavindu-Dodan

Overall your approach looks very good. I just left some suggestions!

One minor concern I have is what if an encoding extension at the top level advertises LogsDecoderExtension but some of the formats (example of awslogs encoding extension) do not support streaming. In that case we will get an error that streaming not supported for format and not a backward compatibility with usage of legacy unmarshaler. Any way maybe that could be handled best in the encoding extension itself and not in the receiver.

Thank you for the review 🤝

I think we cannot do much about sub-formats as they are internal 🤔 (If they expose the Decoder API contract but internally return error as implementation is missing, then those sub-formats will fail to work with the receiver)

However, the adopter layer allows any extension that does not implement the Decoder API to work with receiver.

@MichaelKatsoulis

MichaelKatsoulis commented Mar 5, 2026

Copy link
Copy Markdown
Contributor

@Kavindu-Dodan does it need to be DRAFT ?

Comment thread receiver/awslambdareceiver/receiver.go Outdated
Comment thread receiver/awslambdareceiver/receiver.go

@MichaelKatsoulis MichaelKatsoulis left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks way better

@Kavindu-Dodan Kavindu-Dodan force-pushed the feat/aws-lambda-receiver-stream-support branch 2 times, most recently from a28f271 to 918a544 Compare March 5, 2026 19:49
@Kavindu-Dodan

Copy link
Copy Markdown
Contributor Author

@Kavindu-Dodan does it need to be DRAFT ?

No we do not have to make this a draft. We can merge this if we get approvals

@MichaelKatsoulis MichaelKatsoulis left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks very good to me! I approve it but lets wait for @axw or @pjanotti reviews as well!

@Kavindu-Dodan Kavindu-Dodan force-pushed the feat/aws-lambda-receiver-stream-support branch from 918a544 to a744ae5 Compare March 6, 2026 16:42
Comment thread receiver/awslambdareceiver/internal/decoder_wrapper.go Outdated
Comment thread receiver/awslambdareceiver/internal/default_decoders.go Outdated
Comment thread receiver/awslambdareceiver/handler.go Outdated
Comment thread receiver/awslambdareceiver/handler.go Outdated
Comment thread receiver/awslambdareceiver/README.md Outdated
atoulme pushed a commit that referenced this pull request Mar 9, 2026
#### Description

Introduce adapters for plog.LogsUnmarshaler and
pmetric.MetricsUnmarshaler which, on first call, read the entire stream
into memory and invoke the unmarshaler. Subsequent calls return EOF.

The offset is always the entire stream size in bytes, and if an offset
is provided then that many bytes will discarded first.

We also extract LogsDecoderFactory and MetricsDecoderFactory interfaces
from LogsDecoderExtension and MetricsDecoderExtension in the encoding
package.

This PR was built with the assistance of Cursor.

#### Link to tracking issue

Relates to
#46608

#### Testing

Tests updated

#### Documentation

N/A
@Kavindu-Dodan Kavindu-Dodan force-pushed the feat/aws-lambda-receiver-stream-support branch from a744ae5 to d761fa1 Compare March 9, 2026 18:04
@Kavindu-Dodan Kavindu-Dodan requested a review from axw March 9, 2026 18:09
@Kavindu-Dodan Kavindu-Dodan force-pushed the feat/aws-lambda-receiver-stream-support branch from d761fa1 to 790664e Compare March 9, 2026 18:47
ebrdarSplunk pushed a commit to ebrdarSplunk/opentelemetry-collector-contrib that referenced this pull request Mar 9, 2026
#### Description

Introduce adapters for plog.LogsUnmarshaler and
pmetric.MetricsUnmarshaler which, on first call, read the entire stream
into memory and invoke the unmarshaler. Subsequent calls return EOF.

The offset is always the entire stream size in bytes, and if an offset
is provided then that many bytes will discarded first.

We also extract LogsDecoderFactory and MetricsDecoderFactory interfaces
from LogsDecoderExtension and MetricsDecoderExtension in the encoding
package.

This PR was built with the assistance of Cursor.

#### Link to tracking issue

Relates to
open-telemetry#46608

#### Testing

Tests updated

#### Documentation

N/A
esosaoh pushed a commit to esosaoh/opentelemetry-collector-contrib that referenced this pull request Mar 9, 2026
#### Description

Introduce adapters for plog.LogsUnmarshaler and
pmetric.MetricsUnmarshaler which, on first call, read the entire stream
into memory and invoke the unmarshaler. Subsequent calls return EOF.

The offset is always the entire stream size in bytes, and if an offset
is provided then that many bytes will discarded first.

We also extract LogsDecoderFactory and MetricsDecoderFactory interfaces
from LogsDecoderExtension and MetricsDecoderExtension in the encoding
package.

This PR was built with the assistance of Cursor.

#### Link to tracking issue

Relates to
open-telemetry#46608

#### Testing

Tests updated

#### Documentation

N/A
Comment thread receiver/awslambdareceiver/handler.go Outdated
Comment thread receiver/awslambdareceiver/handler.go Outdated
Comment thread receiver/awslambdareceiver/handler.go Outdated
Comment thread receiver/awslambdareceiver/handler.go Outdated
Comment thread receiver/awslambdareceiver/handler.go Outdated
Comment thread receiver/awslambdareceiver/internal/default_decoders.go
@Kavindu-Dodan Kavindu-Dodan force-pushed the feat/aws-lambda-receiver-stream-support branch from 38734f7 to 6d8c26c Compare March 10, 2026 18:39
@Kavindu-Dodan Kavindu-Dodan requested a review from axw March 10, 2026 18:52

@axw axw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @Kavindu-Dodan, just one last thing and I think it's good to go.

@Kavindu-Dodan Kavindu-Dodan force-pushed the feat/aws-lambda-receiver-stream-support branch from 6d8c26c to 1987919 Compare March 11, 2026 17:26
@Kavindu-Dodan Kavindu-Dodan requested a review from axw March 11, 2026 17:28
@axw axw added the ready to merge Code review completed; ready to merge by maintainers label Mar 12, 2026
@atoulme

atoulme commented Mar 12, 2026

Copy link
Copy Markdown
Contributor

Please resolve conflicts

@atoulme atoulme removed the ready to merge Code review completed; ready to merge by maintainers label Mar 12, 2026
Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>

# Conflicts:
#	receiver/awslambdareceiver/go.mod
#	receiver/awslambdareceiver/go.sum

# Conflicts:
#	receiver/awslambdareceiver/go.mod
#	receiver/awslambdareceiver/go.sum

# Conflicts:
#	receiver/awslambdareceiver/go.sum

# Conflicts:
#	receiver/awslambdareceiver/go.mod
#	receiver/awslambdareceiver/go.sum

# Conflicts:
#	receiver/awslambdareceiver/go.mod
#	receiver/awslambdareceiver/go.sum

# Conflicts:
#	receiver/awslambdareceiver/go.mod
#	receiver/awslambdareceiver/go.sum
Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>
Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>
Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>
Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>
Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>
@Kavindu-Dodan Kavindu-Dodan force-pushed the feat/aws-lambda-receiver-stream-support branch from 0aa1a17 to e4fb78c Compare March 12, 2026 13:59
@Kavindu-Dodan

Kavindu-Dodan commented Mar 12, 2026

Copy link
Copy Markdown
Contributor Author

Please resolve conflicts

@atoulme thank you, all validations are green with the latest rebase 🙏

Could you please go ahead and merge this PR ?

@atoulme atoulme merged commit 3314aed into open-telemetry:main Mar 12, 2026
191 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants