Repository navigation
Carry structured logging properties through worker hooks - #857
Radek Maziarka (rmaziarka) wants to merge 2 commits into
Conversation
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
It changes a shared critical-path logging contract and still has unresolved warning-scope and API-overload issues requiring code-owner review.
Review effort: Balanced
Findings: 1
What changed in this PR
Adds opt-in structured logging metadata to the worker’s core API and carries validated attributes to process-local log hooks without changing Host RPC messages.
Changes:
- Extends core logging and hook APIs with structured attributes and capability detection.
- Sanitizes attributes, protects reserved keys, and emits bounded compatibility warnings.
- Adds compatibility, concurrency, disposal, validation, and transport tests.
Human Review Packet
HUMAN REVIEW REQUIRED
Gate: A - before implementation
Owner: @azure/azure-functions-nodejs
Decision needed: Approve the new cross-repository core logging contract, compatibility behavior, and coordinated rollout.
Critical paths:
WorkerContext,InvocationHandler, core-module setup, and hooks alter invocation logging and public programming-model behavior.
Behavioral contract:
- Before: Logs exposed only formatted messages to hooks and Host RPC.
- After: Opted-in hooks receive sanitized structured attributes through an extended core API.
- Must remain invariant: Existing message, severity, correlation, hook mutation, and Host RPC behavior.
Blast radius:
- Programming-model and exporter compatibility, concurrent invocations, specialization, and coordinated package releases.
Security analysis:
- No evidence-backed vulnerability found; attributes remain process-local and reserved or invalid values are filtered.
Validation evidence:
- NOT RUN: Independent repository checks were unavailable under review constraints; the PR reports 157 tests, lint, build, and local Host integration passing.
Residual risks or open decisions:
- Invocation warning scope is incorrect before
logContextinitialization, the generic hook overload accepts ignored options, and managed Azure validation is absent.
Human decision: PENDING
| File | Description |
|---|---|
types-core/index.d.ts |
Extends logging and hook types. |
src/AppContext.ts |
Tracks structured-capable hooks. |
src/WorkerContext.ts |
Sanitizes metadata and emits warnings. |
src/setupCoreModule.ts |
Exposes capability detection. |
src/hooks/registerHook.ts |
Records consumer support. |
src/hooks/LogHookContext.ts |
Exposes sanitized attributes. |
src/eventHandlers/InvocationHandler.ts |
Carries invocation metadata. |
src/coreApi/coreApiLog.ts |
Carries application-level metadata. |
src/utils/structuredLogProperties.ts |
Validates and freezes attributes. |
test/eventHandlers/structuredLogging.test.ts |
Tests structured logging behavior. |
README.md |
Documents the new contract. |
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| reason: string, | ||
| rejectedCount?: number | ||
| ): void { | ||
| const scope = invocationLogCtx ?? this.app; |

Project
context.log/errorarguments as separately queryable Application Insights fields.Problem
context.log/errorbecome message text; no separately queryable fields.Proposed solution
LogHookContext; unchanged formatted message and invocation context.Validation
Warning limits use a stable invocation scope from creation through execution; regression coverage includes logging in
getInvocationModel,getArgumentsandinvokeFunction.Structured logging options are accepted only for the log-hook overload.
159 tests passed; 8 existing tests for older Node versions skipped on Node 24. Build and lint passed.
Combined integration test: local Functions host, modified packages and live Application Insights; 30 records verified across CommonJS, ESM, disabled opt-in, missing consumer and old-worker scenarios.
Verified message preservation, custom dimensions, severity and invocation correlation. Not tested in managed Azure Functions; rollout requires coordinated releases.