Skip to content

Commit

Permalink
Task 7496325: Add Distributed tracing population for the properties f…
Browse files Browse the repository at this point in the history
…or the core #1846

- Single Page Application Page View Tracking #176
- Run-time Telemetry initializers for Ajax requests #198
- How to modify traceflag in traceparent header? #1776
  • Loading branch information
MSNev committed May 31, 2022
1 parent 3e8bece commit 562a00e
Show file tree
Hide file tree
Showing 25 changed files with 1,056 additions and 439 deletions.
29 changes: 26 additions & 3 deletions AISKU/src/Initialization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
IChannelControls, hasWindow, hasDocument, isReactNative, doPerf, IDiagnosticLogger, INotificationManager, objForEachKey, proxyAssign, proxyFunctions,
arrForEach, isString, isFunction, isNullOrUndefined, isArray, throwError, ICookieMgr, addPageUnloadEventListener, addPageHideEventListener,
createUniqueNamespace, ITelemetryPlugin, IPlugin, ILoadedPlugin, UnloadHandler, removePageUnloadEventListener, removePageHideEventListener,
ITelemetryInitializerHandler, ITelemetryUnloadState, mergeEvtNamespace, _throwInternal, arrIndexOf
ITelemetryInitializerHandler, ITelemetryUnloadState, mergeEvtNamespace, _throwInternal, arrIndexOf, IDistributedTraceContext
} from "@microsoft/applicationinsights-core-js";
import { AnalyticsPlugin, ApplicationInsights } from "@microsoft/applicationinsights-analytics-js";
import { Sender } from "@microsoft/applicationinsights-channel-js";
Expand All @@ -23,6 +23,7 @@ import {
IPropertiesPlugin, DistributedTracingModes, PropertiesPluginIdentifier, BreezeChannelIdentifier, AnalyticsPluginIdentifier,
ITelemetryContext as Common_ITelemetryContext, parseConnectionString
} from "@microsoft/applicationinsights-common"
import { DependencyListenerFunction, IDependencyListenerHandler } from "@microsoft/applicationinsights-dependencies-js/types/DependencyListener";

export { IUtil, ICorrelationIdHelper, IUrlHelper, IDateTimeUtils, IRequestHeaders };

Expand Down Expand Up @@ -413,7 +414,8 @@ export class Initialization implements IApplicationInsights {
]);

proxyFunctions(_self, _getCurrentDependencies, [
"trackDependencyData"
"trackDependencyData",
"addDependencyListener"
]);

proxyFunctions(_self, _core, [
Expand All @@ -423,7 +425,8 @@ export class Initialization implements IApplicationInsights {
"getPlugin",
"addPlugin",
"evtNamespace",
"addUnloadCb"
"addUnloadCb",
"getTraceCtx"
]);

proxyFunctions(_self, () => {
Expand All @@ -440,6 +443,7 @@ export class Initialization implements IApplicationInsights {
_self.config.diagnosticLogInterval && _self.config.diagnosticLogInterval > 0 ? _self.config.diagnosticLogInterval : 10000;
}

// Using a function to support the dynamic adding / removal of plugins, so this will always return the current value
function _getCurrentDependencies() {
return dependencies;
}
Expand Down Expand Up @@ -715,6 +719,25 @@ export class Initialization implements IApplicationInsights {
public addUnloadCb(handler: UnloadHandler): void {
// @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
}

/**
* Add an ajax listener which is called just prior to the request being sent and before the correlation headers are added, to allow you
* to access the headers and modify the values used to generate the distributed tracing correlation headers. (added in v2.8.4)
* @param dependencyListener - The Telemetry Initializer function
* @returns - A IDependencyListenerHandler to enable the initializer to be removed
*/
public addDependencyListener(dependencyListener: DependencyListenerFunction): IDependencyListenerHandler {
// @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
return null;
}

/**
* Gets the current distributed trace context for this instance if available
*/
public getTraceCtx(): IDistributedTraceContext | null | undefined {
// @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
return null;
}
}

// tslint:disable-next-line
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -260,11 +260,12 @@ appInsights.trackTrace({message: 'this message will not be sent'}); // Not sent
## Configuration
Most configuration fields are named such that they can be defaulted to falsey. All fields are optional except for `instrumentationKey`.
Most configuration fields are named such that they can be defaulted to falsey. All fields are optional except for `instrumentationKey` or a `connectionString` containing the instrumentation key.
| Name | Type | Default | Description |
|------|------|---------|-------------|
| instrumentationKey | string<br>[**Required**]| null | Instrumentation key that you obtained from the Azure Portal. |
| instrumentationKey | string<br>[**Required if `connectionString` not supplied**]| null | Instrumentation key that you obtained from the Azure Portal. |
| connectionString | string<br>[**Require if `instrumentationKey` not supplied**] | null | The Connection string that you obtained from the Azure portal |
| accountId | string | null | An optional account id, if your app groups users into accounts. No spaces, commas, semicolons, equals, or vertical bars |
| sessionRenewalMs | numeric | 1800000 | A session is logged if the user is inactive for this amount of time in milliseconds. Default is 30 minutes |
| sessionExpirationMs | numeric | 86400000 | A session is logged if it has continued for this amount of time in milliseconds. Default is 24 hours |
Expand Down
Loading

0 comments on commit 562a00e

Please sign in to comment.