You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Context should be propagated as soon as possible to make all logs generated by function invocation have a valid Operation Id in Application Insights.
Thus:
self.configure_opentelemetry(fi_context) should be executed in _handle__invocation_request right before first log is emitted at line 617
If OpenTelemetry is available and initialized, first log emitted by _handle__invocation_request is not properly recorded as part of function workflow, i.e.: in Application Insights has a blank Operation Id.
This is because of late context propagation (at line 666) which happens after first log is emitted at line 617
Steps to Reproduce
Create a new Azure Function
Create a new trigger and write code to emit some logs
In local.settings.json add PYTHON_ENABLE_OPENTELEMETRY=1 and APPLICATIONINSIGHTS_CONNECTION_STRING=your-connection-string
Run the trigger created at step 2.
Check in Application Insights that first log emitted by function invocation (i.e.: Received function invocation request ...) has a blank operation_id
requirements.txt file
azure-functions
azure-monitor-opentelemetry
Where are you facing this problem?
Local - Core Tools
The text was updated successfully, but these errors were encountered:
MatteoMeil
changed the title
[Bug] Late context propagation in _handle__invocation_request
[Bug] Late OpenTelemetry context propagation in _handle__invocation_request
Jan 9, 2025
Expected Behavior
Context should be propagated as soon as possible to make all logs generated by function invocation have a valid Operation Id in Application Insights.
Thus:
self.configure_opentelemetry(fi_context)
should be executed in_handle__invocation_request
right before first log is emitted at line 617fi_context
initialization should be moved up, ideally at line 602Actual Behavior
If OpenTelemetry is available and initialized, first log emitted by
_handle__invocation_request
is not properly recorded as part of function workflow, i.e.: in Application Insights has a blank Operation Id.This is because of late context propagation (at line 666) which happens after first log is emitted at line 617
Steps to Reproduce
local.settings.json
addPYTHON_ENABLE_OPENTELEMETRY=1
andAPPLICATIONINSIGHTS_CONNECTION_STRING=your-connection-string
Received function invocation request ...
) has a blankoperation_id
requirements.txt file
Where are you facing this problem?
Local - Core Tools
The text was updated successfully, but these errors were encountered: