Azure / Azure/azure-functions-dotnet-worker

Worker logs not routed to console/host output when using OpenTelemetry schema v1.37.0

Open Beginner friendly
#3,489 0 comments 0 reactions 0 assignees View on GitHub
Needs: Triage (Functions) potential-bug
Dominant language
C#
Stars
466
Forks
215
Avg merge
3d 10h
Merged PRs (30d)
7

Description

### Description

## Description

When `UseFunctionsWorkerDefaults()` is called on the OpenTelemetry builder, it advertises schema version `1.37.0` via the `WorkerOpenTelemetrySchemaVersion` capability. This activates `TelemetryProviderV1_37_0`, which causes **all worker invocation logs to stop appearing in console output and the host log stream**.

## Root Cause

`GrpcFunctionsHostLogWriter.AppendInvocationIdToLog` looks for the key `TraceConstants.InternalKeys.FunctionInvocationId` (`"AzureFunctions_InvocationId"`) in the current log scope to attach the `InvocationId` to the outgoing RPC log message. Without it, the host cannot correlate the log to an invocation and drops it from output.

`TelemetryProviderV1_17_0` correctly emits this key in `GetScopeAttributes`:

`yield return new(TraceConstants.InternalKeys.FunctionInvocationId, context.InvocationId);`

`TelemetryProviderV1_37_0` does **not** emit this key — it only emits the OTel-compliant key `TraceConstants.OTelAttributes_1_37_0.InvocationId` (`"faas.invocation_id"`), which `AppendInvocationIdToLog` does not recognize.

### Steps to reproduce

## Steps to Reproduce

1. Create a .NET Isolated Azure Functions app.
2. Add `Microsoft.Azure.Functions.Worker.OpenTelemetry` and call `.UseFunctionsWorkerDefaults()`.
3. Invoke any function.
4. Observe that logs written inside the function body **do not appear** in the console or host log output.

## Expected Behavior

Logs are routed to console output and the host, as they are with schema v1.17.0.

## Actual Behavior

Logs are silently dropped — `rpcLog.InvocationId` is never set, so the host cannot route them.

## Fix

Add the internal key to `TelemetryProviderV1_37_0.GetScopeAttributes`:

`// Required by GrpcFunctionsHostLogWriter.AppendInvocationIdToLog for host log routing yield return new(TraceConstants.InternalKeys.FunctionInvocationId, context.InvocationId);
`

This is in addition to (not replacing) the OTel attribute `TraceConstants.OTelAttributes_1_37_0.InvocationId`, which should remain for tracing purposes.

## Affected File

`src/DotNetWorker.Core/Diagnostics/Telemetry/TelemetryProviderV1_37_0.cs`

## Environment

- Package: `Microsoft.Azure.Functions.Worker.OpenTelemetry`
- Triggered by: calling `UseFunctionsWorkerDefaults()`, which sets `WorkerOpenTelemetrySchemaVersion = "1.37.0"`

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with src/DotNetWorker.Core/Diagnostics/Telemetry/TelemetryProviderV1_37_0.cs and compare GetScopeAttributes with TelemetryProviderV1_17_0; review GrpcFunctionsHostLogWriter.AppendInvocationIdToLog to confirm the required scope key. Done means v1.37.0 retains its OTel invocation attribute, also provides the internal invocation key, and worker logs appear in console and host output.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
backend, observability
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
90/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.