UNPKG

5.8 kBTypeScriptView Raw
1import CorrelationContextManager = require("./AutoCollection/CorrelationContextManager");
2export import TelemetryClient = require("./Library/NodeClient");
3export import Contracts = require("./Declarations/Contracts");
4/**
5* The default client, initialized when setup was called. To initialize a different client
6* with its own configuration, use `new TelemetryClient(instrumentationKey?)`.
7*/
8export declare let defaultClient: TelemetryClient;
9/**
10 * Initializes the default client. Should be called after setting
11 * configuration options.
12 *
13 * @param instrumentationKey the instrumentation key to use. Optional, if
14 * this is not specified, the value will be read from the environment
15 * variable APPINSIGHTS_INSTRUMENTATIONKEY.
16 * @returns {Configuration} the configuration class to initialize
17 * and start the SDK.
18 */
19export declare function setup(instrumentationKey?: string): typeof Configuration;
20/**
21 * Starts automatic collection of telemetry. Prior to calling start no
22 * telemetry will be *automatically* collected, though manual collection
23 * is enabled.
24 * @returns {ApplicationInsights} this class
25 */
26export declare function start(): typeof Configuration;
27/**
28 * Returns an object that is shared across all code handling a given request.
29 * This can be used similarly to thread-local storage in other languages.
30 * Properties set on this object will be available to telemetry processors.
31 *
32 * Do not store sensitive information here.
33 * Custom properties set on this object can be exposed in a future SDK
34 * release via outgoing HTTP headers.
35 * This is to allow for correlating data cross-component.
36 *
37 * This method will return null if automatic dependency correlation is disabled.
38 * @returns A plain object for request storage or null if automatic dependency correlation is disabled.
39 */
40export declare function getCorrelationContext(): CorrelationContextManager.CorrelationContext;
41/**
42 * Returns a function that will get the same correlation context within its
43 * function body as the code executing this function.
44 * Use this method if automatic dependency correlation is not propagating
45 * correctly to an asynchronous callback.
46 */
47export declare function wrapWithCorrelationContext<T extends Function>(fn: T): T;
48/**
49 * The active configuration for global SDK behaviors, such as autocollection.
50 */
51export declare class Configuration {
52 static start: typeof start;
53 /**
54 * Sets the state of console and logger tracking (enabled by default for third-party loggers only)
55 * @param value if true logger activity will be sent to Application Insights
56 * @param collectConsoleLog if true, logger autocollection will include console.log calls (default false)
57 * @returns {Configuration} this class
58 */
59 static setAutoCollectConsole(value: boolean, collectConsoleLog?: boolean): typeof Configuration;
60 /**
61 * Sets the state of exception tracking (enabled by default)
62 * @param value if true uncaught exceptions will be sent to Application Insights
63 * @returns {Configuration} this class
64 */
65 static setAutoCollectExceptions(value: boolean): typeof Configuration;
66 /**
67 * Sets the state of performance tracking (enabled by default)
68 * @param value if true performance counters will be collected every second and sent to Application Insights
69 * @returns {Configuration} this class
70 */
71 static setAutoCollectPerformance(value: boolean): typeof Configuration;
72 /**
73 * Sets the state of request tracking (enabled by default)
74 * @param value if true requests will be sent to Application Insights
75 * @returns {Configuration} this class
76 */
77 static setAutoCollectRequests(value: boolean): typeof Configuration;
78 /**
79 * Sets the state of dependency tracking (enabled by default)
80 * @param value if true dependencies will be sent to Application Insights
81 * @returns {Configuration} this class
82 */
83 static setAutoCollectDependencies(value: boolean): typeof Configuration;
84 /**
85 * Sets the state of automatic dependency correlation (enabled by default)
86 * @param value if true dependencies will be correlated with requests
87 * @returns {Configuration} this class
88 */
89 static setAutoDependencyCorrelation(value: boolean): typeof Configuration;
90 /**
91 * Enable or disable disk-backed retry caching to cache events when client is offline (enabled by default)
92 * Note that this method only applies to the default client. Disk-backed retry caching is disabled by default for additional clients.
93 * For enable for additional clients, use client.channel.setUseDiskRetryCaching(true).
94 * These cached events are stored in your system or user's temporary directory and access restricted to your user when possible.
95 * @param value if true events that occured while client is offline will be cached on disk
96 * @param resendInterval The wait interval for resending cached events.
97 * @param maxBytesOnDisk The maximum size (in bytes) that the created temporary directory for cache events can grow to, before caching is disabled.
98 * @returns {Configuration} this class
99 */
100 static setUseDiskRetryCaching(value: boolean, resendInterval?: number, maxBytesOnDisk?: number): typeof Configuration;
101 /**
102 * Enables debug and warning logging for AppInsights itself.
103 * @param enableDebugLogging if true, enables debug logging
104 * @param enableWarningLogging if true, enables warning logging
105 * @returns {Configuration} this class
106 */
107 static setInternalLogging(enableDebugLogging?: boolean, enableWarningLogging?: boolean): typeof Configuration;
108}
109/**
110 * Disposes the default client and all the auto collectors so they can be reinitialized with different configuration
111*/
112export declare function dispose(): void;