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

Task 7496325: Add Distributed tracing population for the properties for the core #1846 #1847

Merged
merged 2 commits into from
May 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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