Node layer never flushes LoggerProvider on invocation completion — logs silently dropped without manual forceFlush()
メンテナーはふだん 2 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 55/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 静か
- 技術スタック
- aws, node.js, typescript
- 領域
- cloud, observability
調査の方向性
nodejs/packages/layer/src/wrapper.ts を読み、LoggerProvider の構築と wrapped-handler の完了パスから確認します。また、Lambda Extensions API の SHUTDOWN パスが存在するかどうかも調べます。提供された handler と OTLP endpoint で再現し、手動の forceFlush() なしで出力されたログが、invocation の完了または shutdown の前に配信されることを確認します。
索引モデルが issue の本文から書いたものです。
説明
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
- 主要言語
- Go
- スター
- 433
- フォーク
- 249
- 平均マージ
- 1日 12時間
- マージ済み PR(30日)
- 39
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
open-telemetry/opentelemetry-lambda のほかの issue
-
enhancement ruby
難易度 2/5 1〜3時間 初心者へのやさしさ 64/100
open-telemetry/opentelemetry-lambda#2741 ·
メンテナーはふだん 2 日以内に返信
-
processor/cold_start
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
open-telemetry/opentelemetry-lambda#2738 ·
メンテナーはふだん 2 日以内に返信
-
Fix install-toolsオープンgo
難易度 2/5 1〜3時間 初心者へのやさしさ 64/100
open-telemetry/opentelemetry-lambda#2736 ·
メンテナーはふだん 2 日以内に返信
-
enhancement javascript
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
open-telemetry/opentelemetry-lambda#2744 ·
メンテナーはふだん 2 日以内に返信
-
enhancement python
難易度 3/5 1〜2日 初心者へのやさしさ 55/100
open-telemetry/opentelemetry-lambda#2742 ·
メンテナーはふだん 2 日以内に返信
open-telemetry/opentelemetry-lambda の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 73/100
-
[BUG] EphemeralJob matches every pod in the namespace when spec.selector is empty対応中かも @vishnums2k5 が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
openkruise/kruise#2656 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
rancher/rancher-ai-mcp#206 ·
メンテナーはふだん 1 日以内に返信
-
test: make command and stdio startup tests portable対応中かも @dajiaohuang が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 73/100
mark3labs/mcp-go#1220 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信