You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat: support Lambda Managed Instances telemetry records - #1193
lambda-extension failed to deserialize Telemetry API records from functions running on Lambda Managed Instances. It also subscribed to the Telemetry API with a schema version that Managed Instances don't use. This PR fixes both.
platform.report metrics (telemetry.rs)
On Managed Instances, platform.report only contains durationMs. ReportMetrics required billedDurationMs, memorySizeMB and maxMemoryUsedMB, so deserialization failed with missing field `billedDurationMs` . Because records arrive in batches, that failure dropped the whole batch, including function log records.
OnDemand is the first variant on purpose. Untagged deserialization tries variants in order, and an on-demand payload would also match the smaller Managed Instances shape. A ReportMetrics::duration_ms() helper returns the one field both shapes share.
initializationType (telemetry.rs)
On Managed Instances, init records (platform.initStart, platform.initRuntimeDone, platform.initReport) have "initializationType": "lambda-managed-instances". This PR adds InitType::LambdaManagedInstances for it. The enum's existing rename_all = "kebab-case" produces that string, so no explicit rename is needed.
Telemetry API schema version (requests.rs)
The subscription request now sends schemaVersion: "2025-01-29" when the AWS_LAMBDA_INITIALIZATION_TYPE environment variable is lambda-managed-instances. Otherwise it still sends "2022-07-01", so on-demand, provisioned concurrency and SnapStart functions behave as before. The rustdoc for Extension::with_telemetry_processor describes this.
Breaking change
ReportMetrics changes from a struct to an enum. Code that reads its fields directly has to match on the variant first:
// beforelet billed = metrics.billed_duration_ms;// afterifletReportMetrics::OnDemand(m) = &metrics {let billed = m.billed_duration_ms;}let duration = metrics.duration_ms();// available for both variants
Adding a variant to InitType, which isn't #[non_exhaustive], is also a breaking change for exhaustive matches.
Tests
Deserialization and serialization tests for a Managed Instances platform.report (durationMs + spans only) and for platform.initStart with lambda-managed-instances.
Updated the existing on-demand platform.report tests to the new enum. The JSON output is the same as before.
Unit tests for how the schema version is chosen.
These changes have not been tested against a real Managed Instances function.
🔏 By submitting this pull request
I confirm that I've ran cargo +nightly fmt.
I confirm that I've ran cargo clippy --fix.
I confirm that I've made a best effort attempt to update all relevant documentation.
I confirm that my contribution is made under the terms of the Apache 2.0 license.
I tested 0df0244 locally. The extension tests passed, including the Managed Instances telemetry cases. I also captured the registration request before telemetry starts. The default sends ["INVOKE", "SHUTDOWN"], and an explicit .with_events(&["SHUTDOWN"]) sent only SHUTDOWN and registered successfully against a local mock.
@mattenarle10 Thanks a lot for testing this locally and for capturing the registration request.
Good point about the rustdoc. I agree that showing .with_events(&["SHUTDOWN"]) there will help callers reach the telemetry subscription on Managed Instances. I'll wait for the rest of the review and then add it together with any other feedback, so everything goes in one update.
This branch has not been deployed
No deployments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📬 *Issue #, if available: #1192
✍️ Description of changes:
lambda-extensionfailed to deserialize Telemetry API records from functions running on Lambda Managed Instances. It also subscribed to the Telemetry API with a schema version that Managed Instances don't use. This PR fixes both.platform.reportmetrics (telemetry.rs)On Managed Instances,
platform.reportonly containsdurationMs.ReportMetricsrequiredbilledDurationMs,memorySizeMBandmaxMemoryUsedMB, so deserialization failed withmissing field `billedDurationMs`. Because records arrive in batches, that failure dropped the whole batch, including function log records.ReportMetricsis now an untagged enum:OnDemandis the first variant on purpose. Untagged deserialization tries variants in order, and an on-demand payload would also match the smaller Managed Instances shape. AReportMetrics::duration_ms()helper returns the one field both shapes share.initializationType(telemetry.rs)On Managed Instances, init records (
platform.initStart,platform.initRuntimeDone,platform.initReport) have"initializationType": "lambda-managed-instances". This PR addsInitType::LambdaManagedInstancesfor it. The enum's existingrename_all = "kebab-case"produces that string, so no explicit rename is needed.Telemetry API schema version (
requests.rs)The subscription request now sends
schemaVersion: "2025-01-29"when theAWS_LAMBDA_INITIALIZATION_TYPEenvironment variable islambda-managed-instances. Otherwise it still sends"2022-07-01", so on-demand, provisioned concurrency and SnapStart functions behave as before. The rustdoc forExtension::with_telemetry_processordescribes this.Breaking change
ReportMetricschanges from a struct to an enum. Code that reads its fields directly has to match on the variant first:Adding a variant to
InitType, which isn't#[non_exhaustive], is also a breaking change for exhaustivematches.Tests
platform.report(durationMs+ spans only) and forplatform.initStartwithlambda-managed-instances.platform.reporttests to the new enum. The JSON output is the same as before.These changes have not been tested against a real Managed Instances function.
🔏 By submitting this pull request
cargo +nightly fmt.cargo clippy --fix.🤖 Generated with Claude Code