AWS Lambda Implementation Guide
By Nicolas Narbais
Make Lambda functions visible with AWS-native metrics, the OpenTelemetry layer, structured logs, and application traces.
Make AWS Lambda functions operationally visible in Tsuga across three progressive levels. Lambda has no host agent or long-lived Collector; the OpenTelemetry Lambda layer embeds a Collector extension directly inside each execution environment.
| Level | Signals added | Path |
|---|---|---|
| 1 | AWS-native invocations, errors, duration, throttles, concurrency | CloudWatch Metric Stream → Firehose → Tsuga |
| 2 | Platform/app logs + custom OTLP metrics | Lambda Telemetry API + OTel layer extension |
| 3 | Handler traces, dependency spans, propagation, log correlation | Language auto-instrumentation + manual spans |
The three levels separate what you enable, not three separate Collectors. Keep the trace pipeline wired in Level 2, but only call a function trace-instrumented once its handler emits meaningful spans and propagates context downstream.
Before starting
- Scope: agree on AWS accounts, regions, functions, environments, owners, and any data-residency restrictions.
- Secrets: store the Tsuga ingestion key in your secret store, never in code, deployment zips, or checked-in Collector YAML.
- Egress: verify outbound HTTPS to Tsuga (VPC-attached functions need NAT or an approved egress path).
- Single log route: keep CloudWatch during rollout if needed, but if the Lambda layer ships logs to Tsuga, do not also forward that CloudWatch log group to Tsuga.
- Identity: lock
service.nameanddeployment.environment.namebefore expanding past one pilot function. - Layer match: pick the exact OpenTelemetry Lambda layer ARN for your runtime, region, and architecture (
x86_64vsarm64).
Choose your Lambda service-identity model
A Lambda function name (faas.name) is AWS infrastructure identity, not automatically your service boundary. Never put environments, mutable aliases, or invocation IDs in service.name.
| Model | When to use | Upside | Tradeoff |
|---|---|---|---|
| One function = one service | Independently owned, deployed, and alerted function | Clean per-function health and SLOs | Fragments multi-Lambda journeys |
| Several functions = one bounded service (default) | Functions ship and operate as one capability | Unified traffic, errors, latency, deployments | Requires grouping by faas.name for function-level regressions |
Always preserve automatic faas.name attributes and set immutable release identity via environment variables (use a commit SHA or published Lambda version, never $LATEST or a mutable alias):
OTEL_SERVICE_NAME=<LOGICAL_SERVICE_NAME>
OTEL_RESOURCE_ATTRIBUTES=service.namespace=<TEAM_OR_PRODUCT>,service.version=<IMMUTABLE_BUILD_VERSION>,deployment.environment.name=<ENVIRONMENT>
Level 1 - Stream AWS-native metrics
Stream the AWS/Lambda CloudWatch namespace to Tsuga via a CloudWatch Metric Stream (OpenTelemetry 1.0 format), a Firehose HTTP delivery stream, and an S3 backup for failed deliveries. Restrict the stream to in-scope namespaces (AWS/Lambda first).
This requires zero code, layer, or execution-role changes and immediately gives you:
- Core health: invocations, errors, duration, throttles, concurrent executions.
- Trigger-specific signals: dead-letter/async outcomes, provisioned concurrency, and iterator age where applicable.
Build your first dashboard and monitors from these metrics (throttles, sustained errors with an invocation floor, duration jumps), validating in order: Metric Stream → Firehose deliveries/S3 backup → Tsuga Metrics.
Exit criteria: Recent AWS-native invocation, error, duration, and concurrency metrics appear in Tsuga, Firehose retains failures in S3, and on-call can spot throttled or failing functions without code changes.
Level 2 - Add the Lambda layer for logs and app metrics
Attach the matching upstream OpenTelemetry Lambda layer without overwriting existing layers. Point OPENTELEMETRY_COLLECTOR_CONFIG_URI to a packaged config file (fewest runtime dependencies; S3/HTTP adds cold-start fetches) and expose TSUGA_OTLP_ENDPOINT and TSUGA_API_KEY from your secret store:
receivers:
telemetryapi:
otlp:
protocols:
http:
grpc:
processors:
batch:
decouple:
exporters:
otlp_http/tsuga:
endpoint: ${env:TSUGA_OTLP_ENDPOINT}
headers:
Authorization: Bearer ${env:TSUGA_API_KEY}
service:
pipelines:
logs:
receivers: [telemetryapi]
processors: [batch, decouple]
exporters: [otlp_http/tsuga]
metrics:
receivers: [otlp]
processors: [batch, decouple]
exporters: [otlp_http/tsuga]
traces:
receivers: [otlp]
processors: [batch, decouple]
exporters: [otlp_http/tsuga]
Keep decouple so the extension can flush exports after the handler returns before Lambda freezes the sandbox. Keep CloudWatch for AWS-native metrics and use OTLP metrics strictly for custom domain/application metrics; never duplicate the same metric across both paths.
Make log format and ownership explicit
- Structured JSON: emit one JSON object per line with timestamp, level, stable message, and bounded fields, with no secrets, auth headers, or raw payloads.
- CloudWatch cutoff: only deny
logs:CreateLogGroup,logs:CreateLogStream, andlogs:PutLogEventsafter validating direct Telemetry API delivery (never during initial rollout).
Invoke once with a unique harmless log token and confirm it appears once in Tsuga with the agreed context.service.name, environment, and Lambda metadata (trace IDs arrive in Level 3).
Exit criteria: Platform and application logs arrive in Tsuga exactly once with correct identity, CloudWatch forwarding is not duplicating records, and any custom OTLP metric is distinct from AWS-native metrics.
Level 3 - Trace handler invocations and dependencies
Enable the OpenTelemetry Lambda layer’s language wrapper/bootstrap so auto-instrumentation loads before your handler and framework (never initialize a second global SDK provider if the layer owns one):
- Root invocation span: trigger the function normally and confirm the root span carries the agreed service and environment identity.
- Automatic dependency spans: verify AWS SDK, HTTP, and database spans appear without duplicating them manually.
- Purposeful manual spans: add small spans only for business work (
validate-order,calculate-price). Never put request IDs or payloads in span names. - Cross-boundary propagation: set
OTEL_PROPAGATORS=tracecontext,baggagewhere supported. Keep synchronous API Gateway/HTTP calls in one trace; link asynchronous SQS/EventBridge/SNS consumer spans to the producer context instead of inflating parent-child duration. - Log correlation: configure the runtime logger bridge to emit active
trace_idandspan_idon every log record.
Keep metric dimensions bounded (route, operation, AWS service, outcome, status) and exclude user IDs, tenant ARNs, request IDs, and message bodies. Test both a normal invocation and a controlled failure to prove trace-to-log and log-to-trace pivots work in both directions.
Exit criteria: Normal and failed invocations produce searchable traces with dependency/business spans, sync and async causality work as intended, logs pivot to traces, and all signals share one identity.
Add monitors and SLOs after Level 3
Pair AWS-native metrics (platform failures and capacity) with trace-derived metrics (user-facing errors and latency):
- Throttles / concurrency: sustained throttles or concurrency saturation.
- Error rate: elevated errors paired with a minimum invocation floor.
- Latency: high handler or end-to-end duration on critical operations.
- Async backlog: failed async deliveries or rising iterator age.
- SLOs: base SLOs on customer-visible outcomes (one SLO across a multi-Lambda order service, or per function for a standalone auth Lambda).
Troubleshooting path
| Symptom | Check first | Fix |
|---|---|---|
| Missing AWS-native metrics | CloudWatch Metric Stream → Firehose → S3 backup | Fix stream namespace filter, Firehose intake endpoint, or IAM role |
| Duplicate logs in Tsuga | CloudWatch log forwarding vs Telemetry API extension | Disable one of the two Tsuga log routes |
| Logs arrive, traces are missing | Layer wrapper/bootstrap config and local OTLP export | Load language wrapper before handler; avoid duplicate SDK init |
Wrong service.name | OTEL_SERVICE_NAME and OTEL_RESOURCE_ATTRIBUTES | Standardize deployment env vars; never rename post-collection |
| Direct telemetry never arrives | Layer ARN match, OPENTELEMETRY_COLLECTOR_CONFIG_URI, VPC NAT | Verify runtime/arch ARN, extension errors, and outbound HTTPS |
Completion criterion and CLI validation
A known invocation appears as a trace with the agreed service.name and environment, its log arrives exactly once, and the function’s AWS-native metrics are visible for the same window.
# 1. Confirm spans arrived through the Lambda layer
tsuga traces search \
--query "context.service.name:<service>" \
--from -15m \
--to now \
--max-results 10
# 2. Confirm the test log arrived exactly once
tsuga logs search \
--query "context.service.name:<service> <unique-log-token>" \
--from -15m \
--to now \
--max-results 10
If command 1 is empty while command 2 returns the log, fix the language wrapper/bootstrap rather than the exporter. If command 2 returns two copies, remove the duplicate CloudWatch log route. Verify Level 1 AWS-native metrics directly in Tsuga Metrics, as CloudWatch-derived metric names differ from raw namespace names.
References
Written by
Nicolas Narbais
Nicolas Narbais builds, breaks, debugs, and scales observability systems using OpenTelemetry and modern telemetry pipelines. He shares practical, opinionated lessons to help engineers get better signal with less noise.
Olatuak Editorial Philosophy
Better signal, not more telemetry.
Olatuak helps platform engineers, SREs, and observability teams turn noisy telemetry into clear operational decisions without blindly collecting more data.
