Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add back Azure Functions correlation context hook #1070

Merged
merged 14 commits into from
Feb 7, 2023
Prev Previous commit
Next Next commit
WIP
  • Loading branch information
hectorhdzg committed Feb 1, 2023
commit 306fdfebd4b21ac43e8ef9ea876645b5f94da1b0
8 changes: 5 additions & 3 deletions AutoCollection/AzureFunctionsHook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,11 @@ export class AzureFunctionsHook {
if (!extractedContext) {
this._createIncomingRequestTelemetry(ctx, request, startTime, null);
}
CorrelationContextManager.runWithContext(extractedContext, () => {
this._createIncomingRequestTelemetry(ctx, request, startTime, extractedContext.operation.parentId);
});
else {
CorrelationContextManager.runWithContext(extractedContext, () => {
this._createIncomingRequestTelemetry(ctx, request, startTime, extractedContext.operation.parentId);
});
}
}
}
}
Expand Down
5 changes: 3 additions & 2 deletions Bootstrap/Default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,14 @@ export function setupAndStart(aadTokenCredential?: azureCoreAuth.TokenCredential
// Instrument the SDK
// Azure Functions
if (isAzureFunction) {
// Agent will always run in parallel with Azure Functions .NET Agent, disable requests and exceptions to avoid duplication of telemetry
_appInsights.setup().setSendLiveMetrics(false)
.setAutoCollectPerformance(false)
.setAutoCollectPreAggregatedMetrics(false)
.setAutoCollectIncomingRequestAzureFunctions(false)
.setAutoCollectRequests(true)
.setAutoCollectRequests(false)
.setAutoCollectExceptions(false)
.setAutoCollectDependencies(true)
.setAutoCollectExceptions(true)
.setAutoCollectHeartbeat(true)
.setUseDiskRetryCaching(true);
}
Expand Down
4 changes: 2 additions & 2 deletions applicationinsights.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ let _isSendingLiveMetrics = defaultConfig.isSendingLiveMetrics(); // Off by defa
let _isNativePerformance = defaultConfig.isNativePerformance();
let _disabledExtendedMetrics: IDisabledExtendedMetrics;
let _isSnippetInjection = defaultConfig.isSnippetInjection(); // default to false
let _isAzureFunctions = defaultConfig.isAzureFunctions(); // default to true
let _isAzureFunctions = defaultConfig.isAzureFunctions(); // default to false

function _getDefaultAutoCollectConfig() {
return {
Expand All @@ -68,7 +68,7 @@ function _getDefaultAutoCollectConfig() {
isSendingLiveMetrics: () => false, // Off by default
isNativePerformance: () => true,
isSnippetInjection: () => false,
isAzureFunctions: () => true
isAzureFunctions: () => false
}
}

Expand Down
Loading