@azure/opentelemetry-instrumentation-azure-sdk 1.0.0-beta.5 → 1.0.0-beta.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -2
- package/dist/browser/configuration.d.ts +21 -0
- package/dist/browser/configuration.d.ts.map +1 -0
- package/{dist-esm/src → dist/browser}/configuration.js +2 -2
- package/dist/browser/configuration.js.map +1 -0
- package/dist/browser/index.d.ts +3 -0
- package/dist/browser/index.d.ts.map +1 -0
- package/dist/browser/index.js +5 -0
- package/{dist-esm/src → dist/browser}/index.js.map +1 -1
- package/dist/browser/instrumentation-browser.d.mts.map +1 -0
- package/dist/browser/instrumentation-browser.mjs.map +1 -0
- package/dist/browser/instrumentation.d.ts +35 -0
- package/{dist-esm/src/instrumentation.browser.js → dist/browser/instrumentation.js} +5 -5
- package/dist/browser/instrumenter.d.ts +13 -0
- package/dist/browser/instrumenter.d.ts.map +1 -0
- package/{dist-esm/src → dist/browser}/instrumenter.js +4 -4
- package/dist/browser/instrumenter.js.map +1 -0
- package/dist/browser/logger.d.ts +5 -0
- package/dist/browser/logger.d.ts.map +1 -0
- package/{dist-esm/src → dist/browser}/logger.js +1 -1
- package/{dist-esm/src → dist/browser}/logger.js.map +1 -1
- package/dist/browser/package.json +3 -0
- package/dist/browser/spanWrapper.d.ts +20 -0
- package/dist/browser/spanWrapper.d.ts.map +1 -0
- package/{dist-esm/src → dist/browser}/spanWrapper.js +6 -2
- package/dist/browser/spanWrapper.js.map +1 -0
- package/dist/browser/transformations.d.ts +29 -0
- package/dist/browser/transformations.d.ts.map +1 -0
- package/{dist-esm/src → dist/browser}/transformations.js +4 -19
- package/dist/browser/transformations.js.map +1 -0
- package/dist/commonjs/configuration.d.ts +21 -0
- package/dist/commonjs/configuration.d.ts.map +1 -0
- package/dist/commonjs/configuration.js +35 -0
- package/dist/commonjs/configuration.js.map +1 -0
- package/dist/commonjs/index.d.ts +3 -0
- package/dist/commonjs/index.d.ts.map +1 -0
- package/dist/commonjs/index.js +8 -0
- package/dist/commonjs/index.js.map +1 -0
- package/{types/3.1/opentelemetry-instrumentation-azure-sdk.d.ts → dist/commonjs/instrumentation.d.ts} +39 -33
- package/dist/commonjs/instrumentation.d.ts.map +1 -0
- package/dist/commonjs/instrumentation.js +57 -0
- package/dist/commonjs/instrumentation.js.map +1 -0
- package/dist/commonjs/instrumenter.d.ts +13 -0
- package/dist/commonjs/instrumenter.d.ts.map +1 -0
- package/dist/commonjs/instrumenter.js +51 -0
- package/dist/commonjs/instrumenter.js.map +1 -0
- package/dist/commonjs/logger.d.ts +5 -0
- package/dist/commonjs/logger.d.ts.map +1 -0
- package/dist/commonjs/logger.js +11 -0
- package/dist/commonjs/logger.js.map +1 -0
- package/dist/commonjs/package.json +3 -0
- package/dist/commonjs/spanWrapper.d.ts +20 -0
- package/dist/commonjs/spanWrapper.d.ts.map +1 -0
- package/dist/commonjs/spanWrapper.js +54 -0
- package/dist/commonjs/spanWrapper.js.map +1 -0
- package/dist/commonjs/transformations.d.ts +29 -0
- package/dist/commonjs/transformations.d.ts.map +1 -0
- package/dist/commonjs/transformations.js +55 -0
- package/dist/commonjs/transformations.js.map +1 -0
- package/{types/latest → dist/commonjs}/tsdoc-metadata.json +1 -1
- package/dist/esm/configuration.d.ts +21 -0
- package/dist/esm/configuration.d.ts.map +1 -0
- package/dist/esm/configuration.js +31 -0
- package/dist/esm/configuration.js.map +1 -0
- package/dist/esm/index.d.ts +3 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +5 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/instrumentation.d.ts +39 -0
- package/dist/esm/instrumentation.d.ts.map +1 -0
- package/{dist-esm/src → dist/esm}/instrumentation.js +4 -4
- package/dist/esm/instrumentation.js.map +1 -0
- package/dist/esm/instrumenter.d.ts +13 -0
- package/dist/esm/instrumenter.d.ts.map +1 -0
- package/dist/esm/instrumenter.js +47 -0
- package/dist/esm/instrumenter.js.map +1 -0
- package/dist/esm/logger.d.ts +5 -0
- package/dist/esm/logger.d.ts.map +1 -0
- package/dist/esm/logger.js +8 -0
- package/dist/esm/logger.js.map +1 -0
- package/dist/esm/package.json +3 -0
- package/dist/esm/spanWrapper.d.ts +20 -0
- package/dist/esm/spanWrapper.d.ts.map +1 -0
- package/dist/esm/spanWrapper.js +50 -0
- package/dist/esm/spanWrapper.js.map +1 -0
- package/dist/esm/transformations.d.ts +29 -0
- package/dist/esm/transformations.d.ts.map +1 -0
- package/dist/esm/transformations.js +51 -0
- package/dist/esm/transformations.js.map +1 -0
- package/dist/react-native/configuration.d.ts +21 -0
- package/dist/react-native/configuration.d.ts.map +1 -0
- package/dist/react-native/configuration.js +31 -0
- package/dist/react-native/configuration.js.map +1 -0
- package/dist/react-native/index.d.ts +3 -0
- package/dist/react-native/index.d.ts.map +1 -0
- package/dist/react-native/index.js +5 -0
- package/dist/react-native/index.js.map +1 -0
- package/dist/react-native/instrumentation.d.ts +39 -0
- package/dist/react-native/instrumentation.d.ts.map +1 -0
- package/dist/react-native/instrumentation.js +52 -0
- package/dist/react-native/instrumentation.js.map +1 -0
- package/dist/react-native/instrumenter.d.ts +13 -0
- package/dist/react-native/instrumenter.d.ts.map +1 -0
- package/dist/react-native/instrumenter.js +47 -0
- package/dist/react-native/instrumenter.js.map +1 -0
- package/dist/react-native/logger.d.ts +5 -0
- package/dist/react-native/logger.d.ts.map +1 -0
- package/dist/react-native/logger.js +8 -0
- package/dist/react-native/logger.js.map +1 -0
- package/dist/react-native/package.json +3 -0
- package/dist/react-native/spanWrapper.d.ts +20 -0
- package/dist/react-native/spanWrapper.d.ts.map +1 -0
- package/dist/react-native/spanWrapper.js +50 -0
- package/dist/react-native/spanWrapper.js.map +1 -0
- package/dist/react-native/transformations.d.ts +29 -0
- package/dist/react-native/transformations.d.ts.map +1 -0
- package/dist/react-native/transformations.js +51 -0
- package/dist/react-native/transformations.js.map +1 -0
- package/package.json +75 -67
- package/types/latest/opentelemetry-instrumentation-azure-sdk.d.ts +15 -0
- package/dist/index.js +0 -246
- package/dist/index.js.map +0 -1
- package/dist-esm/src/configuration.js.map +0 -1
- package/dist-esm/src/index.js +0 -5
- package/dist-esm/src/instrumentation.browser.js.map +0 -1
- package/dist-esm/src/instrumentation.js.map +0 -1
- package/dist-esm/src/instrumenter.js.map +0 -1
- package/dist-esm/src/spanWrapper.js.map +0 -1
- package/dist-esm/src/transformations.js.map +0 -1
package/README.md
CHANGED
|
@@ -58,6 +58,8 @@ registerInstrumentations({
|
|
|
58
58
|
// Continue to import any Azure SDK client libraries after registering the instrumentation.
|
|
59
59
|
|
|
60
60
|
const { KeyClient } = require("@azure/keyvault-keys");
|
|
61
|
+
const { DefaultAzureCredential } = require("@azure/identity");
|
|
62
|
+
|
|
61
63
|
const keyClient = new KeyClient(url, new DefaultAzureCredential());
|
|
62
64
|
|
|
63
65
|
async function main() {
|
|
@@ -94,6 +96,10 @@ setLogLevel("info");
|
|
|
94
96
|
|
|
95
97
|
For more detailed instructions on how to enable logs, you can look at the [@azure/logger package docs](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/core/logger).
|
|
96
98
|
|
|
99
|
+
### Instrumentation for ES Modules
|
|
100
|
+
|
|
101
|
+
This package utilizes [@opentelemetry/instrumentation](https://www.npmjs.com/package/@opentelemetry/instrumentation) to setup the necessary hooks and loaders. Please refer to [@opentelemetry/instrumentation's README](https://github.com/open-telemetry/opentelemetry-js/blob/main/experimental/packages/opentelemetry-instrumentation/README.md#instrumentation-for-es-modules-in-nodejs-experimental) for instructions on configuring tracing for ESM packages.
|
|
102
|
+
|
|
97
103
|
## Contributing
|
|
98
104
|
|
|
99
105
|
If you'd like to contribute to this library, please read the [contributing guide](https://github.com/Azure/azure-sdk-for-js/blob/main/CONTRIBUTING.md) to learn more about how to build and test the code.
|
|
@@ -104,7 +110,6 @@ If you'd like to contribute to this library, please read the [contributing guide
|
|
|
104
110
|
|
|
105
111
|

|
|
106
112
|
|
|
107
|
-
[azure_cli]: https://docs.microsoft.com/cli/azure
|
|
108
113
|
[azure_sub]: https://azure.microsoft.com/free/
|
|
109
114
|
[otel_instrumentation]: https://www.npmjs.com/package/@opentelemetry/instrumentation
|
|
110
|
-
[otel_documentation]: https://opentelemetry.io/docs/js/
|
|
115
|
+
[otel_documentation]: https://opentelemetry.io/docs/languages/js/
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export declare const SDK_VERSION: string;
|
|
2
|
+
/**
|
|
3
|
+
* @internal
|
|
4
|
+
*
|
|
5
|
+
* Keys of known environment variables we look up.
|
|
6
|
+
*/
|
|
7
|
+
export type KnownEnvironmentKey = "AZURE_HTTP_TRACING_CHILDREN_DISABLED" | "AZURE_TRACING_DISABLED";
|
|
8
|
+
/**
|
|
9
|
+
* @internal
|
|
10
|
+
*
|
|
11
|
+
* Cached values of environment variables that were fetched.
|
|
12
|
+
*/
|
|
13
|
+
export declare const environmentCache: Map<KnownEnvironmentKey, string | undefined>;
|
|
14
|
+
/**
|
|
15
|
+
* Converts an environment variable to Boolean.
|
|
16
|
+
* the strings "false" and "0" are treated as falsy values.
|
|
17
|
+
*
|
|
18
|
+
* @internal
|
|
19
|
+
*/
|
|
20
|
+
export declare function envVarToBoolean(key: KnownEnvironmentKey): boolean;
|
|
21
|
+
//# sourceMappingURL=configuration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configuration.d.ts","sourceRoot":"","sources":["../../src/configuration.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,WAAW,EAAE,MAAuB,CAAC;AAElD;;;;GAIG;AACH,MAAM,MAAM,mBAAmB,GAAG,sCAAsC,GAAG,wBAAwB,CAAC;AAEpG;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,8CAAqD,CAAC;AAEnF;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,mBAAmB,GAAG,OAAO,CAMjE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configuration.js","sourceRoot":"","sources":["../../src/configuration.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,MAAM,CAAC,MAAM,WAAW,GAAW,cAAc,CAAC;AASlD;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,GAAG,EAA2C,CAAC;AAEnF;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAAC,GAAwB;;IACtD,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;QAC/B,uBAAuB,CAAC,GAAG,CAAC,CAAC;IAC/B,CAAC;IACD,MAAM,KAAK,GAAG,CAAC,MAAA,gBAAgB,CAAC,GAAG,CAAC,GAAG,CAAC,mCAAI,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;IAC9D,OAAO,KAAK,KAAK,OAAO,IAAI,KAAK,KAAK,GAAG,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9D,CAAC;AAED,SAAS,uBAAuB,CAAC,GAAwB;;IACvD,IAAI,OAAO,OAAO,KAAK,WAAW,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;QAClD,MAAM,QAAQ,GAAG,MAAA,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,mCAAI,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,CAAC;QACpE,gBAAgB,CAAC,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;IACtC,CAAC;AACH,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nexport const SDK_VERSION: string = \"1.0.0-beta.7\";\n\n/**\n * @internal\n *\n * Keys of known environment variables we look up.\n */\nexport type KnownEnvironmentKey = \"AZURE_HTTP_TRACING_CHILDREN_DISABLED\" | \"AZURE_TRACING_DISABLED\";\n\n/**\n * @internal\n *\n * Cached values of environment variables that were fetched.\n */\nexport const environmentCache = new Map<KnownEnvironmentKey, string | undefined>();\n\n/**\n * Converts an environment variable to Boolean.\n * the strings \"false\" and \"0\" are treated as falsy values.\n *\n * @internal\n */\nexport function envVarToBoolean(key: KnownEnvironmentKey): boolean {\n if (!environmentCache.has(key)) {\n loadEnvironmentVariable(key);\n }\n const value = (environmentCache.get(key) ?? \"\").toLowerCase();\n return value !== \"false\" && value !== \"0\" && Boolean(value);\n}\n\nfunction loadEnvironmentVariable(key: KnownEnvironmentKey): void {\n if (typeof process !== \"undefined\" && process.env) {\n const rawValue = process.env[key] ?? process.env[key.toLowerCase()];\n environmentCache.set(key, rawValue);\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAGA,cAAc,aAAa,CAAC;AAC5B,cAAc,sBAAsB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,cAAc,aAAa,CAAC;AAC5B,cAAc,sBAAsB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nexport * from \"./logger.js\";\nexport * from \"./instrumentation.js\";\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instrumentation-browser.d.mts","sourceRoot":"","sources":["../../src/instrumentation-browser.mts"],"names":[],"mappings":"AAGA,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,qBAAqB,EACtB,MAAM,gCAAgC,CAAC;AAMxC;;GAEG;AACH,MAAM,WAAW,8BAA+B,SAAQ,qBAAqB;CAAG;AAEhF;;GAEG;AACH,qBAAa,uBAAwB,SAAQ,mBAAmB;gBAClD,OAAO,GAAE,8BAAmC;IAOxD,2GAA2G;IAC3G,SAAS,CAAC,IAAI,IAAI,IAAI;IAItB;;OAEG;IACH,MAAM,IAAI,IAAI;IAId,OAAO,IAAI,IAAI;CAGhB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,6BAA6B,CAC3C,OAAO,GAAE,8BAAmC,GAC3C,eAAe,CAEjB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instrumentation-browser.mjs","sourceRoot":"","sources":["../../src/instrumentation-browser.mts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAEL,mBAAmB,GAEpB,MAAM,gCAAgC,CAAC;AAExC,OAAO,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAOtD;;GAEG;AACH,MAAM,OAAO,uBAAwB,SAAQ,mBAAmB;IAC9D,YAAY,UAA0C,EAAE;QACtD,KAAK,CACH,gDAAgD,EAChD,WAAW,EACX,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,OAAO,CAAC,CAC3B,CAAC;IACJ,CAAC;IACD,2GAA2G;IACjG,IAAI;QACZ,QAAQ;IACV,CAAC;IAED;;OAEG;IACH,MAAM;QACJ,eAAe,CAAC,IAAI,yBAAyB,EAAE,CAAC,CAAC;IACnD,CAAC;IAED,OAAO;QACL,QAAQ;IACV,CAAC;CACF;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,6BAA6B,CAC3C,UAA0C,EAAE;IAE5C,OAAO,IAAI,uBAAuB,CAAC,OAAO,CAAC,CAAC;AAC9C,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport {\n Instrumentation,\n InstrumentationBase,\n InstrumentationConfig,\n} from \"@opentelemetry/instrumentation\";\n\nimport { OpenTelemetryInstrumenter } from \"./instrumenter.js\";\nimport { SDK_VERSION } from \"./configuration.js\";\nimport { useInstrumenter } from \"@azure/core-tracing\";\n\n/**\n * Configuration options that can be passed to {@link createAzureSdkInstrumentation} function.\n */\nexport interface AzureSdkInstrumentationOptions extends InstrumentationConfig {}\n\n/**\n * The instrumentation module for the Azure SDK. Implements OpenTelemetry's {@link Instrumentation}.\n */\nexport class AzureSdkInstrumentation extends InstrumentationBase {\n constructor(options: AzureSdkInstrumentationOptions = {}) {\n super(\n \"@azure/opentelemetry-instrumentation-azure-sdk\",\n SDK_VERSION,\n Object.assign({}, options),\n );\n }\n /** In the browser we rely on overriding the `enable` function instead as there are no modules to patch. */\n protected init(): void {\n // no-op\n }\n\n /**\n * Entrypoint for the module registration. Ensures the global instrumenter is set to use OpenTelemetry.\n */\n enable(): void {\n useInstrumenter(new OpenTelemetryInstrumenter());\n }\n\n disable(): void {\n // no-op\n }\n}\n\n/**\n * Enables Azure SDK Instrumentation using OpenTelemetry for Azure SDK client libraries.\n *\n * When registered, any Azure data plane package will begin emitting tracing spans for internal calls\n * as well as network calls\n *\n * Example usage:\n * ```ts\n * const openTelemetryInstrumentation = require(\"@opentelemetry/instrumentation\");\n * openTelemetryInstrumentation.registerInstrumentations({\n * instrumentations: [createAzureSdkInstrumentation()],\n * })\n * ```\n */\nexport function createAzureSdkInstrumentation(\n options: AzureSdkInstrumentationOptions = {},\n): Instrumentation {\n return new AzureSdkInstrumentation(options);\n}\n"]}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Instrumentation, InstrumentationBase, InstrumentationConfig } from "@opentelemetry/instrumentation";
|
|
2
|
+
/**
|
|
3
|
+
* Configuration options that can be passed to {@link createAzureSdkInstrumentation} function.
|
|
4
|
+
*/
|
|
5
|
+
export interface AzureSdkInstrumentationOptions extends InstrumentationConfig {
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* The instrumentation module for the Azure SDK. Implements OpenTelemetry's {@link Instrumentation}.
|
|
9
|
+
*/
|
|
10
|
+
export declare class AzureSdkInstrumentation extends InstrumentationBase {
|
|
11
|
+
constructor(options?: AzureSdkInstrumentationOptions);
|
|
12
|
+
/** In the browser we rely on overriding the `enable` function instead as there are no modules to patch. */
|
|
13
|
+
protected init(): void;
|
|
14
|
+
/**
|
|
15
|
+
* Entrypoint for the module registration. Ensures the global instrumenter is set to use OpenTelemetry.
|
|
16
|
+
*/
|
|
17
|
+
enable(): void;
|
|
18
|
+
disable(): void;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Enables Azure SDK Instrumentation using OpenTelemetry for Azure SDK client libraries.
|
|
22
|
+
*
|
|
23
|
+
* When registered, any Azure data plane package will begin emitting tracing spans for internal calls
|
|
24
|
+
* as well as network calls
|
|
25
|
+
*
|
|
26
|
+
* Example usage:
|
|
27
|
+
* ```ts
|
|
28
|
+
* const openTelemetryInstrumentation = require("@opentelemetry/instrumentation");
|
|
29
|
+
* openTelemetryInstrumentation.registerInstrumentations({
|
|
30
|
+
* instrumentations: [createAzureSdkInstrumentation()],
|
|
31
|
+
* })
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export declare function createAzureSdkInstrumentation(options?: AzureSdkInstrumentationOptions): Instrumentation;
|
|
35
|
+
//# sourceMappingURL=instrumentation-browser.d.mts.map
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
// Copyright (c) Microsoft Corporation.
|
|
2
|
-
// Licensed under the MIT
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
3
|
import { InstrumentationBase, } from "@opentelemetry/instrumentation";
|
|
4
|
-
import { OpenTelemetryInstrumenter } from "./instrumenter";
|
|
5
|
-
import { SDK_VERSION } from "./configuration";
|
|
4
|
+
import { OpenTelemetryInstrumenter } from "./instrumenter.js";
|
|
5
|
+
import { SDK_VERSION } from "./configuration.js";
|
|
6
6
|
import { useInstrumenter } from "@azure/core-tracing";
|
|
7
7
|
/**
|
|
8
8
|
* The instrumentation module for the Azure SDK. Implements OpenTelemetry's {@link Instrumentation}.
|
|
9
9
|
*/
|
|
10
|
-
class AzureSdkInstrumentation extends InstrumentationBase {
|
|
10
|
+
export class AzureSdkInstrumentation extends InstrumentationBase {
|
|
11
11
|
constructor(options = {}) {
|
|
12
12
|
super("@azure/opentelemetry-instrumentation-azure-sdk", SDK_VERSION, Object.assign({}, options));
|
|
13
13
|
}
|
|
@@ -42,4 +42,4 @@ class AzureSdkInstrumentation extends InstrumentationBase {
|
|
|
42
42
|
export function createAzureSdkInstrumentation(options = {}) {
|
|
43
43
|
return new AzureSdkInstrumentation(options);
|
|
44
44
|
}
|
|
45
|
-
//# sourceMappingURL=instrumentation
|
|
45
|
+
//# sourceMappingURL=instrumentation-browser.mjs.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Instrumenter, InstrumenterSpanOptions, TracingContext, TracingSpan } from "@azure/core-tracing";
|
|
2
|
+
import { W3CTraceContextPropagator } from "@opentelemetry/core";
|
|
3
|
+
export declare const propagator: W3CTraceContextPropagator;
|
|
4
|
+
export declare class OpenTelemetryInstrumenter implements Instrumenter {
|
|
5
|
+
startSpan(name: string, spanOptions: InstrumenterSpanOptions): {
|
|
6
|
+
span: TracingSpan;
|
|
7
|
+
tracingContext: TracingContext;
|
|
8
|
+
};
|
|
9
|
+
withContext<CallbackArgs extends unknown[], Callback extends (...args: CallbackArgs) => ReturnType<Callback>>(tracingContext: TracingContext, callback: Callback, ...callbackArgs: CallbackArgs): ReturnType<Callback>;
|
|
10
|
+
parseTraceparentHeader(traceparentHeader: string): TracingContext;
|
|
11
|
+
createRequestHeaders(tracingContext?: TracingContext): Record<string, string>;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=instrumenter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instrumenter.d.ts","sourceRoot":"","sources":["../../src/instrumenter.ts"],"names":[],"mappings":"AAWA,OAAO,EACL,YAAY,EACZ,uBAAuB,EACvB,cAAc,EACd,WAAW,EACZ,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,yBAAyB,EAAmB,MAAM,qBAAqB,CAAC;AAOjF,eAAO,MAAM,UAAU,2BAAkC,CAAC;AAE1D,qBAAa,yBAA0B,YAAW,YAAY;IAC5D,SAAS,CACP,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,uBAAuB,GACnC;QAAE,IAAI,EAAE,WAAW,CAAC;QAAC,cAAc,EAAE,cAAc,CAAA;KAAE;IA2BxD,WAAW,CACT,YAAY,SAAS,OAAO,EAAE,EAC9B,QAAQ,SAAS,CAAC,GAAG,IAAI,EAAE,YAAY,KAAK,UAAU,CAAC,QAAQ,CAAC,EAEhE,cAAc,EAAE,cAAc,EAC9B,QAAQ,EAAE,QAAQ,EAClB,GAAG,YAAY,EAAE,YAAY,GAC5B,UAAU,CAAC,QAAQ,CAAC;IASvB,sBAAsB,CAAC,iBAAiB,EAAE,MAAM,GAAG,cAAc;IAQjE,oBAAoB,CAAC,cAAc,CAAC,EAAE,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;CAK9E"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// Copyright (c) Microsoft Corporation.
|
|
2
|
-
// Licensed under the MIT
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
3
|
import { INVALID_SPAN_CONTEXT, context, defaultTextMapGetter, defaultTextMapSetter, trace, } from "@opentelemetry/api";
|
|
4
4
|
import { W3CTraceContextPropagator, suppressTracing } from "@opentelemetry/core";
|
|
5
|
-
import { OpenTelemetrySpanWrapper } from "./spanWrapper";
|
|
6
|
-
import { envVarToBoolean } from "./configuration";
|
|
7
|
-
import { toSpanOptions } from "./transformations";
|
|
5
|
+
import { OpenTelemetrySpanWrapper } from "./spanWrapper.js";
|
|
6
|
+
import { envVarToBoolean } from "./configuration.js";
|
|
7
|
+
import { toSpanOptions } from "./transformations.js";
|
|
8
8
|
// While default propagation is user-configurable, Azure services always use the W3C implementation.
|
|
9
9
|
export const propagator = new W3CTraceContextPropagator();
|
|
10
10
|
export class OpenTelemetryInstrumenter {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instrumenter.js","sourceRoot":"","sources":["../../src/instrumenter.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EACL,oBAAoB,EAEpB,OAAO,EACP,oBAAoB,EACpB,oBAAoB,EACpB,KAAK,GACN,MAAM,oBAAoB,CAAC;AAO5B,OAAO,EAAE,yBAAyB,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEjF,OAAO,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAErD,oGAAoG;AACpG,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,yBAAyB,EAAE,CAAC;AAE1D,MAAM,OAAO,yBAAyB;IACpC,SAAS,CACP,IAAY,EACZ,WAAoC;QAEpC,IAAI,GAAG,GAAG,CAAA,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,cAAc,KAAI,OAAO,CAAC,MAAM,EAAE,CAAC;QAC1D,IAAI,IAAU,CAAC;QAEf,IAAI,eAAe,CAAC,wBAAwB,CAAC,EAAE,CAAC;YAC9C,sDAAsD;YACtD,IAAI,GAAG,KAAK,CAAC,eAAe,CAAC,oBAAoB,CAAC,CAAC;QACrD,CAAC;aAAM,CAAC;YACN,kBAAkB;YAClB,IAAI,GAAG,KAAK;iBACT,SAAS,CAAC,WAAW,CAAC,WAAW,EAAE,WAAW,CAAC,cAAc,CAAC;iBAC9D,SAAS,CAAC,IAAI,EAAE,aAAa,CAAC,WAAW,CAAC,EAAE,GAAG,CAAC,CAAC;YAEpD,IACE,eAAe,CAAC,sCAAsC,CAAC;gBACvD,IAAI,CAAC,WAAW,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,EACrC,CAAC;gBACD,2BAA2B;gBAC3B,GAAG,GAAG,eAAe,CAAC,GAAG,CAAC,CAAC;YAC7B,CAAC;QACH,CAAC;QAED,OAAO;YACL,IAAI,EAAE,IAAI,wBAAwB,CAAC,IAAI,CAAC;YACxC,cAAc,EAAE,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC;SACzC,CAAC;IACJ,CAAC;IACD,WAAW,CAIT,cAA8B,EAC9B,QAAkB,EAClB,GAAG,YAA0B;QAE7B,OAAO,OAAO,CAAC,IAAI,CACjB,cAAc,EACd,QAAQ;QACR,4DAA4D,CAAC,SAAS,EACtE,GAAG,YAAY,CAChB,CAAC;IACJ,CAAC;IAED,sBAAsB,CAAC,iBAAyB;QAC9C,OAAO,UAAU,CAAC,OAAO,CACvB,OAAO,CAAC,MAAM,EAAE,EAChB,EAAE,WAAW,EAAE,iBAAiB,EAAE,EAClC,oBAAoB,CACrB,CAAC;IACJ,CAAC;IAED,oBAAoB,CAAC,cAA+B;QAClD,MAAM,OAAO,GAA2B,EAAE,CAAC;QAC3C,UAAU,CAAC,MAAM,CAAC,cAAc,IAAI,OAAO,CAAC,MAAM,EAAE,EAAE,OAAO,EAAE,oBAAoB,CAAC,CAAC;QACrF,OAAO,OAAO,CAAC;IACjB,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport {\n INVALID_SPAN_CONTEXT,\n Span,\n context,\n defaultTextMapGetter,\n defaultTextMapSetter,\n trace,\n} from \"@opentelemetry/api\";\nimport {\n Instrumenter,\n InstrumenterSpanOptions,\n TracingContext,\n TracingSpan,\n} from \"@azure/core-tracing\";\nimport { W3CTraceContextPropagator, suppressTracing } from \"@opentelemetry/core\";\n\nimport { OpenTelemetrySpanWrapper } from \"./spanWrapper.js\";\nimport { envVarToBoolean } from \"./configuration.js\";\nimport { toSpanOptions } from \"./transformations.js\";\n\n// While default propagation is user-configurable, Azure services always use the W3C implementation.\nexport const propagator = new W3CTraceContextPropagator();\n\nexport class OpenTelemetryInstrumenter implements Instrumenter {\n startSpan(\n name: string,\n spanOptions: InstrumenterSpanOptions,\n ): { span: TracingSpan; tracingContext: TracingContext } {\n let ctx = spanOptions?.tracingContext || context.active();\n let span: Span;\n\n if (envVarToBoolean(\"AZURE_TRACING_DISABLED\")) {\n // disable only our spans but not any downstream spans\n span = trace.wrapSpanContext(INVALID_SPAN_CONTEXT);\n } else {\n // Create our span\n span = trace\n .getTracer(spanOptions.packageName, spanOptions.packageVersion)\n .startSpan(name, toSpanOptions(spanOptions), ctx);\n\n if (\n envVarToBoolean(\"AZURE_HTTP_TRACING_CHILDREN_DISABLED\") &&\n name.toUpperCase().startsWith(\"HTTP\")\n ) {\n // disable downstream spans\n ctx = suppressTracing(ctx);\n }\n }\n\n return {\n span: new OpenTelemetrySpanWrapper(span),\n tracingContext: trace.setSpan(ctx, span),\n };\n }\n withContext<\n CallbackArgs extends unknown[],\n Callback extends (...args: CallbackArgs) => ReturnType<Callback>,\n >(\n tracingContext: TracingContext,\n callback: Callback,\n ...callbackArgs: CallbackArgs\n ): ReturnType<Callback> {\n return context.with(\n tracingContext,\n callback,\n /** Assume caller will bind `this` or use arrow functions */ undefined,\n ...callbackArgs,\n );\n }\n\n parseTraceparentHeader(traceparentHeader: string): TracingContext {\n return propagator.extract(\n context.active(),\n { traceparent: traceparentHeader },\n defaultTextMapGetter,\n );\n }\n\n createRequestHeaders(tracingContext?: TracingContext): Record<string, string> {\n const headers: Record<string, string> = {};\n propagator.inject(tracingContext || context.active(), headers, defaultTextMapSetter);\n return headers;\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/logger.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,eAAO,MAAM,MAAM,qCAAgE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/logger.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAEnD;;GAEG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,kBAAkB,CAAC,yCAAyC,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/logger.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAEnD;;GAEG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,kBAAkB,CAAC,yCAAyC,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { createClientLogger } from \"@azure/logger\";\n\n/**\n * The \\@azure/logger configuration for this package.\n */\nexport const logger = createClientLogger(\"opentelemetry-instrumentation-azure-sdk\");\n"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Span } from "@opentelemetry/api";
|
|
2
|
+
import { SpanStatus, TracingSpan, AddEventOptions } from "@azure/core-tracing";
|
|
3
|
+
export declare class OpenTelemetrySpanWrapper implements TracingSpan {
|
|
4
|
+
private _span;
|
|
5
|
+
constructor(span: Span);
|
|
6
|
+
setStatus(status: SpanStatus): void;
|
|
7
|
+
setAttribute(name: string, value: unknown): void;
|
|
8
|
+
end(): void;
|
|
9
|
+
recordException(exception: string | Error): void;
|
|
10
|
+
isRecording(): boolean;
|
|
11
|
+
addEvent(name: string, options?: AddEventOptions): void;
|
|
12
|
+
/**
|
|
13
|
+
* Allows getting the wrapped span as needed.
|
|
14
|
+
* @internal
|
|
15
|
+
*
|
|
16
|
+
* @returns The underlying span
|
|
17
|
+
*/
|
|
18
|
+
unwrap(): Span;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=spanWrapper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spanWrapper.d.ts","sourceRoot":"","sources":["../../src/spanWrapper.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,IAAI,EAAkB,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAG/E,qBAAa,wBAAyB,YAAW,WAAW;IAC1D,OAAO,CAAC,KAAK,CAAO;gBAER,IAAI,EAAE,IAAI;IAItB,SAAS,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;IAanC,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI;IAMhD,GAAG,IAAI,IAAI;IAIX,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,KAAK,GAAG,IAAI;IAIhD,WAAW,IAAI,OAAO;IAItB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,eAAoB,GAAG,IAAI;IAI3D;;;;;OAKG;IACH,MAAM,IAAI,IAAI;CAGf"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// Copyright (c) Microsoft Corporation.
|
|
2
|
-
// Licensed under the MIT
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
3
|
import { SpanStatusCode } from "@opentelemetry/api";
|
|
4
|
+
import { isAttributeValue, sanitizeAttributes } from "@opentelemetry/core";
|
|
4
5
|
export class OpenTelemetrySpanWrapper {
|
|
5
6
|
constructor(span) {
|
|
6
7
|
this._span = span;
|
|
@@ -20,7 +21,7 @@ export class OpenTelemetrySpanWrapper {
|
|
|
20
21
|
}
|
|
21
22
|
}
|
|
22
23
|
setAttribute(name, value) {
|
|
23
|
-
if (value !== null && value !== undefined) {
|
|
24
|
+
if (value !== null && value !== undefined && isAttributeValue(value)) {
|
|
24
25
|
this._span.setAttribute(name, value);
|
|
25
26
|
}
|
|
26
27
|
}
|
|
@@ -33,6 +34,9 @@ export class OpenTelemetrySpanWrapper {
|
|
|
33
34
|
isRecording() {
|
|
34
35
|
return this._span.isRecording();
|
|
35
36
|
}
|
|
37
|
+
addEvent(name, options = {}) {
|
|
38
|
+
this._span.addEvent(name, sanitizeAttributes(options.attributes), options.startTime);
|
|
39
|
+
}
|
|
36
40
|
/**
|
|
37
41
|
* Allows getting the wrapped span as needed.
|
|
38
42
|
* @internal
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spanWrapper.js","sourceRoot":"","sources":["../../src/spanWrapper.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAQ,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAE1D,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAE3E,MAAM,OAAO,wBAAwB;IAGnC,YAAY,IAAU;QACpB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACpB,CAAC;IAED,SAAS,CAAC,MAAkB;QAC1B,IAAI,MAAM,CAAC,MAAM,KAAK,OAAO,EAAE,CAAC;YAC9B,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;gBACjB,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,cAAc,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;gBACvF,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YACrC,CAAC;iBAAM,CAAC;gBACN,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,cAAc,CAAC,KAAK,EAAE,CAAC,CAAC;YACvD,CAAC;QACH,CAAC;aAAM,IAAI,MAAM,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;YACvC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,cAAc,CAAC,EAAE,EAAE,CAAC,CAAC;QACpD,CAAC;IACH,CAAC;IAED,YAAY,CAAC,IAAY,EAAE,KAAc;QACvC,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,IAAI,gBAAgB,CAAC,KAAK,CAAC,EAAE,CAAC;YACrE,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QACvC,CAAC;IACH,CAAC;IAED,GAAG;QACD,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;IACnB,CAAC;IAED,eAAe,CAAC,SAAyB;QACvC,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC;IACxC,CAAC;IAED,WAAW;QACT,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC;IAClC,CAAC;IAED,QAAQ,CAAC,IAAY,EAAE,UAA2B,EAAE;QAClD,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,EAAE,kBAAkB,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;IACvF,CAAC;IAED;;;;;OAKG;IACH,MAAM;QACJ,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { Span, SpanStatusCode } from \"@opentelemetry/api\";\nimport { SpanStatus, TracingSpan, AddEventOptions } from \"@azure/core-tracing\";\nimport { isAttributeValue, sanitizeAttributes } from \"@opentelemetry/core\";\n\nexport class OpenTelemetrySpanWrapper implements TracingSpan {\n private _span: Span;\n\n constructor(span: Span) {\n this._span = span;\n }\n\n setStatus(status: SpanStatus): void {\n if (status.status === \"error\") {\n if (status.error) {\n this._span.setStatus({ code: SpanStatusCode.ERROR, message: status.error.toString() });\n this.recordException(status.error);\n } else {\n this._span.setStatus({ code: SpanStatusCode.ERROR });\n }\n } else if (status.status === \"success\") {\n this._span.setStatus({ code: SpanStatusCode.OK });\n }\n }\n\n setAttribute(name: string, value: unknown): void {\n if (value !== null && value !== undefined && isAttributeValue(value)) {\n this._span.setAttribute(name, value);\n }\n }\n\n end(): void {\n this._span.end();\n }\n\n recordException(exception: string | Error): void {\n this._span.recordException(exception);\n }\n\n isRecording(): boolean {\n return this._span.isRecording();\n }\n\n addEvent(name: string, options: AddEventOptions = {}): void {\n this._span.addEvent(name, sanitizeAttributes(options.attributes), options.startTime);\n }\n\n /**\n * Allows getting the wrapped span as needed.\n * @internal\n *\n * @returns The underlying span\n */\n unwrap(): Span {\n return this._span;\n }\n}\n"]}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { InstrumenterSpanOptions, TracingSpanKind } from "@azure/core-tracing";
|
|
2
|
+
import { SpanKind, SpanOptions } from "@opentelemetry/api";
|
|
3
|
+
/**
|
|
4
|
+
* Converts our TracingSpanKind to the corresponding OpenTelemetry SpanKind.
|
|
5
|
+
*
|
|
6
|
+
* By default it will return {@link SpanKind.INTERNAL}
|
|
7
|
+
* @param tracingSpanKind - The core tracing {@link TracingSpanKind}
|
|
8
|
+
* @returns - The OpenTelemetry {@link SpanKind}
|
|
9
|
+
*/
|
|
10
|
+
export declare function toOpenTelemetrySpanKind<K extends TracingSpanKind>(tracingSpanKind?: K): SpanKindMapping[K];
|
|
11
|
+
/**
|
|
12
|
+
* A mapping between our {@link TracingSpanKind} union type and OpenTelemetry's {@link SpanKind}.
|
|
13
|
+
*/
|
|
14
|
+
type SpanKindMapping = {
|
|
15
|
+
client: SpanKind.CLIENT;
|
|
16
|
+
server: SpanKind.SERVER;
|
|
17
|
+
producer: SpanKind.PRODUCER;
|
|
18
|
+
consumer: SpanKind.CONSUMER;
|
|
19
|
+
internal: SpanKind.INTERNAL;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Converts core-tracing span options to OpenTelemetry options.
|
|
23
|
+
*
|
|
24
|
+
* @param spanOptions - The {@link InstrumenterSpanOptions} to convert.
|
|
25
|
+
* @returns An OpenTelemetry {@link SpanOptions} that can be used when creating a span.
|
|
26
|
+
*/
|
|
27
|
+
export declare function toSpanOptions(spanOptions?: InstrumenterSpanOptions): SpanOptions;
|
|
28
|
+
export {};
|
|
29
|
+
//# sourceMappingURL=transformations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transformations.d.ts","sourceRoot":"","sources":["../../src/transformations.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,uBAAuB,EAAE,eAAe,EAAmB,MAAM,qBAAqB,CAAC;AAChG,OAAO,EAAQ,QAAQ,EAAE,WAAW,EAAS,MAAM,oBAAoB,CAAC;AAGxE;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,CAAC,SAAS,eAAe,EAC/D,eAAe,CAAC,EAAE,CAAC,GAClB,eAAe,CAAC,CAAC,CAAC,CAGpB;AAED;;GAEG;AACH,KAAK,eAAe,GAAG;IACrB,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC;IACxB,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC;IACxB,QAAQ,EAAE,QAAQ,CAAC,QAAQ,CAAC;IAC5B,QAAQ,EAAE,QAAQ,CAAC,QAAQ,CAAC;IAC5B,QAAQ,EAAE,QAAQ,CAAC,QAAQ,CAAC;CAC7B,CAAC;AAqBF;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,WAAW,CAAC,EAAE,uBAAuB,GAAG,WAAW,CAYhF"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// Copyright (c) Microsoft Corporation.
|
|
2
|
-
// Licensed under the MIT
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
3
|
import { SpanKind, trace } from "@opentelemetry/api";
|
|
4
|
+
import { sanitizeAttributes } from "@opentelemetry/core";
|
|
4
5
|
/**
|
|
5
6
|
* Converts our TracingSpanKind to the corresponding OpenTelemetry SpanKind.
|
|
6
7
|
*
|
|
@@ -24,28 +25,12 @@ function toOpenTelemetryLinks(spanLinks = []) {
|
|
|
24
25
|
if (spanContext) {
|
|
25
26
|
acc.push({
|
|
26
27
|
context: spanContext,
|
|
27
|
-
attributes:
|
|
28
|
+
attributes: sanitizeAttributes(tracingSpanLink.attributes),
|
|
28
29
|
});
|
|
29
30
|
}
|
|
30
31
|
return acc;
|
|
31
32
|
}, []);
|
|
32
33
|
}
|
|
33
|
-
/**
|
|
34
|
-
* Converts core-tracing's span attributes to OpenTelemetry attributes.
|
|
35
|
-
*
|
|
36
|
-
* @param spanAttributes - The set of attributes to convert.
|
|
37
|
-
* @returns An {@link SpanAttributes} to set on a span.
|
|
38
|
-
*/
|
|
39
|
-
function toOpenTelemetrySpanAttributes(spanAttributes) {
|
|
40
|
-
const attributes = {};
|
|
41
|
-
for (const key in spanAttributes) {
|
|
42
|
-
// Any non-nullish value is allowed.
|
|
43
|
-
if (spanAttributes[key] !== null && spanAttributes[key] !== undefined) {
|
|
44
|
-
attributes[key] = spanAttributes[key];
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
return attributes;
|
|
48
|
-
}
|
|
49
34
|
/**
|
|
50
35
|
* Converts core-tracing span options to OpenTelemetry options.
|
|
51
36
|
*
|
|
@@ -54,7 +39,7 @@ function toOpenTelemetrySpanAttributes(spanAttributes) {
|
|
|
54
39
|
*/
|
|
55
40
|
export function toSpanOptions(spanOptions) {
|
|
56
41
|
const { spanAttributes, spanLinks, spanKind } = spanOptions || {};
|
|
57
|
-
const attributes =
|
|
42
|
+
const attributes = sanitizeAttributes(spanAttributes);
|
|
58
43
|
const kind = toOpenTelemetrySpanKind(spanKind);
|
|
59
44
|
const links = toOpenTelemetryLinks(spanLinks);
|
|
60
45
|
return {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transformations.js","sourceRoot":"","sources":["../../src/transformations.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAQ,QAAQ,EAAe,KAAK,EAAE,MAAM,oBAAoB,CAAC;AACxE,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAEzD;;;;;;GAMG;AACH,MAAM,UAAU,uBAAuB,CACrC,eAAmB;IAEnB,MAAM,GAAG,GAAG,CAAC,eAAe,IAAI,UAAU,CAAC,CAAC,WAAW,EAA2B,CAAC;IACnF,OAAO,QAAQ,CAAC,GAAG,CAAuB,CAAC;AAC7C,CAAC;AAaD;;;;;GAKG;AACH,SAAS,oBAAoB,CAAC,YAA+B,EAAE;IAC7D,OAAO,SAAS,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,eAAe,EAAE,EAAE;QAC/C,MAAM,WAAW,GAAG,KAAK,CAAC,cAAc,CAAC,eAAe,CAAC,cAAc,CAAC,CAAC;QACzE,IAAI,WAAW,EAAE,CAAC;YAChB,GAAG,CAAC,IAAI,CAAC;gBACP,OAAO,EAAE,WAAW;gBACpB,UAAU,EAAE,kBAAkB,CAAC,eAAe,CAAC,UAAU,CAAC;aAC3D,CAAC,CAAC;QACL,CAAC;QACD,OAAO,GAAG,CAAC;IACb,CAAC,EAAE,EAAY,CAAC,CAAC;AACnB,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAAC,WAAqC;IACjE,MAAM,EAAE,cAAc,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,WAAW,IAAI,EAAE,CAAC;IAElE,MAAM,UAAU,GAAG,kBAAkB,CAAC,cAAc,CAAC,CAAC;IACtD,MAAM,IAAI,GAAG,uBAAuB,CAAC,QAAQ,CAAC,CAAC;IAC/C,MAAM,KAAK,GAAG,oBAAoB,CAAC,SAAS,CAAC,CAAC;IAE9C,OAAO;QACL,UAAU;QACV,IAAI;QACJ,KAAK;KACN,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { InstrumenterSpanOptions, TracingSpanKind, TracingSpanLink } from \"@azure/core-tracing\";\nimport { Link, SpanKind, SpanOptions, trace } from \"@opentelemetry/api\";\nimport { sanitizeAttributes } from \"@opentelemetry/core\";\n\n/**\n * Converts our TracingSpanKind to the corresponding OpenTelemetry SpanKind.\n *\n * By default it will return {@link SpanKind.INTERNAL}\n * @param tracingSpanKind - The core tracing {@link TracingSpanKind}\n * @returns - The OpenTelemetry {@link SpanKind}\n */\nexport function toOpenTelemetrySpanKind<K extends TracingSpanKind>(\n tracingSpanKind?: K,\n): SpanKindMapping[K] {\n const key = (tracingSpanKind || \"internal\").toUpperCase() as keyof typeof SpanKind;\n return SpanKind[key] as SpanKindMapping[K];\n}\n\n/**\n * A mapping between our {@link TracingSpanKind} union type and OpenTelemetry's {@link SpanKind}.\n */\ntype SpanKindMapping = {\n client: SpanKind.CLIENT;\n server: SpanKind.SERVER;\n producer: SpanKind.PRODUCER;\n consumer: SpanKind.CONSUMER;\n internal: SpanKind.INTERNAL;\n};\n\n/**\n * Converts core-tracing's TracingSpanLink to OpenTelemetry's Link\n *\n * @param spanLinks - The core tracing {@link TracingSpanLink} to convert\n * @returns A set of {@link Link}s\n */\nfunction toOpenTelemetryLinks(spanLinks: TracingSpanLink[] = []): Link[] {\n return spanLinks.reduce((acc, tracingSpanLink) => {\n const spanContext = trace.getSpanContext(tracingSpanLink.tracingContext);\n if (spanContext) {\n acc.push({\n context: spanContext,\n attributes: sanitizeAttributes(tracingSpanLink.attributes),\n });\n }\n return acc;\n }, [] as Link[]);\n}\n\n/**\n * Converts core-tracing span options to OpenTelemetry options.\n *\n * @param spanOptions - The {@link InstrumenterSpanOptions} to convert.\n * @returns An OpenTelemetry {@link SpanOptions} that can be used when creating a span.\n */\nexport function toSpanOptions(spanOptions?: InstrumenterSpanOptions): SpanOptions {\n const { spanAttributes, spanLinks, spanKind } = spanOptions || {};\n\n const attributes = sanitizeAttributes(spanAttributes);\n const kind = toOpenTelemetrySpanKind(spanKind);\n const links = toOpenTelemetryLinks(spanLinks);\n\n return {\n attributes,\n kind,\n links,\n };\n}\n"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export declare const SDK_VERSION: string;
|
|
2
|
+
/**
|
|
3
|
+
* @internal
|
|
4
|
+
*
|
|
5
|
+
* Keys of known environment variables we look up.
|
|
6
|
+
*/
|
|
7
|
+
export type KnownEnvironmentKey = "AZURE_HTTP_TRACING_CHILDREN_DISABLED" | "AZURE_TRACING_DISABLED";
|
|
8
|
+
/**
|
|
9
|
+
* @internal
|
|
10
|
+
*
|
|
11
|
+
* Cached values of environment variables that were fetched.
|
|
12
|
+
*/
|
|
13
|
+
export declare const environmentCache: Map<KnownEnvironmentKey, string | undefined>;
|
|
14
|
+
/**
|
|
15
|
+
* Converts an environment variable to Boolean.
|
|
16
|
+
* the strings "false" and "0" are treated as falsy values.
|
|
17
|
+
*
|
|
18
|
+
* @internal
|
|
19
|
+
*/
|
|
20
|
+
export declare function envVarToBoolean(key: KnownEnvironmentKey): boolean;
|
|
21
|
+
//# sourceMappingURL=configuration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configuration.d.ts","sourceRoot":"","sources":["../../src/configuration.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,WAAW,EAAE,MAAuB,CAAC;AAElD;;;;GAIG;AACH,MAAM,MAAM,mBAAmB,GAAG,sCAAsC,GAAG,wBAAwB,CAAC;AAEpG;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,8CAAqD,CAAC;AAEnF;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,mBAAmB,GAAG,OAAO,CAMjE"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Microsoft Corporation.
|
|
3
|
+
// Licensed under the MIT License.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.environmentCache = exports.SDK_VERSION = void 0;
|
|
6
|
+
exports.envVarToBoolean = envVarToBoolean;
|
|
7
|
+
exports.SDK_VERSION = "1.0.0-beta.7";
|
|
8
|
+
/**
|
|
9
|
+
* @internal
|
|
10
|
+
*
|
|
11
|
+
* Cached values of environment variables that were fetched.
|
|
12
|
+
*/
|
|
13
|
+
exports.environmentCache = new Map();
|
|
14
|
+
/**
|
|
15
|
+
* Converts an environment variable to Boolean.
|
|
16
|
+
* the strings "false" and "0" are treated as falsy values.
|
|
17
|
+
*
|
|
18
|
+
* @internal
|
|
19
|
+
*/
|
|
20
|
+
function envVarToBoolean(key) {
|
|
21
|
+
var _a;
|
|
22
|
+
if (!exports.environmentCache.has(key)) {
|
|
23
|
+
loadEnvironmentVariable(key);
|
|
24
|
+
}
|
|
25
|
+
const value = ((_a = exports.environmentCache.get(key)) !== null && _a !== void 0 ? _a : "").toLowerCase();
|
|
26
|
+
return value !== "false" && value !== "0" && Boolean(value);
|
|
27
|
+
}
|
|
28
|
+
function loadEnvironmentVariable(key) {
|
|
29
|
+
var _a;
|
|
30
|
+
if (typeof process !== "undefined" && process.env) {
|
|
31
|
+
const rawValue = (_a = process.env[key]) !== null && _a !== void 0 ? _a : process.env[key.toLowerCase()];
|
|
32
|
+
exports.environmentCache.set(key, rawValue);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=configuration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configuration.js","sourceRoot":"","sources":["../../src/configuration.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAwBlC,0CAMC;AA5BY,QAAA,WAAW,GAAW,cAAc,CAAC;AASlD;;;;GAIG;AACU,QAAA,gBAAgB,GAAG,IAAI,GAAG,EAA2C,CAAC;AAEnF;;;;;GAKG;AACH,SAAgB,eAAe,CAAC,GAAwB;;IACtD,IAAI,CAAC,wBAAgB,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;QAC/B,uBAAuB,CAAC,GAAG,CAAC,CAAC;IAC/B,CAAC;IACD,MAAM,KAAK,GAAG,CAAC,MAAA,wBAAgB,CAAC,GAAG,CAAC,GAAG,CAAC,mCAAI,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;IAC9D,OAAO,KAAK,KAAK,OAAO,IAAI,KAAK,KAAK,GAAG,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9D,CAAC;AAED,SAAS,uBAAuB,CAAC,GAAwB;;IACvD,IAAI,OAAO,OAAO,KAAK,WAAW,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;QAClD,MAAM,QAAQ,GAAG,MAAA,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,mCAAI,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,CAAC;QACpE,wBAAgB,CAAC,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;IACtC,CAAC;AACH,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nexport const SDK_VERSION: string = \"1.0.0-beta.7\";\n\n/**\n * @internal\n *\n * Keys of known environment variables we look up.\n */\nexport type KnownEnvironmentKey = \"AZURE_HTTP_TRACING_CHILDREN_DISABLED\" | \"AZURE_TRACING_DISABLED\";\n\n/**\n * @internal\n *\n * Cached values of environment variables that were fetched.\n */\nexport const environmentCache = new Map<KnownEnvironmentKey, string | undefined>();\n\n/**\n * Converts an environment variable to Boolean.\n * the strings \"false\" and \"0\" are treated as falsy values.\n *\n * @internal\n */\nexport function envVarToBoolean(key: KnownEnvironmentKey): boolean {\n if (!environmentCache.has(key)) {\n loadEnvironmentVariable(key);\n }\n const value = (environmentCache.get(key) ?? \"\").toLowerCase();\n return value !== \"false\" && value !== \"0\" && Boolean(value);\n}\n\nfunction loadEnvironmentVariable(key: KnownEnvironmentKey): void {\n if (typeof process !== \"undefined\" && process.env) {\n const rawValue = process.env[key] ?? process.env[key.toLowerCase()];\n environmentCache.set(key, rawValue);\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAGA,cAAc,aAAa,CAAC;AAC5B,cAAc,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Microsoft Corporation.
|
|
3
|
+
// Licensed under the MIT License.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
const tslib_1 = require("tslib");
|
|
6
|
+
tslib_1.__exportStar(require("./logger.js"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./instrumentation.js"), exports);
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAElC,sDAA4B;AAC5B,+DAAqC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nexport * from \"./logger.js\";\nexport * from \"./instrumentation.js\";\n"]}
|
|
@@ -1,33 +1,39 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
*
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
1
|
+
import { Instrumentation, InstrumentationBase, InstrumentationConfig, InstrumentationModuleDefinition } from "@opentelemetry/instrumentation";
|
|
2
|
+
/**
|
|
3
|
+
* Configuration options that can be passed to {@link createAzureSdkInstrumentation} function.
|
|
4
|
+
*/
|
|
5
|
+
export interface AzureSdkInstrumentationOptions extends InstrumentationConfig {
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* The instrumentation module for the Azure SDK. Implements OpenTelemetry's {@link Instrumentation}.
|
|
9
|
+
*/
|
|
10
|
+
export declare class AzureSdkInstrumentation extends InstrumentationBase {
|
|
11
|
+
constructor(options?: AzureSdkInstrumentationOptions);
|
|
12
|
+
/**
|
|
13
|
+
* Entrypoint for the module registration.
|
|
14
|
+
*
|
|
15
|
+
* @returns The patched \@azure/core-tracing module after setting its instrumenter.
|
|
16
|
+
*/
|
|
17
|
+
protected init(): void | InstrumentationModuleDefinition | InstrumentationModuleDefinition[];
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Enables Azure SDK Instrumentation using OpenTelemetry for Azure SDK client libraries.
|
|
21
|
+
*
|
|
22
|
+
* When registered, any Azure data plane package will begin emitting tracing spans for internal calls
|
|
23
|
+
* as well as network calls
|
|
24
|
+
*
|
|
25
|
+
* Example usage:
|
|
26
|
+
* ```ts
|
|
27
|
+
* const openTelemetryInstrumentation = require("@opentelemetry/instrumentation");
|
|
28
|
+
* openTelemetryInstrumentation.registerInstrumentations({
|
|
29
|
+
* instrumentations: [createAzureSdkInstrumentation()],
|
|
30
|
+
* })
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
* @remarks
|
|
34
|
+
*
|
|
35
|
+
* As OpenTelemetry instrumentations rely on patching required modules, you should register
|
|
36
|
+
* this instrumentation as early as possible and before loading any Azure Client Libraries.
|
|
37
|
+
*/
|
|
38
|
+
export declare function createAzureSdkInstrumentation(options?: AzureSdkInstrumentationOptions): Instrumentation;
|
|
39
|
+
//# sourceMappingURL=instrumentation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instrumentation.d.ts","sourceRoot":"","sources":["../../src/instrumentation.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,qBAAqB,EACrB,+BAA+B,EAEhC,MAAM,gCAAgC,CAAC;AAKxC;;GAEG;AACH,MAAM,WAAW,8BAA+B,SAAQ,qBAAqB;CAAG;AAEhF;;GAEG;AACH,qBAAa,uBAAwB,SAAQ,mBAAmB;gBAClD,OAAO,GAAE,8BAAmC;IAOxD;;;;OAIG;IACH,SAAS,CAAC,IAAI,IAAI,IAAI,GAAG,+BAA+B,GAAG,+BAA+B,EAAE;CAgB7F;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,6BAA6B,CAC3C,OAAO,GAAE,8BAAmC,GAC3C,eAAe,CAEjB"}
|