Skip to content

feat: support Lambda Managed Instances telemetry records - #1193

Open
save91 wants to merge 1 commit into
aws:mainfrom
save91:feat/lambda-managed-instances-telemetry
Open

save91 wants to merge 1 commit into
aws:mainfrom
save91:feat/lambda-managed-instances-telemetry

Conversation

@save91

@save91 save91 commented Nov 26, 2026

Copy link
Copy Markdown

📬 *Issue #, if available: #1192

✍️ Description of changes:

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.

ReportMetrics is now an untagged enum:

pub enum ReportMetrics {
    OnDemand(OnDemandReportMetrics),                             // previous fields, unchanged
    LambdaManagedInstances(LambdaManagedInstancesReportMetrics), // duration_ms only
}

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:

// before
let billed = metrics.billed_duration_ms;

// after
if let ReportMetrics::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.

🤖 Generated with Claude Code

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant