[Monitor OpenTelemetry] Replace Az Fns Hook with Instrumentation#37591
Merged
JacksonWeber merged 16 commits intoAzure:mainfrom Mar 20, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR modernizes Azure Functions context propagation in @azure/monitor-opentelemetry by replacing the custom AzureFunctionsHook with the officially supported @azure/functions-opentelemetry-instrumentation, and removes now-unneeded custom module-loading utilities.
Changes:
- Always registers
AzureFunctionsInstrumentationas part ofTraceHandlerinstrumentation initialization. - Removes the custom Azure Functions hook implementation (
azureFnHook.ts) and the ESM/CJS loaders previously used to conditionally load@azure/functions-core. - Updates unit tests and package metadata (dependency + changelog) to reflect the new Azure Functions instrumentation approach.
Reviewed changes
Copilot reviewed 9 out of 10 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| sdk/monitor/monitor-opentelemetry/src/traces/handler.ts | Replaces custom hook usage with AzureFunctionsInstrumentation and always adds it to the instrumentation list. |
| sdk/monitor/monitor-opentelemetry/src/traces/azureFnHook.ts | Removes the custom AzureFunctionsHook implementation entirely. |
| sdk/monitor/monitor-opentelemetry/src/shared/module.ts | Removes ESM loader helper that loaded @azure/functions-core. |
| sdk/monitor/monitor-opentelemetry/src/shared/module-cjs.cts | Removes CJS loader helper that loaded @azure/functions-core. |
| sdk/monitor/monitor-opentelemetry/test/internal/unit/traces/azureFnHook.test.ts | Updates tests to validate AzureFunctionsInstrumentation registration instead of custom hook behavior. |
| sdk/monitor/monitor-opentelemetry/test/internal/unit/traces/traceHandler.test.ts | Updates expectation to account for always-on AzureFunctionsInstrumentation. |
| sdk/monitor/monitor-opentelemetry/package.json | Adds dependency on @azure/functions-opentelemetry-instrumentation. |
| sdk/monitor/monitor-opentelemetry/CHANGELOG.md | Documents the replacement of the custom hook with the new instrumentation package. |
| sdk/monitor/monitor-opentelemetry/src/metrics/quickpulse/export/sender.ts | Clarifies a @ts-expect-error comment used for tests accessing a private field. |
You can also share your feedback on Copilot code review. Take the survey.
hectorhdzg
reviewed
Mar 16, 2026
hectorhdzg
reviewed
Mar 19, 2026
hectorhdzg
approved these changes
Mar 19, 2026
Member
hectorhdzg
left a comment
There was a problem hiding this comment.
Looks like some git merge issues, but monitor opentelemetry package changes look good
These files were accidentally included in the PR and are outside the scope of monitor-opentelemetry changes. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
hectorhdzg
approved these changes
Mar 19, 2026
jeremymeng
approved these changes
Mar 20, 2026
Member
jeremymeng
left a comment
There was a problem hiding this comment.
lock file changes look good
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Packages impacted by this PR
@azure/monitor-opentelemetry
Issues associated with this PR
Describe the problem that is addressed by this PR
This pull request updates the Azure Monitor OpenTelemetry SDK to replace the custom
AzureFunctionsHookwith the officially supported@azure/functions-opentelemetry-instrumentationpackage for Azure Functions context propagation. This change simplifies the codebase, removes custom module loading logic, and ensures the latest Azure Functions instrumentation features are available. Related tests have been updated to reflect the new approach.Key changes include:
Azure Functions Instrumentation Modernization:
AzureFunctionsHookimplementation with the@azure/functions-opentelemetry-instrumentationpackage, which is now always included as an instrumentation. This package is maintained by the Azure Functions team and adds capabilities such as log forwarding and support forWorkerOpenTelemetryEnabled. (sdk/monitor/monitor-opentelemetry/CHANGELOG.md,sdk/monitor/monitor-opentelemetry/package.json,sdk/monitor/monitor-opentelemetry/src/traces/handler.ts, [1] [2] [3] [4] [5] [6] [7]Codebase Simplification and Cleanup:
sdk/monitor/monitor-opentelemetry/src/traces/azureFnHook.ts,sdk/monitor/monitor-opentelemetry/src/shared/module.ts,sdk/monitor/monitor-opentelemetry/src/shared/module-cjs.cts, [1] [2] [3]Test Updates:
AzureFunctionsInstrumentationis always registered, and removed tests specific to the old custom hook logic. (sdk/monitor/monitor-opentelemetry/test/internal/unit/traces/azureFnHook.test.ts,sdk/monitor/monitor-opentelemetry/test/internal/unit/traces/traceHandler.test.ts, [1] [2] [3] [4]Minor Code Comments:
QuickpulseSenderto clarify test access patterns. (sdk/monitor/monitor-opentelemetry/src/metrics/quickpulse/export/sender.ts, sdk/monitor/monitor-opentelemetry/src/metrics/quickpulse/export/sender.tsL43-R43)Checklists