Node layer never flushes LoggerProvider on invocation completion — logs silently dropped without manual forceFlush()
Maintainer thường phản hồi trong vòng 2 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 55/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Ít trao đổi
- Công nghệ
- aws, node.js, typescript
- Lĩnh vực
- cloud, observability
Hướng nghiên cứu
Đọc nodejs/packages/layer/src/wrapper.ts, bắt đầu từ quá trình khởi tạo LoggerProvider và đường dẫn hoàn tất của wrapped handler; đồng thời kiểm tra xem có đường dẫn SHUTDOWN của Lambda Extensions API hay không. Tái hiện với handler và endpoint OTLP được cung cấp, sau đó xác minh rằng các log được phát ra mà không gọi forceFlush() thủ công được gửi trước khi invocation hoàn tất hoặc shutdown xảy ra.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Describe the bug
When using the Node layer with AWS_LAMBDA_EXEC_WRAPPER=/opt/otel-handler and OTLP logs export, logs emitted via the Logs API are unreliably delivered to the backend. They are only reliably delivered if the application explicitly calls forceFlush() on the logger provider before the handler returns. wrapper.ts constructs the LoggerProvider with a BatchLogRecordProcessor but no code path calls forceFlush()/shutdown() on it after the wrapped handler resolves, nor on a Lambda Extensions API SHUTDOWN event. AWS may freeze the execution environment shortly after the handler returns, before the batch processor's timer fires, dropping any log not yet exported.
Steps to reproduce
Deploy a Lambda with the layer below and AWS_LAMBDA_EXEC_WRAPPER=/opt/otel-handler, OTEL_EXPORTER_OTLP_LOGS_ENDPOINT=<your OTLP endpoint>, using this handler:
import { logs, SeverityNumber } from '@opentelemetry/api-logs'
import { randomUUID } from 'node:crypto'
export async function handler() {
const experimentId = randomUUID()
logs.getLogger('otel-logs').emit({
body: 'Lambda test log',
severityNumber: SeverityNumber.INFO,
severityText: 'INFO',
attributes: {
experiment_id: experimentId,
},
})
// works only with this line uncommented
// await (logs.getLoggerProvider() as any).forceFlush?.()
return {
experimentId,
}
}
Invoke repeatedly with the forceFlush() line commented out: log records are missing in the backend intermittently. Uncommenting the forceFlush() line (or alternatively sleeping ~5s before returning) makes delivery reliable.
What did you expect to see?
Logs emitted during a Lambda invocation are flushed/delivered automatically by the layer before the execution environment is frozen, the same "zero code change" guarantee the layer provides for traces.
What did you see instead?
Log records queued in the (default) BatchLogRecordProcessor are lost intermittently, with no application-level indication of the drop.
What version of collector/language SDK version did you use?
Version: layer opentelemetry-nodejs-0_23_0 (arn:aws:lambda:eu-central-1:184161586896:layer:opentelemetry-nodejs-0_23_0:1)
What language layer did you use?
Config: Node.js
Additional context
Relevant code: wrapper.ts constructs the LoggerProvider with a BatchLogRecordProcessor (no schedule-delay override), but no flush/shutdown call exists in the wrapper for the logger (or tracer/meter) provider.
Suggested fix: flush all registered providers (logger, tracer, meter) automatically once the wrapped handler settles, before returning control to the Lambda runtime, and/or register a Lambda Extensions API SHUTDOWN handler to flush on environment termination so in-flight logs aren't lost if the process is killed abnormally.
Workaround: manually call await (logs.getLoggerProvider() as any).forceFlush?.() at the end of every handler.
Possibly related (metrics, not logs, but similar auto-flush gap): #1949
- Ngôn ngữ chính
- Go
- Star
- 433
- Fork
- 249
- Merge trung bình
- 1 ngày 12 giờ
- Pull request đã merge (30 ngày)
- 39
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của open-telemetry/opentelemetry-lambda
-
enhancement ruby
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 64/100
open-telemetry/opentelemetry-lambda#2741 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
processor/cold_start
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
open-telemetry/opentelemetry-lambda#2738 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Fix install-toolsĐang mởgo
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 64/100
open-telemetry/opentelemetry-lambda#2736 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Use node-sdk package for layerĐang mởenhancement javascript
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
open-telemetry/opentelemetry-lambda#2744 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
enhancement python
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 55/100
open-telemetry/opentelemetry-lambda#2742 ·
Maintainer thường phản hồi trong vòng 2 ngày
Tất cả issue của open-telemetry/opentelemetry-lambda
Issue tương tự
-
bug
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 78/100
fabriziosalmi/secure-proxy-manager#619 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug needs-triage P1 tier:1-mechanical
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
krakenhavoc/cmd_and_ctrl#5434 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
go good first issue help wanted up-for-grabs
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
andrewsiah/agentswarm-data-tasks#117 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
openshell image: provide /sandbox so the workspace path can be uniform across OpenShell driversĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
Maintainer thường phản hồi trong vòng 1 ngày
-
C:dataplane
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
yanet-platform/yanet2#3395 ·
Maintainer thường phản hồi trong vòng 1 ngày