Bump artifact dependencies if CODEQL_ACTION_ARTIFACT_V2_UPGRADE enabled (#2482)

Co-authored-by: Andrew Eisenberg <aeisenberg@github.com>
Co-authored-by: Henry Mercer <henrymercer@github.com>
This commit is contained in:
Angela P Wen 2024-10-01 09:59:05 -07:00 committed by GitHub
parent cf5b0a9041
commit a196a714b8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5388 changed files with 2176737 additions and 71701 deletions

View file

@ -1,81 +0,0 @@
# Release History
## 1.0.0-preview.13 (2021-07-15)
### Features Added
- Added support for disabling distributed tracing using the AZURE_TRACING_DISABLED environment variable.
### Breaking Changes
- Removed `TestTracer` and `TestSpan` from public API and into `@azure/test-utils`. [PR #16315](https://github.com/Azure/azure-sdk-for-js/pull/16315)
- `TestTracer` and `TestSpan` are intended for test support when used by other Azure packages and not intended for use by end users.
- Removed `setTracer`, @azure/core-tracing will now rely on the `trace` API to fetch a tracer from the global tracer provider. [PR #16347](https://github.com/Azure/azure-sdk-for-js/pull/16347)
- If you are using `setTracer`, please use `trace.setGlobalTracerProvider(provider)` instead as described in the OpenTelemetry documentation.
- Removed `NoOpTracer` and `NoOpSpan` from the public API. Please use `trace.wrapSpanContext(INVALID_SPAN_CONTEXT)` from `@opentelemetry/api` instead. [PR #16315](https://github.com/Azure/azure-sdk-for-js/pull/16315)
## 1.0.0-preview.12 (2021-06-30)
- Update `@opentelemetry/api` to version 1.0.0 [PR #15883](https://github.com/Azure/azure-sdk-for-js/pull/15883)
- This version ships with ESM modules and fixes an issue where Angular projects would warn ab out optimization bailouts due to dependencies on CommonJS or AMD.
### Breaking Changes
- Removed `OpenCensusSpanWrapper` and `OpenCensusTracerWrapper` from the public API. Customers using these wrappers should migrate to using `OpenTelemetry` directly. [PR #15770](https://github.com/Azure/azure-sdk-for-js/pull/15770)
- Update `@azure/core-tracing` to version 1.0.0-preview.12. This brings core-tracing up to date with `@opentelemetry/api@1.0.0`.
- `Span#context` was renamed to `Span#spanContext`. This change is supported in `@azure/core-http@1.2.7`.
## 1.0.0-preview.11 (2021-03-30)
### Breaking Changes
- Update @azure/core-tracing to version 1.0.0-preview.11. This brings core-tracing up to date with @opentelemetry/api@1.0.0-rc.0.
There are two scenarios that will require changes if you are using tracing:
- Previously, you would pass a parent span using the `OperationOptions.tracingOptions.spanOptions.parentSpan` property. This has been
changed so that you now specify a parent `Context` using the `OperationOptions.tracingOptions.tracingContext` property instead.
- The status code for Spans is no longer of type `CanonicalCode`. Instead, it's now `SpanStatusCode`, which also has a smaller range of values.
## 1.0.0-preview.10 (2021-03-04)
- Internal improvements to make future opentelemetry updates simpler.
## 1.0.0-preview.9 (2020-08-04)
- Update `@opentelemetry/api` to version 0.10.2 [PR 10393](https://github.com/Azure/azure-sdk-for-js/pull/10393)
## 1.0.0-preview.8 (2020-04-28)
- Update `TestSpan` to allow setting span attributes [PR link](https://github.com/Azure/azure-sdk-for-js/pull/6565).
- [BREAKING] Migrate to OpenTelemetry 0.6 using the new `@opentelemetry/api` package. There were a few breaking changes:
- `SpanContext` now requires traceFlags to be set.
- `Tracer` has removed `recordSpanData`, `getBinaryFormat`, and `getHttpTextFormat`.
- `Tracer.getCurrentSpan` returns `undefined` instead of `null` when unset.
- `Link` objects renamed `spanContext` property to `context`.
## 1.0.0-preview.7 (2019-12-03)
- Updated the behavior of how incompatible versions of OpenTelemetry Tracer are handled. Now, errors will be thrown only if the user has manually set a Tracer. This means that incompatible versions will be silently ignored when tracing is not enabled.
- Updated to use OpenTelemetry 0.2 via the `@opentelemetry/types` package. There were two breaking changes in this update:
- `isRecordingEvents` on `Span` was renamed to `isRecording`. [PR link](https://github.com/open-telemetry/opentelemetry-js/pull/454)
- `addLink` was removed from `Span` as links are now only allowed to be added during span creation. This is possible by specifying any necessary links inside `SpanOptions`. [PR link](https://github.com/open-telemetry/opentelemetry-js/pull/449)
## 1.0.0-preview.5 (2019-10-22)
- Fixes issue where loading multiple copies of this module could result in the tracer set by `setTracer()` being reset.
## 1.0.0-preview.4 (2019-10-08)
- Remove dependency on the `debug` module to ensure compatibility with IE11
## 1.0.0-preview.3 (2019-10-07)
- Updated to use the latest types from OpenTelemetry (PR [#5182](https://github.com/Azure/azure-sdk-for-js/pull/5182))
- Clean up and refactored code for easier usage and testability. (PR [#5233](https://github.com/Azure/azure-sdk-for-js/pull/5233) and PR [#5283](https://github.com/Azure/azure-sdk-for-js/pull/5283))
## 1.0.0-preview.2 (2019-09-09)
Updated the `OpenCensusSpanPlugin` & the `NoOpSpanPlugin` to support for retrieving span context. This allows updating of request headers with the right [span context](https://www.w3.org/TR/trace-context/#trace-context-http-headers-format). (PR [#4712](https://github.com/Azure/azure-sdk-for-js/pull/4712))
## 1.0.0-preview.1 (2019-08-05)
Provides low-level interfaces and helper methods for tracing in Azure SDK

View file

@ -6,56 +6,19 @@ This is the core tracing library that provides low-level interfaces and helper m
### Installation
Install this library using npm as follows
```
npm install @azure/core-tracing
```
This package is primarily used in Azure client libraries and not meant to be used directly by consumers of Azure SDKs.
## Key Concepts
The `@azure/core-tracing` package supports enabling tracing for Azure SDK packages, using an [OpenTelemetry](https://opentelemetry.io/) `Tracer`.
By default, all libraries log with a `NoOpTracer` that takes no action.
To change this, you have to use `setTracer` to set a new default `Tracer`.
- `TracingClient` is the primary interface providing tracing functionality to client libraries. Client libraries should only be aware of and interact with a `TracingClient` instance.
- A `TracingClient` implementation can be created using the `createTracingClient` factory function.
- `Instrumenter` provides an abstraction over an instrumentation and acts as the interop point for using third party libraries like OpenTelemetry. By default, a no-op `Instrumenter` is used. Customers who wish to enable `OpenTelemetry` based tracing will do so by installing and registering the [@azure/opentelemetry-instrumentation-azure-sdk] package.
- `TracingContext` is an **immutable** data container, used to pass operation-specific information around (such as span parenting information).
- `TracingSpan` is an abstraction of a `Span` which can be used to record events, attributes, and exceptions.
## Examples
### Example 1 - Setting an OpenTelemetry Tracer
```js
const opentelemetry = require("@opentelemetry/api");
const { BasicTracer, SimpleSpanProcessor } = require("@opentelemetry/tracing");
const { ZipkinExporter } = require("@opentelemetry/exporter-zipkin");
const { setTracer } = require("@azure/core-tracing");
const exporter = new ZipkinExporter({
serviceName: "azure-tracing-sample"
});
const tracer = new BasicTracer();
tracer.addSpanProcessor(new SimpleSpanProcessor(exporter));
setTracer(tracer);
const rootSpan = tracer.startSpan("root");
const context = opentelemetry.setSpan(opentelemetry.context.active(), rootSpan);
// Call some client library methods and pass rootSpan via tracingOptions.
rootSpan.end();
exporter.shutdown();
```
### Example 2 - Passing current Context to library operations
```js
// Given a BlobClient from @azure/storage-blob
const result = await blobClient.download(undefined, undefined, {
tracingOptions: {
tracingContext: context
}
});
```
Examples can be found in the `samples` folder.
## Next steps
@ -69,4 +32,6 @@ If you run into issues while using this library, please feel free to [file an is
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.
[@azure/opentelemetry-instrumentation-azure-sdk]: https://www.npmjs.com/package/@azure/opentelemetry-instrumentation-azure-sdk
![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js%2Fsdk%2Fcore%2Fcore-tracing%2FREADME.png)

View file

@ -1,63 +0,0 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
import { SpanKind, setSpan, context as otContext, getTracer } from "./interfaces";
import { trace, INVALID_SPAN_CONTEXT } from "@opentelemetry/api";
export function isTracingDisabled() {
var _a;
if (typeof process === "undefined") {
// not supported in browser for now without polyfills
return false;
}
const azureTracingDisabledValue = (_a = process.env.AZURE_TRACING_DISABLED) === null || _a === void 0 ? void 0 : _a.toLowerCase();
if (azureTracingDisabledValue === "false" || azureTracingDisabledValue === "0") {
return false;
}
return Boolean(azureTracingDisabledValue);
}
/**
* Creates a function that can be used to create spans using the global tracer.
*
* Usage:
*
* ```typescript
* // once
* const createSpan = createSpanFunction({ packagePrefix: "Azure.Data.AppConfiguration", namespace: "Microsoft.AppConfiguration" });
*
* // in each operation
* const span = createSpan("deleteConfigurationSetting", operationOptions);
* // code...
* span.end();
* ```
*
* @hidden
* @param args - allows configuration of the prefix for each span as well as the az.namespace field.
*/
export function createSpanFunction(args) {
return function (operationName, operationOptions) {
const tracer = getTracer();
const tracingOptions = (operationOptions === null || operationOptions === void 0 ? void 0 : operationOptions.tracingOptions) || {};
const spanOptions = Object.assign({ kind: SpanKind.INTERNAL }, tracingOptions.spanOptions);
const spanName = args.packagePrefix ? `${args.packagePrefix}.${operationName}` : operationName;
let span;
if (isTracingDisabled()) {
span = trace.wrapSpanContext(INVALID_SPAN_CONTEXT);
}
else {
span = tracer.startSpan(spanName, spanOptions, tracingOptions.tracingContext);
}
if (args.namespace) {
span.setAttribute("az.namespace", args.namespace);
}
let newSpanOptions = tracingOptions.spanOptions || {};
if (span.isRecording() && args.namespace) {
newSpanOptions = Object.assign(Object.assign({}, tracingOptions.spanOptions), { attributes: Object.assign(Object.assign({}, spanOptions.attributes), { "az.namespace": args.namespace }) });
}
const newTracingOptions = Object.assign(Object.assign({}, tracingOptions), { spanOptions: newSpanOptions, tracingContext: setSpan(tracingOptions.tracingContext || otContext.active(), span) });
const newOperationOptions = Object.assign(Object.assign({}, operationOptions), { tracingOptions: newTracingOptions });
return {
span,
updatedOptions: newOperationOptions
};
};
}
//# sourceMappingURL=createSpan.js.map

File diff suppressed because one or more lines are too long

View file

@ -1,9 +0,0 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
// Tracers and wrappers
export { createSpanFunction } from "./createSpan";
// Shared interfaces
export { context, getSpan, getSpanContext, getTracer, isSpanContextValid, setSpan, setSpanContext, SpanKind, SpanStatusCode } from "./interfaces";
// Utilities
export { extractSpanContextFromTraceParentHeader, getTraceParentHeader } from "./utils/traceParentHeader";
//# sourceMappingURL=index.js.map

View file

@ -1 +0,0 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,uBAAuB;AACvB,OAAO,EAAE,kBAAkB,EAA0B,MAAM,cAAc,CAAC;AAE1E,oBAAoB;AACpB,OAAO,EACL,OAAO,EAOP,OAAO,EACP,cAAc,EACd,SAAS,EAET,kBAAkB,EAGlB,OAAO,EACP,cAAc,EAKd,QAAQ,EAGR,cAAc,EAKf,MAAM,cAAc,CAAC;AAEtB,YAAY;AACZ,OAAO,EACL,uCAAuC,EACvC,oBAAoB,EACrB,MAAM,2BAA2B,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n// Tracers and wrappers\nexport { createSpanFunction, CreateSpanFunctionArgs } from \"./createSpan\";\n\n// Shared interfaces\nexport {\n context,\n Context,\n ContextAPI,\n Exception,\n ExceptionWithCode,\n ExceptionWithMessage,\n ExceptionWithName,\n getSpan,\n getSpanContext,\n getTracer,\n HrTime,\n isSpanContextValid,\n Link,\n OperationTracingOptions,\n setSpan,\n setSpanContext,\n Span,\n SpanAttributes,\n SpanAttributeValue,\n SpanContext,\n SpanKind,\n SpanOptions,\n SpanStatus,\n SpanStatusCode,\n TimeInput,\n TraceFlags,\n Tracer,\n TraceState\n} from \"./interfaces\";\n\n// Utilities\nexport {\n extractSpanContextFromTraceParentHeader,\n getTraceParentHeader\n} from \"./utils/traceParentHeader\";\n"]}

View file

@ -1,102 +0,0 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
import { context as otContext, trace as otTrace } from "@opentelemetry/api";
/**
* The kind of span.
*/
export var SpanKind;
(function (SpanKind) {
/** Default value. Indicates that the span is used internally. */
SpanKind[SpanKind["INTERNAL"] = 0] = "INTERNAL";
/**
* Indicates that the span covers server-side handling of an RPC or other
* remote request.
*/
SpanKind[SpanKind["SERVER"] = 1] = "SERVER";
/**
* Indicates that the span covers the client-side wrapper around an RPC or
* other remote request.
*/
SpanKind[SpanKind["CLIENT"] = 2] = "CLIENT";
/**
* Indicates that the span describes producer sending a message to a
* broker. Unlike client and server, there is no direct critical path latency
* relationship between producer and consumer spans.
*/
SpanKind[SpanKind["PRODUCER"] = 3] = "PRODUCER";
/**
* Indicates that the span describes consumer receiving a message from a
* broker. Unlike client and server, there is no direct critical path latency
* relationship between producer and consumer spans.
*/
SpanKind[SpanKind["CONSUMER"] = 4] = "CONSUMER";
})(SpanKind || (SpanKind = {}));
/**
* Return the span if one exists
*
* @param context - context to get span from
*/
export function getSpan(context) {
return otTrace.getSpan(context);
}
/**
* Set the span on a context
*
* @param context - context to use as parent
* @param span - span to set active
*/
export function setSpan(context, span) {
return otTrace.setSpan(context, span);
}
/**
* Wrap span context in a NoopSpan and set as span in a new
* context
*
* @param context - context to set active span on
* @param spanContext - span context to be wrapped
*/
export function setSpanContext(context, spanContext) {
return otTrace.setSpanContext(context, spanContext);
}
/**
* Get the span context of the span if it exists.
*
* @param context - context to get values from
*/
export function getSpanContext(context) {
return otTrace.getSpanContext(context);
}
/**
* Returns true of the given {@link SpanContext} is valid.
* A valid {@link SpanContext} is one which has a valid trace ID and span ID as per the spec.
*
* @param context - the {@link SpanContext} to validate.
*
* @returns true if the {@link SpanContext} is valid, false otherwise.
*/
export function isSpanContextValid(context) {
return otTrace.isSpanContextValid(context);
}
export function getTracer(name, version) {
return otTrace.getTracer(name || "azure/core-tracing", version);
}
/** Entrypoint for context API */
export const context = otContext;
/** SpanStatusCode */
export var SpanStatusCode;
(function (SpanStatusCode) {
/**
* The default status.
*/
SpanStatusCode[SpanStatusCode["UNSET"] = 0] = "UNSET";
/**
* The operation has been validated by an Application developer or
* Operator to have completed successfully.
*/
SpanStatusCode[SpanStatusCode["OK"] = 1] = "OK";
/**
* The operation contains an error.
*/
SpanStatusCode[SpanStatusCode["ERROR"] = 2] = "ERROR";
})(SpanStatusCode || (SpanStatusCode = {}));
//# sourceMappingURL=interfaces.js.map

File diff suppressed because one or more lines are too long

View file

@ -1,48 +0,0 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
const VERSION = "00";
/**
* Generates a `SpanContext` given a `traceparent` header value.
* @param traceParent - Serialized span context data as a `traceparent` header value.
* @returns The `SpanContext` generated from the `traceparent` value.
*/
export function extractSpanContextFromTraceParentHeader(traceParentHeader) {
const parts = traceParentHeader.split("-");
if (parts.length !== 4) {
return;
}
const [version, traceId, spanId, traceOptions] = parts;
if (version !== VERSION) {
return;
}
const traceFlags = parseInt(traceOptions, 16);
const spanContext = {
spanId,
traceId,
traceFlags
};
return spanContext;
}
/**
* Generates a `traceparent` value given a span context.
* @param spanContext - Contains context for a specific span.
* @returns The `spanContext` represented as a `traceparent` value.
*/
export function getTraceParentHeader(spanContext) {
const missingFields = [];
if (!spanContext.traceId) {
missingFields.push("traceId");
}
if (!spanContext.spanId) {
missingFields.push("spanId");
}
if (missingFields.length) {
return;
}
const flags = spanContext.traceFlags || 0 /* NONE */;
const hexFlags = flags.toString(16);
const traceFlags = hexFlags.length === 1 ? `0${hexFlags}` : hexFlags;
// https://www.w3.org/TR/trace-context/#traceparent-header-field-values
return `${VERSION}-${spanContext.traceId}-${spanContext.spanId}-${traceFlags}`;
}
//# sourceMappingURL=traceParentHeader.js.map

View file

@ -1 +0,0 @@
{"version":3,"file":"traceParentHeader.js","sourceRoot":"","sources":["../../../src/utils/traceParentHeader.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAIlC,MAAM,OAAO,GAAG,IAAI,CAAC;AAErB;;;;GAIG;AACH,MAAM,UAAU,uCAAuC,CACrD,iBAAyB;IAEzB,MAAM,KAAK,GAAG,iBAAiB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAE3C,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE;QACtB,OAAO;KACR;IAED,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,YAAY,CAAC,GAAG,KAAK,CAAC;IAEvD,IAAI,OAAO,KAAK,OAAO,EAAE;QACvB,OAAO;KACR;IAED,MAAM,UAAU,GAAG,QAAQ,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC;IAE9C,MAAM,WAAW,GAAgB;QAC/B,MAAM;QACN,OAAO;QACP,UAAU;KACX,CAAC;IAEF,OAAO,WAAW,CAAC;AACrB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,WAAwB;IAC3D,MAAM,aAAa,GAAa,EAAE,CAAC;IACnC,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE;QACxB,aAAa,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;KAC/B;IACD,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE;QACvB,aAAa,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;KAC9B;IAED,IAAI,aAAa,CAAC,MAAM,EAAE;QACxB,OAAO;KACR;IAED,MAAM,KAAK,GAAG,WAAW,CAAC,UAAU,gBAAmB,CAAC;IACxD,MAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IACpC,MAAM,UAAU,GAAG,QAAQ,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,QAAQ,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC;IAErE,uEAAuE;IACvE,OAAO,GAAG,OAAO,IAAI,WAAW,CAAC,OAAO,IAAI,WAAW,CAAC,MAAM,IAAI,UAAU,EAAE,CAAC;AACjF,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { SpanContext, TraceFlags } from \"../interfaces\";\n\nconst VERSION = \"00\";\n\n/**\n * Generates a `SpanContext` given a `traceparent` header value.\n * @param traceParent - Serialized span context data as a `traceparent` header value.\n * @returns The `SpanContext` generated from the `traceparent` value.\n */\nexport function extractSpanContextFromTraceParentHeader(\n traceParentHeader: string\n): SpanContext | undefined {\n const parts = traceParentHeader.split(\"-\");\n\n if (parts.length !== 4) {\n return;\n }\n\n const [version, traceId, spanId, traceOptions] = parts;\n\n if (version !== VERSION) {\n return;\n }\n\n const traceFlags = parseInt(traceOptions, 16);\n\n const spanContext: SpanContext = {\n spanId,\n traceId,\n traceFlags\n };\n\n return spanContext;\n}\n\n/**\n * Generates a `traceparent` value given a span context.\n * @param spanContext - Contains context for a specific span.\n * @returns The `spanContext` represented as a `traceparent` value.\n */\nexport function getTraceParentHeader(spanContext: SpanContext): string | undefined {\n const missingFields: string[] = [];\n if (!spanContext.traceId) {\n missingFields.push(\"traceId\");\n }\n if (!spanContext.spanId) {\n missingFields.push(\"spanId\");\n }\n\n if (missingFields.length) {\n return;\n }\n\n const flags = spanContext.traceFlags || TraceFlags.NONE;\n const hexFlags = flags.toString(16);\n const traceFlags = hexFlags.length === 1 ? `0${hexFlags}` : hexFlags;\n\n // https://www.w3.org/TR/trace-context/#traceparent-header-field-values\n return `${VERSION}-${spanContext.traceId}-${spanContext.spanId}-${traceFlags}`;\n}\n"]}

View file

@ -0,0 +1,4 @@
export { Instrumenter, InstrumenterSpanOptions, OperationTracingOptions, OptionsWithTracingContext, Resolved, SpanStatus, SpanStatusError, SpanStatusSuccess, TracingClient, TracingClientOptions, TracingContext, TracingSpan, TracingSpanKind, TracingSpanLink, TracingSpanOptions, } from "./interfaces.js";
export { useInstrumenter } from "./instrumenter.js";
export { createTracingClient } from "./tracingClient.js";
//# sourceMappingURL=index.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,YAAY,EACZ,uBAAuB,EACvB,uBAAuB,EACvB,yBAAyB,EACzB,QAAQ,EACR,UAAU,EACV,eAAe,EACf,iBAAiB,EACjB,aAAa,EACb,oBAAoB,EACpB,cAAc,EACd,WAAW,EACX,eAAe,EACf,eAAe,EACf,kBAAkB,GACnB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC"}

View file

@ -0,0 +1,5 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
export { useInstrumenter } from "./instrumenter.js";
export { createTracingClient } from "./tracingClient.js";
//# sourceMappingURL=index.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAmBlC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nexport {\n Instrumenter,\n InstrumenterSpanOptions,\n OperationTracingOptions,\n OptionsWithTracingContext,\n Resolved,\n SpanStatus,\n SpanStatusError,\n SpanStatusSuccess,\n TracingClient,\n TracingClientOptions,\n TracingContext,\n TracingSpan,\n TracingSpanKind,\n TracingSpanLink,\n TracingSpanOptions,\n} from \"./interfaces.js\";\nexport { useInstrumenter } from \"./instrumenter.js\";\nexport { createTracingClient } from \"./tracingClient.js\";\n"]}

View file

@ -0,0 +1,16 @@
import { Instrumenter, TracingSpan } from "./interfaces.js";
export declare function createDefaultTracingSpan(): TracingSpan;
export declare function createDefaultInstrumenter(): Instrumenter;
/**
* Extends the Azure SDK with support for a given instrumenter implementation.
*
* @param instrumenter - The instrumenter implementation to use.
*/
export declare function useInstrumenter(instrumenter: Instrumenter): void;
/**
* Gets the currently set instrumenter, a No-Op instrumenter by default.
*
* @returns The currently set instrumenter
*/
export declare function getInstrumenter(): Instrumenter;
//# sourceMappingURL=instrumenter.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"instrumenter.d.ts","sourceRoot":"","sources":["../../src/instrumenter.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,YAAY,EAGZ,WAAW,EACZ,MAAM,iBAAiB,CAAC;AAKzB,wBAAgB,wBAAwB,IAAI,WAAW,CAgBtD;AAED,wBAAgB,yBAAyB,IAAI,YAAY,CA4BxD;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,YAAY,EAAE,YAAY,GAAG,IAAI,CAEhE;AAED;;;;GAIG;AACH,wBAAgB,eAAe,IAAI,YAAY,CAK9C"}

View file

@ -0,0 +1,60 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
import { createTracingContext } from "./tracingContext.js";
import { state } from "./state.js";
export function createDefaultTracingSpan() {
return {
end: () => {
// noop
},
isRecording: () => false,
recordException: () => {
// noop
},
setAttribute: () => {
// noop
},
setStatus: () => {
// noop
},
};
}
export function createDefaultInstrumenter() {
return {
createRequestHeaders: () => {
return {};
},
parseTraceparentHeader: () => {
return undefined;
},
startSpan: (_name, spanOptions) => {
return {
span: createDefaultTracingSpan(),
tracingContext: createTracingContext({ parentContext: spanOptions.tracingContext }),
};
},
withContext(_context, callback, ...callbackArgs) {
return callback(...callbackArgs);
},
};
}
/**
* Extends the Azure SDK with support for a given instrumenter implementation.
*
* @param instrumenter - The instrumenter implementation to use.
*/
export function useInstrumenter(instrumenter) {
state.instrumenterImplementation = instrumenter;
}
/**
* Gets the currently set instrumenter, a No-Op instrumenter by default.
*
* @returns The currently set instrumenter
*/
export function getInstrumenter() {
if (!state.instrumenterImplementation) {
state.instrumenterImplementation = createDefaultInstrumenter();
}
return state.instrumenterImplementation;
}
//# sourceMappingURL=instrumenter.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"instrumenter.js","sourceRoot":"","sources":["../../src/instrumenter.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AASlC,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnC,MAAM,UAAU,wBAAwB;IACtC,OAAO;QACL,GAAG,EAAE,GAAG,EAAE;YACR,OAAO;QACT,CAAC;QACD,WAAW,EAAE,GAAG,EAAE,CAAC,KAAK;QACxB,eAAe,EAAE,GAAG,EAAE;YACpB,OAAO;QACT,CAAC;QACD,YAAY,EAAE,GAAG,EAAE;YACjB,OAAO;QACT,CAAC;QACD,SAAS,EAAE,GAAG,EAAE;YACd,OAAO;QACT,CAAC;KACF,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,yBAAyB;IACvC,OAAO;QACL,oBAAoB,EAAE,GAA2B,EAAE;YACjD,OAAO,EAAE,CAAC;QACZ,CAAC;QACD,sBAAsB,EAAE,GAA+B,EAAE;YACvD,OAAO,SAAS,CAAC;QACnB,CAAC;QACD,SAAS,EAAE,CACT,KAAa,EACb,WAAoC,EACmB,EAAE;YACzD,OAAO;gBACL,IAAI,EAAE,wBAAwB,EAAE;gBAChC,cAAc,EAAE,oBAAoB,CAAC,EAAE,aAAa,EAAE,WAAW,CAAC,cAAc,EAAE,CAAC;aACpF,CAAC;QACJ,CAAC;QACD,WAAW,CAIT,QAAwB,EACxB,QAAkB,EAClB,GAAG,YAA0B;YAE7B,OAAO,QAAQ,CAAC,GAAG,YAAY,CAAC,CAAC;QACnC,CAAC;KACF,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAC,YAA0B;IACxD,KAAK,CAAC,0BAA0B,GAAG,YAAY,CAAC;AAClD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,eAAe;IAC7B,IAAI,CAAC,KAAK,CAAC,0BAA0B,EAAE,CAAC;QACtC,KAAK,CAAC,0BAA0B,GAAG,yBAAyB,EAAE,CAAC;IACjE,CAAC;IACD,OAAO,KAAK,CAAC,0BAA0B,CAAC;AAC1C,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n Instrumenter,\n InstrumenterSpanOptions,\n TracingContext,\n TracingSpan,\n} from \"./interfaces.js\";\n\nimport { createTracingContext } from \"./tracingContext.js\";\nimport { state } from \"./state.js\";\n\nexport function createDefaultTracingSpan(): TracingSpan {\n return {\n end: () => {\n // noop\n },\n isRecording: () => false,\n recordException: () => {\n // noop\n },\n setAttribute: () => {\n // noop\n },\n setStatus: () => {\n // noop\n },\n };\n}\n\nexport function createDefaultInstrumenter(): Instrumenter {\n return {\n createRequestHeaders: (): Record<string, string> => {\n return {};\n },\n parseTraceparentHeader: (): TracingContext | undefined => {\n return undefined;\n },\n startSpan: (\n _name: string,\n spanOptions: InstrumenterSpanOptions,\n ): { span: TracingSpan; tracingContext: TracingContext } => {\n return {\n span: createDefaultTracingSpan(),\n tracingContext: createTracingContext({ parentContext: spanOptions.tracingContext }),\n };\n },\n withContext<\n CallbackArgs extends unknown[],\n Callback extends (...args: CallbackArgs) => ReturnType<Callback>,\n >(\n _context: TracingContext,\n callback: Callback,\n ...callbackArgs: CallbackArgs\n ): ReturnType<Callback> {\n return callback(...callbackArgs);\n },\n };\n}\n\n/**\n * Extends the Azure SDK with support for a given instrumenter implementation.\n *\n * @param instrumenter - The instrumenter implementation to use.\n */\nexport function useInstrumenter(instrumenter: Instrumenter): void {\n state.instrumenterImplementation = instrumenter;\n}\n\n/**\n * Gets the currently set instrumenter, a No-Op instrumenter by default.\n *\n * @returns The currently set instrumenter\n */\nexport function getInstrumenter(): Instrumenter {\n if (!state.instrumenterImplementation) {\n state.instrumenterImplementation = createDefaultInstrumenter();\n }\n return state.instrumenterImplementation;\n}\n"]}

View file

@ -0,0 +1,254 @@
/**
* A narrower version of TypeScript 4.5's Awaited type which Recursively
* unwraps the "awaited type", emulating the behavior of `await`.
*/
export type Resolved<T> = T extends {
then(onfulfilled: infer F): any;
} ? F extends (value: infer V) => any ? Resolved<V> : never : T;
/**
* Represents a client that can integrate with the currently configured {@link Instrumenter}.
*
* Create an instance using {@link createTracingClient}.
*/
export interface TracingClient {
/**
* Wraps a callback in a tracing span, calls the callback, and closes the span.
*
* This is the primary interface for using Tracing and will handle error recording as well as setting the status on the span.
*
* Both synchronous and asynchronous functions will be awaited in order to reflect the result of the callback on the span.
*
* Example:
*
* ```ts
* const myOperationResult = await tracingClient.withSpan("myClassName.myOperationName", options, (updatedOptions) => myOperation(updatedOptions));
* ```
* @param name - The name of the span. By convention this should be `${className}.${methodName}`.
* @param operationOptions - The original options passed to the method. The callback will receive these options with the newly created {@link TracingContext}.
* @param callback - The callback to be invoked with the updated options and newly created {@link TracingSpan}.
*/
withSpan<Options extends {
tracingOptions?: OperationTracingOptions;
}, Callback extends (updatedOptions: Options, span: Omit<TracingSpan, "end">) => ReturnType<Callback>>(name: string, operationOptions: Options, callback: Callback, spanOptions?: TracingSpanOptions): Promise<Resolved<ReturnType<Callback>>>;
/**
* Starts a given span but does not set it as the active span.
*
* You must end the span using {@link TracingSpan.end}.
*
* Most of the time you will want to use {@link withSpan} instead.
*
* @param name - The name of the span. By convention this should be `${className}.${methodName}`.
* @param operationOptions - The original operation options.
* @param spanOptions - The options to use when creating the span.
*
* @returns A {@link TracingSpan} and the updated operation options.
*/
startSpan<Options extends {
tracingOptions?: OperationTracingOptions;
}>(name: string, operationOptions?: Options, spanOptions?: TracingSpanOptions): {
span: TracingSpan;
updatedOptions: OptionsWithTracingContext<Options>;
};
/**
* Wraps a callback with an active context and calls the callback.
* Depending on the implementation, this may set the globally available active context.
*
* Useful when you want to leave the boundaries of the SDK (make a request or callback to user code) and are unable to use the {@link withSpan} API.
*
* @param context - The {@link TracingContext} to use as the active context in the scope of the callback.
* @param callback - The callback to be invoked with the given context set as the globally active context.
* @param callbackArgs - The callback arguments.
*/
withContext<CallbackArgs extends unknown[], Callback extends (...args: CallbackArgs) => ReturnType<Callback>>(context: TracingContext, callback: Callback, ...callbackArgs: CallbackArgs): ReturnType<Callback>;
/**
* Parses a traceparent header value into a {@link TracingSpanContext}.
*
* @param traceparentHeader - The traceparent header to parse.
* @returns An implementation-specific identifier for the span.
*/
parseTraceparentHeader(traceparentHeader: string): TracingContext | undefined;
/**
* Creates a set of request headers to propagate tracing information to a backend.
*
* @param tracingContext - The context containing the span to propagate.
* @returns The set of headers to add to a request.
*/
createRequestHeaders(tracingContext?: TracingContext): Record<string, string>;
}
/**
* Options that can be passed to {@link createTracingClient}
*/
export interface TracingClientOptions {
/** The value of the az.namespace tracing attribute on newly created spans. */
namespace: string;
/** The name of the package invoking this trace. */
packageName: string;
/** An optional version of the package invoking this trace. */
packageVersion?: string;
}
/** The kind of span. */
export type TracingSpanKind = "client" | "server" | "producer" | "consumer" | "internal";
/** Options used to configure the newly created span. */
export interface TracingSpanOptions {
/** The kind of span. Implementations should default this to "client". */
spanKind?: TracingSpanKind;
/** A collection of {@link TracingSpanLink} to link to this span. */
spanLinks?: TracingSpanLink[];
/** Initial set of attributes to set on a span. */
spanAttributes?: {
[key: string]: unknown;
};
}
/** A pointer from the current {@link TracingSpan} to another span in the same or a different trace. */
export interface TracingSpanLink {
/** The {@link TracingContext} containing the span context to link to. */
tracingContext: TracingContext;
/** A set of attributes on the link. */
attributes?: {
[key: string]: unknown;
};
}
/**
* Represents an implementation agnostic instrumenter.
*/
export interface Instrumenter {
/**
* Creates a new {@link TracingSpan} with the given name and options and sets it on a new context.
* @param name - The name of the span. By convention this should be `${className}.${methodName}`.
* @param spanOptions - The options to use when creating the span.
*
* @returns A {@link TracingSpan} that can be used to end the span, and the context this span has been set on.
*/
startSpan(name: string, spanOptions: InstrumenterSpanOptions): {
span: TracingSpan;
tracingContext: TracingContext;
};
/**
* Wraps a callback with an active context and calls the callback.
* Depending on the implementation, this may set the globally available active context.
*
* @param context - The {@link TracingContext} to use as the active context in the scope of the callback.
* @param callback - The callback to be invoked with the given context set as the globally active context.
* @param callbackArgs - The callback arguments.
*/
withContext<CallbackArgs extends unknown[], Callback extends (...args: CallbackArgs) => ReturnType<Callback>>(context: TracingContext, callback: Callback, ...callbackArgs: CallbackArgs): ReturnType<Callback>;
/**
* Provides an implementation-specific method to parse a {@link https://www.w3.org/TR/trace-context/#traceparent-header}
* into a {@link TracingSpanContext} which can be used to link non-parented spans together.
*/
parseTraceparentHeader(traceparentHeader: string): TracingContext | undefined;
/**
* Provides an implementation-specific method to serialize a {@link TracingSpan} to a set of headers.
* @param tracingContext - The context containing the span to serialize.
*/
createRequestHeaders(tracingContext?: TracingContext): Record<string, string>;
}
/**
* Options passed to {@link Instrumenter.startSpan} as a superset of {@link TracingSpanOptions}.
*/
export interface InstrumenterSpanOptions extends TracingSpanOptions {
/** The name of the package invoking this trace. */
packageName: string;
/** The version of the package invoking this trace. */
packageVersion?: string;
/** The current tracing context. Defaults to an implementation-specific "active" context. */
tracingContext?: TracingContext;
}
/**
* Status representing a successful operation that can be sent to {@link TracingSpan.setStatus}
*/
export type SpanStatusSuccess = {
status: "success";
};
/**
* Status representing an error that can be sent to {@link TracingSpan.setStatus}
*/
export type SpanStatusError = {
status: "error";
error?: Error | string;
};
/**
* Represents the statuses that can be passed to {@link TracingSpan.setStatus}.
*
* By default, all spans will be created with status "unset".
*/
export type SpanStatus = SpanStatusSuccess | SpanStatusError;
/**
* Represents an implementation agnostic tracing span.
*/
export interface TracingSpan {
/**
* Sets the status of the span. When an error is provided, it will be recorded on the span as well.
*
* @param status - The {@link SpanStatus} to set on the span.
*/
setStatus(status: SpanStatus): void;
/**
* Sets a given attribute on a span.
*
* @param name - The attribute's name.
* @param value - The attribute's value to set. May be any non-nullish value.
*/
setAttribute(name: string, value: unknown): void;
/**
* Ends the span.
*/
end(): void;
/**
* Records an exception on a {@link TracingSpan} without modifying its status.
*
* When recording an unhandled exception that should fail the span, please use {@link TracingSpan.setStatus} instead.
*
* @param exception - The exception to record on the span.
*
*/
recordException(exception: Error | string): void;
/**
* Returns true if this {@link TracingSpan} is recording information.
*
* Depending on the span implementation, this may return false if the span is not being sampled.
*/
isRecording(): boolean;
}
/** An immutable context bag of tracing values for the current operation. */
export interface TracingContext {
/**
* Sets a given object on a context.
* @param key - The key of the given context value.
* @param value - The value to set on the context.
*
* @returns - A new context with the given value set.
*/
setValue(key: symbol, value: unknown): TracingContext;
/**
* Gets an object from the context if it exists.
* @param key - The key of the given context value.
*
* @returns - The value of the given context value if it exists, otherwise `undefined`.
*/
getValue(key: symbol): unknown;
/**
* Deletes an object from the context if it exists.
* @param key - The key of the given context value to delete.
*/
deleteValue(key: symbol): TracingContext;
}
/**
* Tracing options to set on an operation.
*/
export interface OperationTracingOptions {
/** The context to use for created Tracing Spans. */
tracingContext?: TracingContext;
}
/**
* A utility type for when we know a TracingContext has been set
* as part of an operation's options.
*/
export type OptionsWithTracingContext<Options extends {
tracingOptions?: OperationTracingOptions;
}> = Options & {
tracingOptions: {
tracingContext: TracingContext;
};
};
//# sourceMappingURL=interfaces.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../src/interfaces.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,MAAM,MAAM,QAAQ,CAAC,CAAC,IAAI,CAAC,SAAS;IAAE,IAAI,CAAC,WAAW,EAAE,MAAM,CAAC,GAAG,GAAG,CAAA;CAAE,GACnE,CAAC,SAAS,CAAC,KAAK,EAAE,MAAM,CAAC,KAAK,GAAG,GAC/B,QAAQ,CAAC,CAAC,CAAC,GACX,KAAK,GACP,CAAC,CAAC;AAEN;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC5B;;;;;;;;;;;;;;;OAeG;IACH,QAAQ,CACN,OAAO,SAAS;QAAE,cAAc,CAAC,EAAE,uBAAuB,CAAA;KAAE,EAC5D,QAAQ,SAAS,CACf,cAAc,EAAE,OAAO,EACvB,IAAI,EAAE,IAAI,CAAC,WAAW,EAAE,KAAK,CAAC,KAC3B,UAAU,CAAC,QAAQ,CAAC,EAEzB,IAAI,EAAE,MAAM,EACZ,gBAAgB,EAAE,OAAO,EACzB,QAAQ,EAAE,QAAQ,EAClB,WAAW,CAAC,EAAE,kBAAkB,GAC/B,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IAC3C;;;;;;;;;;;;OAYG;IACH,SAAS,CAAC,OAAO,SAAS;QAAE,cAAc,CAAC,EAAE,uBAAuB,CAAA;KAAE,EACpE,IAAI,EAAE,MAAM,EACZ,gBAAgB,CAAC,EAAE,OAAO,EAC1B,WAAW,CAAC,EAAE,kBAAkB,GAC/B;QACD,IAA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W,WAAW;IAC1B;;;;OAIG;IACH,SAAS,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI,CAAC;IAEpC;;;;;OAKG;IACH,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CAAC;IAEjD;;OAEG;IACH,GAAG,IAAI,IAAI,CAAC;IAEZ;;;;;;;OAOG;IACH,eAAe,CAAC,SAAS,EAAE,KAAK,GAAG,MAAM,GAAG,IAAI,CAAC;IAEjD;;;;OAIG;IACH,WAAW,IAAI,OAAO,CAAC;CACxB;AAED,4EAA4E;AAC5E,MAAM,WAAW,cAAc;IAC7B;;;;;;OAMG;IACH,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,cAAc,CAAC;IACtD;;;;;OAKG;IACH,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;IAC/B;;;OAGG;IACH,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc,CAAC;CAC1C;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,oDAAoD;IACpD,cAAc,CAAC,EAAE,cAAc,CAAC;CACjC;AAED;;;GAGG;AACH,MAAM,MAAM,yBAAyB,CACnC,OAAO,SAAS;IAAE,cAAc,CAAC,EAAE,uBAAuB,CAAA;CAAE,IAC1D,OAAO,GAAG;IACZ,cAAc,EAAE;QACd,cAAc,EAAE,cAAc,CAAC;KAChC,CAAC;CACH,CAAC"}

View file

@ -0,0 +1,4 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
export {};
//# sourceMappingURL=interfaces.js.map

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,3 @@
{
"type": "module"
}

View file

@ -0,0 +1 @@
{"version":3,"file":"state-browser.d.mts","sourceRoot":"","sources":["../../src/state-browser.mts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C;;GAEG;AACH,eAAO,MAAM,KAAK;;CAEjB,CAAC"}

View file

@ -0,0 +1 @@
{"version":3,"file":"state-browser.mjs","sourceRoot":"","sources":["../../src/state-browser.mts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAIlC;;GAEG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG;IACnB,0BAA0B,EAAE,SAAqC;CAClE,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { Instrumenter } from \"./interfaces.js\";\n\n/**\n * Browser-only implementation of the module's state. The browser esm variant will not load the commonjs state, so we do not need to share state between the two.\n */\nexport const state = {\n instrumenterImplementation: undefined as Instrumenter | undefined,\n};\n"]}

View file

@ -0,0 +1,8 @@
import { Instrumenter } from "./interfaces.js";
/**
* Browser-only implementation of the module's state. The browser esm variant will not load the commonjs state, so we do not need to share state between the two.
*/
export declare const state: {
instrumenterImplementation: Instrumenter | undefined;
};
//# sourceMappingURL=state-browser.d.mts.map

View file

@ -0,0 +1,9 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
/**
* Browser-only implementation of the module's state. The browser esm variant will not load the commonjs state, so we do not need to share state between the two.
*/
export const state = {
instrumenterImplementation: undefined,
};
//# sourceMappingURL=state-browser.mjs.map

View file

@ -0,0 +1,9 @@
import { TracingClient, TracingClientOptions } from "./interfaces.js";
/**
* Creates a new tracing client.
*
* @param options - Options used to configure the tracing client.
* @returns - An instance of {@link TracingClient}.
*/
export declare function createTracingClient(options: TracingClientOptions): TracingClient;
//# sourceMappingURL=tracingClient.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"tracingClient.d.ts","sourceRoot":"","sources":["../../src/tracingClient.ts"],"names":[],"mappings":"AAGA,OAAO,EAIL,aAAa,EACb,oBAAoB,EAIrB,MAAM,iBAAiB,CAAC;AAIzB;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,oBAAoB,GAAG,aAAa,CAkGhF"}

View file

@ -0,0 +1,74 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
import { getInstrumenter } from "./instrumenter.js";
import { knownContextKeys } from "./tracingContext.js";
/**
* Creates a new tracing client.
*
* @param options - Options used to configure the tracing client.
* @returns - An instance of {@link TracingClient}.
*/
export function createTracingClient(options) {
const { namespace, packageName, packageVersion } = options;
function startSpan(name, operationOptions, spanOptions) {
var _a;
const startSpanResult = getInstrumenter().startSpan(name, Object.assign(Object.assign({}, spanOptions), { packageName: packageName, packageVersion: packageVersion, tracingContext: (_a = operationOptions === null || operationOptions === void 0 ? void 0 : operationOptions.tracingOptions) === null || _a === void 0 ? void 0 : _a.tracingContext }));
let tracingContext = startSpanResult.tracingContext;
const span = startSpanResult.span;
if (!tracingContext.getValue(knownContextKeys.namespace)) {
tracingContext = tracingContext.setValue(knownContextKeys.namespace, namespace);
}
span.setAttribute("az.namespace", tracingContext.getValue(knownContextKeys.namespace));
const updatedOptions = Object.assign({}, operationOptions, {
tracingOptions: Object.assign(Object.assign({}, operationOptions === null || operationOptions === void 0 ? void 0 : operationOptions.tracingOptions), { tracingContext }),
});
return {
span,
updatedOptions,
};
}
async function withSpan(name, operationOptions, callback, spanOptions) {
const { span, updatedOptions } = startSpan(name, operationOptions, spanOptions);
try {
const result = await withContext(updatedOptions.tracingOptions.tracingContext, () => Promise.resolve(callback(updatedOptions, span)));
span.setStatus({ status: "success" });
return result;
}
catch (err) {
span.setStatus({ status: "error", error: err });
throw err;
}
finally {
span.end();
}
}
function withContext(context, callback, ...callbackArgs) {
return getInstrumenter().withContext(context, callback, ...callbackArgs);
}
/**
* Parses a traceparent header value into a span identifier.
*
* @param traceparentHeader - The traceparent header to parse.
* @returns An implementation-specific identifier for the span.
*/
function parseTraceparentHeader(traceparentHeader) {
return getInstrumenter().parseTraceparentHeader(traceparentHeader);
}
/**
* Creates a set of request headers to propagate tracing information to a backend.
*
* @param tracingContext - The context containing the span to serialize.
* @returns The set of headers to add to a request.
*/
function createRequestHeaders(tracingContext) {
return getInstrumenter().createRequestHeaders(tracingContext);
}
return {
startSpan,
withSpan,
withContext,
parseTraceparentHeader,
createRequestHeaders,
};
}
//# sourceMappingURL=tracingClient.js.map

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,34 @@
import { TracingContext, TracingSpan } from "./interfaces.js";
/** @internal */
export declare const knownContextKeys: {
span: symbol;
namespace: symbol;
};
/**
* Creates a new {@link TracingContext} with the given options.
* @param options - A set of known keys that may be set on the context.
* @returns A new {@link TracingContext} with the given options.
*
* @internal
*/
export declare function createTracingContext(options?: CreateTracingContextOptions): TracingContext;
/** @internal */
export declare class TracingContextImpl implements TracingContext {
private _contextMap;
constructor(initialContext?: TracingContext);
setValue(key: symbol, value: unknown): TracingContext;
getValue(key: symbol): unknown;
deleteValue(key: symbol): TracingContext;
}
/**
* Represents a set of items that can be set when creating a new {@link TracingContext}.
*/
export interface CreateTracingContextOptions {
/** The {@link parentContext} - the newly created context will contain all the values of the parent context unless overridden. */
parentContext?: TracingContext;
/** An initial span to set on the context. */
span?: TracingSpan;
/** The namespace to set on any child spans. */
namespace?: string;
}
//# sourceMappingURL=tracingContext.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"tracingContext.d.ts","sourceRoot":"","sources":["../../src/tracingContext.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9D,gBAAgB;AAChB,eAAO,MAAM,gBAAgB;;;CAG5B,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,GAAE,2BAAgC,GAAG,cAAc,CAS9F;AAED,gBAAgB;AAChB,qBAAa,kBAAmB,YAAW,cAAc;IACvD,OAAO,CAAC,WAAW,CAAuB;gBAC9B,cAAc,CAAC,EAAE,cAAc;IAO3C,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,cAAc;IAMrD,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAI9B,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc;CAKzC;AAED;;GAEG;AACH,MAAM,WAAW,2BAA2B;IAC1C,iIAAiI;IACjI,aAAa,CAAC,EAAE,cAAc,CAAC;IAC/B,6CAA6C;IAC7C,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,+CAA+C;IAC/C,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB"}

View file

@ -0,0 +1,47 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
/** @internal */
export const knownContextKeys = {
span: Symbol.for("@azure/core-tracing span"),
namespace: Symbol.for("@azure/core-tracing namespace"),
};
/**
* Creates a new {@link TracingContext} with the given options.
* @param options - A set of known keys that may be set on the context.
* @returns A new {@link TracingContext} with the given options.
*
* @internal
*/
export function createTracingContext(options = {}) {
let context = new TracingContextImpl(options.parentContext);
if (options.span) {
context = context.setValue(knownContextKeys.span, options.span);
}
if (options.namespace) {
context = context.setValue(knownContextKeys.namespace, options.namespace);
}
return context;
}
/** @internal */
export class TracingContextImpl {
constructor(initialContext) {
this._contextMap =
initialContext instanceof TracingContextImpl
? new Map(initialContext._contextMap)
: new Map();
}
setValue(key, value) {
const newContext = new TracingContextImpl(this);
newContext._contextMap.set(key, value);
return newContext;
}
getValue(key) {
return this._contextMap.get(key);
}
deleteValue(key) {
const newContext = new TracingContextImpl(this);
newContext._contextMap.delete(key);
return newContext;
}
}
//# sourceMappingURL=tracingContext.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"tracingContext.js","sourceRoot":"","sources":["../../src/tracingContext.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAIlC,gBAAgB;AAChB,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,IAAI,EAAE,MAAM,CAAC,GAAG,CAAC,0BAA0B,CAAC;IAC5C,SAAS,EAAE,MAAM,CAAC,GAAG,CAAC,+BAA+B,CAAC;CACvD,CAAC;AAEF;;;;;;GAMG;AACH,MAAM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nimport { TracingContext, TracingSpan } from \"./interfaces.js\";\n\n/** @internal */\nexport const knownContextKeys = {\n span: Symbol.for(\"@azure/core-tracing span\"),\n namespace: Symbol.for(\"@azure/core-tracing namespace\"),\n};\n\n/**\n * Creates a new {@link TracingContext} with the given options.\n * @param options - A set of known keys that may be set on the context.\n * @returns A new {@link TracingContext} with the given options.\n *\n * @internal\n */\nexport function createTracingContext(options: CreateTracingContextOptions = {}): TracingContext {\n let context: TracingContext = new TracingContextImpl(options.parentContext);\n if (options.span) {\n context = context.setValue(knownContextKeys.span, options.span);\n }\n if (options.namespace) {\n context = context.setValue(knownContextKeys.namespace, options.namespace);\n }\n return context;\n}\n\n/** @internal */\nexport class TracingContextImpl implements TracingContext {\n private _contextMap: Map<symbol, unknown>;\n constructor(initialContext?: TracingContext) {\n this._contextMap =\n initialContext instanceof TracingContextImpl\n ? new Map<symbol, unknown>(initialContext._contextMap)\n : new Map();\n }\n\n setValue(key: symbol, value: unknown): TracingContext {\n const newContext = new TracingContextImpl(this);\n newContext._contextMap.set(key, value);\n return newContext;\n }\n\n getValue(key: symbol): unknown {\n return this._contextMap.get(key);\n }\n\n deleteValue(key: symbol): TracingContext {\n const newContext = new TracingContextImpl(this);\n newContext._contextMap.delete(key);\n return newContext;\n }\n}\n\n/**\n * Represents a set of items that can be set when creating a new {@link TracingContext}.\n */\nexport interface CreateTracingContextOptions {\n /** The {@link parentContext} - the newly created context will contain all the values of the parent context unless overridden. */\n parentContext?: TracingContext;\n /** An initial span to set on the context. */\n span?: TracingSpan;\n /** The namespace to set on any child spans. */\n namespace?: string;\n}\n"]}

View file

@ -0,0 +1,4 @@
export { Instrumenter, InstrumenterSpanOptions, OperationTracingOptions, OptionsWithTracingContext, Resolved, SpanStatus, SpanStatusError, SpanStatusSuccess, TracingClient, TracingClientOptions, TracingContext, TracingSpan, TracingSpanKind, TracingSpanLink, TracingSpanOptions, } from "./interfaces.js";
export { useInstrumenter } from "./instrumenter.js";
export { createTracingClient } from "./tracingClient.js";
//# sourceMappingURL=index.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,YAAY,EACZ,uBAAuB,EACvB,uBAAuB,EACvB,yBAAyB,EACzB,QAAQ,EACR,UAAU,EACV,eAAe,EACf,iBAAiB,EACjB,aAAa,EACb,oBAAoB,EACpB,cAAc,EACd,WAAW,EACX,eAAe,EACf,eAAe,EACf,kBAAkB,GACnB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC"}

View file

@ -0,0 +1,10 @@
"use strict";
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
Object.defineProperty(exports, "__esModule", { value: true });
exports.createTracingClient = exports.useInstrumenter = void 0;
var instrumenter_js_1 = require("./instrumenter.js");
Object.defineProperty(exports, "useInstrumenter", { enumerable: true, get: function () { return instrumenter_js_1.useInstrumenter; } });
var tracingClient_js_1 = require("./tracingClient.js");
Object.defineProperty(exports, "createTracingClient", { enumerable: true, get: function () { return tracingClient_js_1.createTracingClient; } });
//# sourceMappingURL=index.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAmBlC,qDAAoD;AAA3C,kHAAA,eAAe,OAAA;AACxB,uDAAyD;AAAhD,uHAAA,mBAAmB,OAAA","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nexport {\n Instrumenter,\n InstrumenterSpanOptions,\n OperationTracingOptions,\n OptionsWithTracingContext,\n Resolved,\n SpanStatus,\n SpanStatusError,\n SpanStatusSuccess,\n TracingClient,\n TracingClientOptions,\n TracingContext,\n TracingSpan,\n TracingSpanKind,\n TracingSpanLink,\n TracingSpanOptions,\n} from \"./interfaces.js\";\nexport { useInstrumenter } from \"./instrumenter.js\";\nexport { createTracingClient } from \"./tracingClient.js\";\n"]}

View file

@ -0,0 +1,16 @@
import { Instrumenter, TracingSpan } from "./interfaces.js";
export declare function createDefaultTracingSpan(): TracingSpan;
export declare function createDefaultInstrumenter(): Instrumenter;
/**
* Extends the Azure SDK with support for a given instrumenter implementation.
*
* @param instrumenter - The instrumenter implementation to use.
*/
export declare function useInstrumenter(instrumenter: Instrumenter): void;
/**
* Gets the currently set instrumenter, a No-Op instrumenter by default.
*
* @returns The currently set instrumenter
*/
export declare function getInstrumenter(): Instrumenter;
//# sourceMappingURL=instrumenter.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"instrumenter.d.ts","sourceRoot":"","sources":["../../src/instrumenter.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,YAAY,EAGZ,WAAW,EACZ,MAAM,iBAAiB,CAAC;AAKzB,wBAAgB,wBAAwB,IAAI,WAAW,CAgBtD;AAED,wBAAgB,yBAAyB,IAAI,YAAY,CA4BxD;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,YAAY,EAAE,YAAY,GAAG,IAAI,CAEhE;AAED;;;;GAIG;AACH,wBAAgB,eAAe,IAAI,YAAY,CAK9C"}

View file

@ -0,0 +1,67 @@
"use strict";
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
Object.defineProperty(exports, "__esModule", { value: true });
exports.getInstrumenter = exports.useInstrumenter = exports.createDefaultInstrumenter = exports.createDefaultTracingSpan = void 0;
const tracingContext_js_1 = require("./tracingContext.js");
const state_js_1 = require("./state.js");
function createDefaultTracingSpan() {
return {
end: () => {
// noop
},
isRecording: () => false,
recordException: () => {
// noop
},
setAttribute: () => {
// noop
},
setStatus: () => {
// noop
},
};
}
exports.createDefaultTracingSpan = createDefaultTracingSpan;
function createDefaultInstrumenter() {
return {
createRequestHeaders: () => {
return {};
},
parseTraceparentHeader: () => {
return undefined;
},
startSpan: (_name, spanOptions) => {
return {
span: createDefaultTracingSpan(),
tracingContext: (0, tracingContext_js_1.createTracingContext)({ parentContext: spanOptions.tracingContext }),
};
},
withContext(_context, callback, ...callbackArgs) {
return callback(...callbackArgs);
},
};
}
exports.createDefaultInstrumenter = createDefaultInstrumenter;
/**
* Extends the Azure SDK with support for a given instrumenter implementation.
*
* @param instrumenter - The instrumenter implementation to use.
*/
function useInstrumenter(instrumenter) {
state_js_1.state.instrumenterImplementation = instrumenter;
}
exports.useInstrumenter = useInstrumenter;
/**
* Gets the currently set instrumenter, a No-Op instrumenter by default.
*
* @returns The currently set instrumenter
*/
function getInstrumenter() {
if (!state_js_1.state.instrumenterImplementation) {
state_js_1.state.instrumenterImplementation = createDefaultInstrumenter();
}
return state_js_1.state.instrumenterImplementation;
}
exports.getInstrumenter = getInstrumenter;
//# sourceMappingURL=instrumenter.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"instrumenter.js","sourceRoot":"","sources":["../../src/instrumenter.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AASlC,2DAA2D;AAC3D,yCAAmC;AAEnC,SAAgB,wBAAwB;IACtC,OAAO;QACL,GAAG,EAAE,GAAG,EAAE;YACR,OAAO;QACT,CAAC;QACD,WAAW,EAAE,GAAG,EAAE,CAAC,KAAK;QACxB,eAAe,EAAE,GAAG,EAAE;YACpB,OAAO;QACT,CAAC;QACD,YAAY,EAAE,GAAG,EAAE;YACjB,OAAO;QACT,CAAC;QACD,SAAS,EAAE,GAAG,EAAE;YACd,OAAO;QACT,CAAC;KACF,CAAC;AACJ,CAAC;AAhBD,4DAgBC;AAED,SAAgB,yBAAyB;IACvC,OAAO;QACL,oBAAoB,EAAE,GAA2B,EAAE;YACjD,OAAO,EAAE,CAAC;QACZ,CAAC;QACD,sBAAsB,EAAE,GAA+B,EAAE;YACvD,OAAO,SAAS,CAAC;QACnB,CAAC;QACD,SAAS,EAAE,CACT,KAAa,EACb,WAAoC,EACmB,EAAE;YACzD,OAAO;gBACL,IAAI,EAAE,wBAAwB,EAAE;gBAChC,cAAc,EAAE,IAAA,wCAAoB,EAAC,EAAE,aAAa,EAAE,WAAW,CAAC,cAAc,EAAE,CAAC;aACpF,CAAC;QACJ,CAAC;QACD,WAAW,CAIT,QAAwB,EACxB,QAAkB,EAClB,GAAG,YAA0B;YAE7B,OAAO,QAAQ,CAAC,GAAG,YAAY,CAAC,CAAC;QACnC,CAAC;KACF,CAAC;AACJ,CAAC;AA5BD,8DA4BC;AAED;;;;GAIG;AACH,SAAgB,eAAe,CAAC,YAA0B;IACxD,gBAAK,CAAC,0BAA0B,GAAG,YAAY,CAAC;AAClD,CAAC;AAFD,0CAEC;AAED;;;;GAIG;AACH,SAAgB,eAAe;IAC7B,IAAI,CAAC,gBAAK,CAAC,0BAA0B,EAAE,CAAC;QACtC,gBAAK,CAAC,0BAA0B,GAAG,yBAAyB,EAAE,CAAC;IACjE,CAAC;IACD,OAAO,gBAAK,CAAC,0BAA0B,CAAC;AAC1C,CAAC;AALD,0CAKC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n Instrumenter,\n InstrumenterSpanOptions,\n TracingContext,\n TracingSpan,\n} from \"./interfaces.js\";\n\nimport { createTracingContext } from \"./tracingContext.js\";\nimport { state } from \"./state.js\";\n\nexport function createDefaultTracingSpan(): TracingSpan {\n return {\n end: () => {\n // noop\n },\n isRecording: () => false,\n recordException: () => {\n // noop\n },\n setAttribute: () => {\n // noop\n },\n setStatus: () => {\n // noop\n },\n };\n}\n\nexport function createDefaultInstrumenter(): Instrumenter {\n return {\n createRequestHeaders: (): Record<string, string> => {\n return {};\n },\n parseTraceparentHeader: (): TracingContext | undefined => {\n return undefined;\n },\n startSpan: (\n _name: string,\n spanOptions: InstrumenterSpanOptions,\n ): { span: TracingSpan; tracingContext: TracingContext } => {\n return {\n span: createDefaultTracingSpan(),\n tracingContext: createTracingContext({ parentContext: spanOptions.tracingContext }),\n };\n },\n withContext<\n CallbackArgs extends unknown[],\n Callback extends (...args: CallbackArgs) => ReturnType<Callback>,\n >(\n _context: TracingContext,\n callback: Callback,\n ...callbackArgs: CallbackArgs\n ): ReturnType<Callback> {\n return callback(...callbackArgs);\n },\n };\n}\n\n/**\n * Extends the Azure SDK with support for a given instrumenter implementation.\n *\n * @param instrumenter - The instrumenter implementation to use.\n */\nexport function useInstrumenter(instrumenter: Instrumenter): void {\n state.instrumenterImplementation = instrumenter;\n}\n\n/**\n * Gets the currently set instrumenter, a No-Op instrumenter by default.\n *\n * @returns The currently set instrumenter\n */\nexport function getInstrumenter(): Instrumenter {\n if (!state.instrumenterImplementation) {\n state.instrumenterImplementation = createDefaultInstrumenter();\n }\n return state.instrumenterImplementation;\n}\n"]}

View file

@ -0,0 +1,254 @@
/**
* A narrower version of TypeScript 4.5's Awaited type which Recursively
* unwraps the "awaited type", emulating the behavior of `await`.
*/
export type Resolved<T> = T extends {
then(onfulfilled: infer F): any;
} ? F extends (value: infer V) => any ? Resolved<V> : never : T;
/**
* Represents a client that can integrate with the currently configured {@link Instrumenter}.
*
* Create an instance using {@link createTracingClient}.
*/
export interface TracingClient {
/**
* Wraps a callback in a tracing span, calls the callback, and closes the span.
*
* This is the primary interface for using Tracing and will handle error recording as well as setting the status on the span.
*
* Both synchronous and asynchronous functions will be awaited in order to reflect the result of the callback on the span.
*
* Example:
*
* ```ts
* const myOperationResult = await tracingClient.withSpan("myClassName.myOperationName", options, (updatedOptions) => myOperation(updatedOptions));
* ```
* @param name - The name of the span. By convention this should be `${className}.${methodName}`.
* @param operationOptions - The original options passed to the method. The callback will receive these options with the newly created {@link TracingContext}.
* @param callback - The callback to be invoked with the updated options and newly created {@link TracingSpan}.
*/
withSpan<Options extends {
tracingOptions?: OperationTracingOptions;
}, Callback extends (updatedOptions: Options, span: Omit<TracingSpan, "end">) => ReturnType<Callback>>(name: string, operationOptions: Options, callback: Callback, spanOptions?: TracingSpanOptions): Promise<Resolved<ReturnType<Callback>>>;
/**
* Starts a given span but does not set it as the active span.
*
* You must end the span using {@link TracingSpan.end}.
*
* Most of the time you will want to use {@link withSpan} instead.
*
* @param name - The name of the span. By convention this should be `${className}.${methodName}`.
* @param operationOptions - The original operation options.
* @param spanOptions - The options to use when creating the span.
*
* @returns A {@link TracingSpan} and the updated operation options.
*/
startSpan<Options extends {
tracingOptions?: OperationTracingOptions;
}>(name: string, operationOptions?: Options, spanOptions?: TracingSpanOptions): {
span: TracingSpan;
updatedOptions: OptionsWithTracingContext<Options>;
};
/**
* Wraps a callback with an active context and calls the callback.
* Depending on the implementation, this may set the globally available active context.
*
* Useful when you want to leave the boundaries of the SDK (make a request or callback to user code) and are unable to use the {@link withSpan} API.
*
* @param context - The {@link TracingContext} to use as the active context in the scope of the callback.
* @param callback - The callback to be invoked with the given context set as the globally active context.
* @param callbackArgs - The callback arguments.
*/
withContext<CallbackArgs extends unknown[], Callback extends (...args: CallbackArgs) => ReturnType<Callback>>(context: TracingContext, callback: Callback, ...callbackArgs: CallbackArgs): ReturnType<Callback>;
/**
* Parses a traceparent header value into a {@link TracingSpanContext}.
*
* @param traceparentHeader - The traceparent header to parse.
* @returns An implementation-specific identifier for the span.
*/
parseTraceparentHeader(traceparentHeader: string): TracingContext | undefined;
/**
* Creates a set of request headers to propagate tracing information to a backend.
*
* @param tracingContext - The context containing the span to propagate.
* @returns The set of headers to add to a request.
*/
createRequestHeaders(tracingContext?: TracingContext): Record<string, string>;
}
/**
* Options that can be passed to {@link createTracingClient}
*/
export interface TracingClientOptions {
/** The value of the az.namespace tracing attribute on newly created spans. */
namespace: string;
/** The name of the package invoking this trace. */
packageName: string;
/** An optional version of the package invoking this trace. */
packageVersion?: string;
}
/** The kind of span. */
export type TracingSpanKind = "client" | "server" | "producer" | "consumer" | "internal";
/** Options used to configure the newly created span. */
export interface TracingSpanOptions {
/** The kind of span. Implementations should default this to "client". */
spanKind?: TracingSpanKind;
/** A collection of {@link TracingSpanLink} to link to this span. */
spanLinks?: TracingSpanLink[];
/** Initial set of attributes to set on a span. */
spanAttributes?: {
[key: string]: unknown;
};
}
/** A pointer from the current {@link TracingSpan} to another span in the same or a different trace. */
export interface TracingSpanLink {
/** The {@link TracingContext} containing the span context to link to. */
tracingContext: TracingContext;
/** A set of attributes on the link. */
attributes?: {
[key: string]: unknown;
};
}
/**
* Represents an implementation agnostic instrumenter.
*/
export interface Instrumenter {
/**
* Creates a new {@link TracingSpan} with the given name and options and sets it on a new context.
* @param name - The name of the span. By convention this should be `${className}.${methodName}`.
* @param spanOptions - The options to use when creating the span.
*
* @returns A {@link TracingSpan} that can be used to end the span, and the context this span has been set on.
*/
startSpan(name: string, spanOptions: InstrumenterSpanOptions): {
span: TracingSpan;
tracingContext: TracingContext;
};
/**
* Wraps a callback with an active context and calls the callback.
* Depending on the implementation, this may set the globally available active context.
*
* @param context - The {@link TracingContext} to use as the active context in the scope of the callback.
* @param callback - The callback to be invoked with the given context set as the globally active context.
* @param callbackArgs - The callback arguments.
*/
withContext<CallbackArgs extends unknown[], Callback extends (...args: CallbackArgs) => ReturnType<Callback>>(context: TracingContext, callback: Callback, ...callbackArgs: CallbackArgs): ReturnType<Callback>;
/**
* Provides an implementation-specific method to parse a {@link https://www.w3.org/TR/trace-context/#traceparent-header}
* into a {@link TracingSpanContext} which can be used to link non-parented spans together.
*/
parseTraceparentHeader(traceparentHeader: string): TracingContext | undefined;
/**
* Provides an implementation-specific method to serialize a {@link TracingSpan} to a set of headers.
* @param tracingContext - The context containing the span to serialize.
*/
createRequestHeaders(tracingContext?: TracingContext): Record<string, string>;
}
/**
* Options passed to {@link Instrumenter.startSpan} as a superset of {@link TracingSpanOptions}.
*/
export interface InstrumenterSpanOptions extends TracingSpanOptions {
/** The name of the package invoking this trace. */
packageName: string;
/** The version of the package invoking this trace. */
packageVersion?: string;
/** The current tracing context. Defaults to an implementation-specific "active" context. */
tracingContext?: TracingContext;
}
/**
* Status representing a successful operation that can be sent to {@link TracingSpan.setStatus}
*/
export type SpanStatusSuccess = {
status: "success";
};
/**
* Status representing an error that can be sent to {@link TracingSpan.setStatus}
*/
export type SpanStatusError = {
status: "error";
error?: Error | string;
};
/**
* Represents the statuses that can be passed to {@link TracingSpan.setStatus}.
*
* By default, all spans will be created with status "unset".
*/
export type SpanStatus = SpanStatusSuccess | SpanStatusError;
/**
* Represents an implementation agnostic tracing span.
*/
export interface TracingSpan {
/**
* Sets the status of the span. When an error is provided, it will be recorded on the span as well.
*
* @param status - The {@link SpanStatus} to set on the span.
*/
setStatus(status: SpanStatus): void;
/**
* Sets a given attribute on a span.
*
* @param name - The attribute's name.
* @param value - The attribute's value to set. May be any non-nullish value.
*/
setAttribute(name: string, value: unknown): void;
/**
* Ends the span.
*/
end(): void;
/**
* Records an exception on a {@link TracingSpan} without modifying its status.
*
* When recording an unhandled exception that should fail the span, please use {@link TracingSpan.setStatus} instead.
*
* @param exception - The exception to record on the span.
*
*/
recordException(exception: Error | string): void;
/**
* Returns true if this {@link TracingSpan} is recording information.
*
* Depending on the span implementation, this may return false if the span is not being sampled.
*/
isRecording(): boolean;
}
/** An immutable context bag of tracing values for the current operation. */
export interface TracingContext {
/**
* Sets a given object on a context.
* @param key - The key of the given context value.
* @param value - The value to set on the context.
*
* @returns - A new context with the given value set.
*/
setValue(key: symbol, value: unknown): TracingContext;
/**
* Gets an object from the context if it exists.
* @param key - The key of the given context value.
*
* @returns - The value of the given context value if it exists, otherwise `undefined`.
*/
getValue(key: symbol): unknown;
/**
* Deletes an object from the context if it exists.
* @param key - The key of the given context value to delete.
*/
deleteValue(key: symbol): TracingContext;
}
/**
* Tracing options to set on an operation.
*/
export interface OperationTracingOptions {
/** The context to use for created Tracing Spans. */
tracingContext?: TracingContext;
}
/**
* A utility type for when we know a TracingContext has been set
* as part of an operation's options.
*/
export type OptionsWithTracingContext<Options extends {
tracingOptions?: OperationTracingOptions;
}> = Options & {
tracingOptions: {
tracingContext: TracingContext;
};
};
//# sourceMappingURL=interfaces.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"interfaces.d.ts","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AK,GAAG,MAAM,GAAG,IAAI,CAAC;IAEjD;;;;OAIG;IACH,WAAW,IAAI,OAAO,CAAC;CACxB;AAED,4EAA4E;AAC5E,MAAM,WAAW,cAAc;IAC7B;;;;;;OAMG;IACH,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,cAAc,CAAC;IACtD;;;;;OAKG;IACH,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;IAC/B;;;OAGG;IACH,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc,CAAC;CAC1C;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,oDAAoD;IACpD,cAAc,CAAC,EAAE,cAAc,CAAC;CACjC;AAED;;;GAGG;AACH,MAAM,MAAM,yBAAyB,CACnC,OAAO,SAAS;IAAE,cAAc,CAAC,EAAE,uBAAuB,CAAA;CAAE,IAC1D,OAAO,GAAG;IACZ,cAAc,EAAE;QACd,cAAc,EAAE,cAAc,CAAC;KAChC,CAAC;CACH,CAAC"}

View file

@ -0,0 +1,5 @@
"use strict";
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=interfaces.js.map

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,3 @@
{
"type": "commonjs"
}

View file

@ -0,0 +1 @@
{"version":3,"file":"state-cjs.cjs","sourceRoot":"","sources":["../../src/state-cjs.cts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAElC;;;;GAIG;AACU,QAAA,KAAK,GAAG;IACnB,0BAA0B,EAAE,SAAS;CACtC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/**\n * @internal\n *\n * Holds the singleton instrumenter, to be shared across CJS and ESM imports.\n */\nexport const state = {\n instrumenterImplementation: undefined,\n};\n"]}

View file

@ -0,0 +1 @@
{"version":3,"file":"state-cjs.d.cts","sourceRoot":"","sources":["../../src/state-cjs.cts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,eAAO,MAAM,KAAK;;CAEjB,CAAC"}

View file

@ -0,0 +1,9 @@
/**
* @internal
*
* Holds the singleton instrumenter, to be shared across CJS and ESM imports.
*/
export declare const state: {
instrumenterImplementation: undefined;
};
//# sourceMappingURL=state-cjs.d.cts.map

View file

@ -0,0 +1,14 @@
"use strict";
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
Object.defineProperty(exports, "__esModule", { value: true });
exports.state = void 0;
/**
* @internal
*
* Holds the singleton instrumenter, to be shared across CJS and ESM imports.
*/
exports.state = {
instrumenterImplementation: undefined,
};
//# sourceMappingURL=state-cjs.cjs.map

View file

@ -0,0 +1,9 @@
import { TracingClient, TracingClientOptions } from "./interfaces.js";
/**
* Creates a new tracing client.
*
* @param options - Options used to configure the tracing client.
* @returns - An instance of {@link TracingClient}.
*/
export declare function createTracingClient(options: TracingClientOptions): TracingClient;
//# sourceMappingURL=tracingClient.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"tracingClient.d.ts","sourceRoot":"","sources":["../../src/tracingClient.ts"],"names":[],"mappings":"AAGA,OAAO,EAIL,aAAa,EACb,oBAAoB,EAIrB,MAAM,iBAAiB,CAAC;AAIzB;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,oBAAoB,GAAG,aAAa,CAkGhF"}

View file

@ -0,0 +1,78 @@
"use strict";
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
Object.defineProperty(exports, "__esModule", { value: true });
exports.createTracingClient = void 0;
const instrumenter_js_1 = require("./instrumenter.js");
const tracingContext_js_1 = require("./tracingContext.js");
/**
* Creates a new tracing client.
*
* @param options - Options used to configure the tracing client.
* @returns - An instance of {@link TracingClient}.
*/
function createTracingClient(options) {
const { namespace, packageName, packageVersion } = options;
function startSpan(name, operationOptions, spanOptions) {
var _a;
const startSpanResult = (0, instrumenter_js_1.getInstrumenter)().startSpan(name, Object.assign(Object.assign({}, spanOptions), { packageName: packageName, packageVersion: packageVersion, tracingContext: (_a = operationOptions === null || operationOptions === void 0 ? void 0 : operationOptions.tracingOptions) === null || _a === void 0 ? void 0 : _a.tracingContext }));
let tracingContext = startSpanResult.tracingContext;
const span = startSpanResult.span;
if (!tracingContext.getValue(tracingContext_js_1.knownContextKeys.namespace)) {
tracingContext = tracingContext.setValue(tracingContext_js_1.knownContextKeys.namespace, namespace);
}
span.setAttribute("az.namespace", tracingContext.getValue(tracingContext_js_1.knownContextKeys.namespace));
const updatedOptions = Object.assign({}, operationOptions, {
tracingOptions: Object.assign(Object.assign({}, operationOptions === null || operationOptions === void 0 ? void 0 : operationOptions.tracingOptions), { tracingContext }),
});
return {
span,
updatedOptions,
};
}
async function withSpan(name, operationOptions, callback, spanOptions) {
const { span, updatedOptions } = startSpan(name, operationOptions, spanOptions);
try {
const result = await withContext(updatedOptions.tracingOptions.tracingContext, () => Promise.resolve(callback(updatedOptions, span)));
span.setStatus({ status: "success" });
return result;
}
catch (err) {
span.setStatus({ status: "error", error: err });
throw err;
}
finally {
span.end();
}
}
function withContext(context, callback, ...callbackArgs) {
return (0, instrumenter_js_1.getInstrumenter)().withContext(context, callback, ...callbackArgs);
}
/**
* Parses a traceparent header value into a span identifier.
*
* @param traceparentHeader - The traceparent header to parse.
* @returns An implementation-specific identifier for the span.
*/
function parseTraceparentHeader(traceparentHeader) {
return (0, instrumenter_js_1.getInstrumenter)().parseTraceparentHeader(traceparentHeader);
}
/**
* Creates a set of request headers to propagate tracing information to a backend.
*
* @param tracingContext - The context containing the span to serialize.
* @returns The set of headers to add to a request.
*/
function createRequestHeaders(tracingContext) {
return (0, instrumenter_js_1.getInstrumenter)().createRequestHeaders(tracingContext);
}
return {
startSpan,
withSpan,
withContext,
parseTraceparentHeader,
createRequestHeaders,
};
}
exports.createTracingClient = createTracingClient;
//# sourceMappingURL=tracingClient.js.map

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,34 @@
import { TracingContext, TracingSpan } from "./interfaces.js";
/** @internal */
export declare const knownContextKeys: {
span: symbol;
namespace: symbol;
};
/**
* Creates a new {@link TracingContext} with the given options.
* @param options - A set of known keys that may be set on the context.
* @returns A new {@link TracingContext} with the given options.
*
* @internal
*/
export declare function createTracingContext(options?: CreateTracingContextOptions): TracingContext;
/** @internal */
export declare class TracingContextImpl implements TracingContext {
private _contextMap;
constructor(initialContext?: TracingContext);
setValue(key: symbol, value: unknown): TracingContext;
getValue(key: symbol): unknown;
deleteValue(key: symbol): TracingContext;
}
/**
* Represents a set of items that can be set when creating a new {@link TracingContext}.
*/
export interface CreateTracingContextOptions {
/** The {@link parentContext} - the newly created context will contain all the values of the parent context unless overridden. */
parentContext?: TracingContext;
/** An initial span to set on the context. */
span?: TracingSpan;
/** The namespace to set on any child spans. */
namespace?: string;
}
//# sourceMappingURL=tracingContext.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"tracingContext.d.ts","sourceRoot":"","sources":["../../src/tracingContext.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9D,gBAAgB;AAChB,eAAO,MAAM,gBAAgB;;;CAG5B,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,GAAE,2BAAgC,GAAG,cAAc,CAS9F;AAED,gBAAgB;AAChB,qBAAa,kBAAmB,YAAW,cAAc;IACvD,OAAO,CAAC,WAAW,CAAuB;gBAC9B,cAAc,CAAC,EAAE,cAAc;IAO3C,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,cAAc;IAMrD,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAI9B,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc;CAKzC;AAED;;GAEG;AACH,MAAM,WAAW,2BAA2B;IAC1C,iIAAiI;IACjI,aAAa,CAAC,EAAE,cAAc,CAAC;IAC/B,6CAA6C;IAC7C,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,+CAA+C;IAC/C,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB"}

View file

@ -0,0 +1,52 @@
"use strict";
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
Object.defineProperty(exports, "__esModule", { value: true });
exports.TracingContextImpl = exports.createTracingContext = exports.knownContextKeys = void 0;
/** @internal */
exports.knownContextKeys = {
span: Symbol.for("@azure/core-tracing span"),
namespace: Symbol.for("@azure/core-tracing namespace"),
};
/**
* Creates a new {@link TracingContext} with the given options.
* @param options - A set of known keys that may be set on the context.
* @returns A new {@link TracingContext} with the given options.
*
* @internal
*/
function createTracingContext(options = {}) {
let context = new TracingContextImpl(options.parentContext);
if (options.span) {
context = context.setValue(exports.knownContextKeys.span, options.span);
}
if (options.namespace) {
context = context.setValue(exports.knownContextKeys.namespace, options.namespace);
}
return context;
}
exports.createTracingContext = createTracingContext;
/** @internal */
class TracingContextImpl {
constructor(initialContext) {
this._contextMap =
initialContext instanceof TracingContextImpl
? new Map(initialContext._contextMap)
: new Map();
}
setValue(key, value) {
const newContext = new TracingContextImpl(this);
newContext._contextMap.set(key, value);
return newContext;
}
getValue(key) {
return this._contextMap.get(key);
}
deleteValue(key) {
const newContext = new TracingContextImpl(this);
newContext._contextMap.delete(key);
return newContext;
}
}
exports.TracingContextImpl = TracingContextImpl;
//# sourceMappingURL=tracingContext.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"tracingContext.js","sourceRoot":"","sources":["../../src/tracingContext.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAIlC,gBAAgB;AACH,QAAA,gBAAgB,GAAG;IAC9B,IAAI,EAAE,MAAM,CAAC,GAAG,CAAC,0BAA0B,CAAC;IAC5C,SAAS,EAAE,MAAM,CAAC,GAAG,CAAC,+BAA+B,CAAC;CACvD,CAAC;AAEF;;;;;;GAMG;AACH,SAAgB,oBAAoB,CAAC,UAAuC,EAAE;I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Span } from \"./interfaces.js\";\n\n/** @internal */\nexport const knownContextKeys = {\n span: Symbol.for(\"@azure/core-tracing span\"),\n namespace: Symbol.for(\"@azure/core-tracing namespace\"),\n};\n\n/**\n * Creates a new {@link TracingContext} with the given options.\n * @param options - A set of known keys that may be set on the context.\n * @returns A new {@link TracingContext} with the given options.\n *\n * @internal\n */\nexport function createTracingContext(options: CreateTracingContextOptions = {}): TracingContext {\n let context: TracingContext = new TracingContextImpl(options.parentContext);\n if (options.span) {\n context = context.setValue(knownContextKeys.span, options.span);\n }\n if (options.namespace) {\n context = context.setValue(knownContextKeys.namespace, options.namespace);\n }\n return context;\n}\n\n/** @internal */\nexport class TracingContextImpl implements TracingContext {\n private _contextMap: Map<symbol, unknown>;\n constructor(initialContext?: TracingContext) {\n this._contextMap =\n initialContext instanceof TracingContextImpl\n ? new Map<symbol, unknown>(initialContext._contextMap)\n : new Map();\n }\n\n setValue(key: symbol, value: unknown): TracingContext {\n const newContext = new TracingContextImpl(this);\n newContext._contextMap.set(key, value);\n return newContext;\n }\n\n getValue(key: symbol): unknown {\n return this._contextMap.get(key);\n }\n\n deleteValue(key: symbol): TracingContext {\n const newContext = new TracingContextImpl(this);\n newContext._contextMap.delete(key);\n return newContext;\n }\n}\n\n/**\n * Represents a set of items that can be set when creating a new {@link TracingContext}.\n */\nexport interface CreateTracingContextOptions {\n /** The {@link parentContext} - the newly created context will contain all the values of the parent context unless overridden. */\n parentContext?: TracingContext;\n /** An initial span to set on the context. */\n span?: TracingSpan;\n /** The namespace to set on any child spans. */\n namespace?: string;\n}\n"]}

View file

@ -0,0 +1,11 @@
// This file is read by tools that parse documentation comments conforming to the TSDoc standard.
// It should be published with your NPM package. It should not be tracked by Git.
{
"tsdocVersion": "0.12",
"toolPackages": [
{
"packageName": "@microsoft/api-extractor",
"packageVersion": "7.43.1"
}
]
}

284
node_modules/@azure/core-tracing/dist/core-tracing.d.ts generated vendored Normal file
View file

@ -0,0 +1,284 @@
/**
* Creates a new tracing client.
*
* @param options - Options used to configure the tracing client.
* @returns - An instance of {@link TracingClient}.
*/
export declare function createTracingClient(options: TracingClientOptions): TracingClient;
/**
* Represents an implementation agnostic instrumenter.
*/
export declare interface Instrumenter {
/**
* Creates a new {@link TracingSpan} with the given name and options and sets it on a new context.
* @param name - The name of the span. By convention this should be `${className}.${methodName}`.
* @param spanOptions - The options to use when creating the span.
*
* @returns A {@link TracingSpan} that can be used to end the span, and the context this span has been set on.
*/
startSpan(name: string, spanOptions: InstrumenterSpanOptions): {
span: TracingSpan;
tracingContext: TracingContext;
};
/**
* Wraps a callback with an active context and calls the callback.
* Depending on the implementation, this may set the globally available active context.
*
* @param context - The {@link TracingContext} to use as the active context in the scope of the callback.
* @param callback - The callback to be invoked with the given context set as the globally active context.
* @param callbackArgs - The callback arguments.
*/
withContext<CallbackArgs extends unknown[], Callback extends (...args: CallbackArgs) => ReturnType<Callback>>(context: TracingContext, callback: Callback, ...callbackArgs: CallbackArgs): ReturnType<Callback>;
/**
* Provides an implementation-specific method to parse a {@link https://www.w3.org/TR/trace-context/#traceparent-header}
* into a {@link TracingSpanContext} which can be used to link non-parented spans together.
*/
parseTraceparentHeader(traceparentHeader: string): TracingContext | undefined;
/**
* Provides an implementation-specific method to serialize a {@link TracingSpan} to a set of headers.
* @param tracingContext - The context containing the span to serialize.
*/
createRequestHeaders(tracingContext?: TracingContext): Record<string, string>;
}
/**
* Options passed to {@link Instrumenter.startSpan} as a superset of {@link TracingSpanOptions}.
*/
export declare interface InstrumenterSpanOptions extends TracingSpanOptions {
/** The name of the package invoking this trace. */
packageName: string;
/** The version of the package invoking this trace. */
packageVersion?: string;
/** The current tracing context. Defaults to an implementation-specific "active" context. */
tracingContext?: TracingContext;
}
/**
* Tracing options to set on an operation.
*/
export declare interface OperationTracingOptions {
/** The context to use for created Tracing Spans. */
tracingContext?: TracingContext;
}
/**
* A utility type for when we know a TracingContext has been set
* as part of an operation's options.
*/
export declare type OptionsWithTracingContext<Options extends {
tracingOptions?: OperationTracingOptions;
}> = Options & {
tracingOptions: {
tracingContext: TracingContext;
};
};
/**
* A narrower version of TypeScript 4.5's Awaited type which Recursively
* unwraps the "awaited type", emulating the behavior of `await`.
*/
export declare type Resolved<T> = T extends {
then(onfulfilled: infer F): any;
} ? F extends (value: infer V) => any ? Resolved<V> : never : T;
/**
* Represents the statuses that can be passed to {@link TracingSpan.setStatus}.
*
* By default, all spans will be created with status "unset".
*/
export declare type SpanStatus = SpanStatusSuccess | SpanStatusError;
/**
* Status representing an error that can be sent to {@link TracingSpan.setStatus}
*/
export declare type SpanStatusError = {
status: "error";
error?: Error | string;
};
/**
* Status representing a successful operation that can be sent to {@link TracingSpan.setStatus}
*/
export declare type SpanStatusSuccess = {
status: "success";
};
/**
* Represents a client that can integrate with the currently configured {@link Instrumenter}.
*
* Create an instance using {@link createTracingClient}.
*/
export declare interface TracingClient {
/**
* Wraps a callback in a tracing span, calls the callback, and closes the span.
*
* This is the primary interface for using Tracing and will handle error recording as well as setting the status on the span.
*
* Both synchronous and asynchronous functions will be awaited in order to reflect the result of the callback on the span.
*
* Example:
*
* ```ts
* const myOperationResult = await tracingClient.withSpan("myClassName.myOperationName", options, (updatedOptions) => myOperation(updatedOptions));
* ```
* @param name - The name of the span. By convention this should be `${className}.${methodName}`.
* @param operationOptions - The original options passed to the method. The callback will receive these options with the newly created {@link TracingContext}.
* @param callback - The callback to be invoked with the updated options and newly created {@link TracingSpan}.
*/
withSpan<Options extends {
tracingOptions?: OperationTracingOptions;
}, Callback extends (updatedOptions: Options, span: Omit<TracingSpan, "end">) => ReturnType<Callback>>(name: string, operationOptions: Options, callback: Callback, spanOptions?: TracingSpanOptions): Promise<Resolved<ReturnType<Callback>>>;
/**
* Starts a given span but does not set it as the active span.
*
* You must end the span using {@link TracingSpan.end}.
*
* Most of the time you will want to use {@link withSpan} instead.
*
* @param name - The name of the span. By convention this should be `${className}.${methodName}`.
* @param operationOptions - The original operation options.
* @param spanOptions - The options to use when creating the span.
*
* @returns A {@link TracingSpan} and the updated operation options.
*/
startSpan<Options extends {
tracingOptions?: OperationTracingOptions;
}>(name: string, operationOptions?: Options, spanOptions?: TracingSpanOptions): {
span: TracingSpan;
updatedOptions: OptionsWithTracingContext<Options>;
};
/**
* Wraps a callback with an active context and calls the callback.
* Depending on the implementation, this may set the globally available active context.
*
* Useful when you want to leave the boundaries of the SDK (make a request or callback to user code) and are unable to use the {@link withSpan} API.
*
* @param context - The {@link TracingContext} to use as the active context in the scope of the callback.
* @param callback - The callback to be invoked with the given context set as the globally active context.
* @param callbackArgs - The callback arguments.
*/
withContext<CallbackArgs extends unknown[], Callback extends (...args: CallbackArgs) => ReturnType<Callback>>(context: TracingContext, callback: Callback, ...callbackArgs: CallbackArgs): ReturnType<Callback>;
/**
* Parses a traceparent header value into a {@link TracingSpanContext}.
*
* @param traceparentHeader - The traceparent header to parse.
* @returns An implementation-specific identifier for the span.
*/
parseTraceparentHeader(traceparentHeader: string): TracingContext | undefined;
/**
* Creates a set of request headers to propagate tracing information to a backend.
*
* @param tracingContext - The context containing the span to propagate.
* @returns The set of headers to add to a request.
*/
createRequestHeaders(tracingContext?: TracingContext): Record<string, string>;
}
/**
* Options that can be passed to {@link createTracingClient}
*/
export declare interface TracingClientOptions {
/** The value of the az.namespace tracing attribute on newly created spans. */
namespace: string;
/** The name of the package invoking this trace. */
packageName: string;
/** An optional version of the package invoking this trace. */
packageVersion?: string;
}
/** An immutable context bag of tracing values for the current operation. */
export declare interface TracingContext {
/**
* Sets a given object on a context.
* @param key - The key of the given context value.
* @param value - The value to set on the context.
*
* @returns - A new context with the given value set.
*/
setValue(key: symbol, value: unknown): TracingContext;
/**
* Gets an object from the context if it exists.
* @param key - The key of the given context value.
*
* @returns - The value of the given context value if it exists, otherwise `undefined`.
*/
getValue(key: symbol): unknown;
/**
* Deletes an object from the context if it exists.
* @param key - The key of the given context value to delete.
*/
deleteValue(key: symbol): TracingContext;
}
/**
* Represents an implementation agnostic tracing span.
*/
export declare interface TracingSpan {
/**
* Sets the status of the span. When an error is provided, it will be recorded on the span as well.
*
* @param status - The {@link SpanStatus} to set on the span.
*/
setStatus(status: SpanStatus): void;
/**
* Sets a given attribute on a span.
*
* @param name - The attribute's name.
* @param value - The attribute's value to set. May be any non-nullish value.
*/
setAttribute(name: string, value: unknown): void;
/**
* Ends the span.
*/
end(): void;
/**
* Records an exception on a {@link TracingSpan} without modifying its status.
*
* When recording an unhandled exception that should fail the span, please use {@link TracingSpan.setStatus} instead.
*
* @param exception - The exception to record on the span.
*
*/
recordException(exception: Error | string): void;
/**
* Returns true if this {@link TracingSpan} is recording information.
*
* Depending on the span implementation, this may return false if the span is not being sampled.
*/
isRecording(): boolean;
}
/** The kind of span. */
export declare type TracingSpanKind = "client" | "server" | "producer" | "consumer" | "internal";
/** A pointer from the current {@link TracingSpan} to another span in the same or a different trace. */
export declare interface TracingSpanLink {
/** The {@link TracingContext} containing the span context to link to. */
tracingContext: TracingContext;
/** A set of attributes on the link. */
attributes?: {
[key: string]: unknown;
};
}
/** Options used to configure the newly created span. */
export declare interface TracingSpanOptions {
/** The kind of span. Implementations should default this to "client". */
spanKind?: TracingSpanKind;
/** A collection of {@link TracingSpanLink} to link to this span. */
spanLinks?: TracingSpanLink[];
/** Initial set of attributes to set on a span. */
spanAttributes?: {
[key: string]: unknown;
};
}
/**
* Extends the Azure SDK with support for a given instrumenter implementation.
*
* @param instrumenter - The instrumenter implementation to use.
*/
export declare function useInstrumenter(instrumenter: Instrumenter): void;
export { }

4
node_modules/@azure/core-tracing/dist/esm/index.d.ts generated vendored Normal file
View file

@ -0,0 +1,4 @@
export { Instrumenter, InstrumenterSpanOptions, OperationTracingOptions, OptionsWithTracingContext, Resolved, SpanStatus, SpanStatusError, SpanStatusSuccess, TracingClient, TracingClientOptions, TracingContext, TracingSpan, TracingSpanKind, TracingSpanLink, TracingSpanOptions, } from "./interfaces.js";
export { useInstrumenter } from "./instrumenter.js";
export { createTracingClient } from "./tracingClient.js";
//# sourceMappingURL=index.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,YAAY,EACZ,uBAAuB,EACvB,uBAAuB,EACvB,yBAAyB,EACzB,QAAQ,EACR,UAAU,EACV,eAAe,EACf,iBAAiB,EACjB,aAAa,EACb,oBAAoB,EACpB,cAAc,EACd,WAAW,EACX,eAAe,EACf,eAAe,EACf,kBAAkB,GACnB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC"}

5
node_modules/@azure/core-tracing/dist/esm/index.js generated vendored Normal file
View file

@ -0,0 +1,5 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
export { useInstrumenter } from "./instrumenter.js";
export { createTracingClient } from "./tracingClient.js";
//# sourceMappingURL=index.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAmBlC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nexport {\n Instrumenter,\n InstrumenterSpanOptions,\n OperationTracingOptions,\n OptionsWithTracingContext,\n Resolved,\n SpanStatus,\n SpanStatusError,\n SpanStatusSuccess,\n TracingClient,\n TracingClientOptions,\n TracingContext,\n TracingSpan,\n TracingSpanKind,\n TracingSpanLink,\n TracingSpanOptions,\n} from \"./interfaces.js\";\nexport { useInstrumenter } from \"./instrumenter.js\";\nexport { createTracingClient } from \"./tracingClient.js\";\n"]}

View file

@ -0,0 +1,16 @@
import { Instrumenter, TracingSpan } from "./interfaces.js";
export declare function createDefaultTracingSpan(): TracingSpan;
export declare function createDefaultInstrumenter(): Instrumenter;
/**
* Extends the Azure SDK with support for a given instrumenter implementation.
*
* @param instrumenter - The instrumenter implementation to use.
*/
export declare function useInstrumenter(instrumenter: Instrumenter): void;
/**
* Gets the currently set instrumenter, a No-Op instrumenter by default.
*
* @returns The currently set instrumenter
*/
export declare function getInstrumenter(): Instrumenter;
//# sourceMappingURL=instrumenter.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"instrumenter.d.ts","sourceRoot":"","sources":["../../src/instrumenter.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,YAAY,EAGZ,WAAW,EACZ,MAAM,iBAAiB,CAAC;AAKzB,wBAAgB,wBAAwB,IAAI,WAAW,CAgBtD;AAED,wBAAgB,yBAAyB,IAAI,YAAY,CA4BxD;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,YAAY,EAAE,YAAY,GAAG,IAAI,CAEhE;AAED;;;;GAIG;AACH,wBAAgB,eAAe,IAAI,YAAY,CAK9C"}

View file

@ -0,0 +1,60 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
import { createTracingContext } from "./tracingContext.js";
import { state } from "./state.js";
export function createDefaultTracingSpan() {
return {
end: () => {
// noop
},
isRecording: () => false,
recordException: () => {
// noop
},
setAttribute: () => {
// noop
},
setStatus: () => {
// noop
},
};
}
export function createDefaultInstrumenter() {
return {
createRequestHeaders: () => {
return {};
},
parseTraceparentHeader: () => {
return undefined;
},
startSpan: (_name, spanOptions) => {
return {
span: createDefaultTracingSpan(),
tracingContext: createTracingContext({ parentContext: spanOptions.tracingContext }),
};
},
withContext(_context, callback, ...callbackArgs) {
return callback(...callbackArgs);
},
};
}
/**
* Extends the Azure SDK with support for a given instrumenter implementation.
*
* @param instrumenter - The instrumenter implementation to use.
*/
export function useInstrumenter(instrumenter) {
state.instrumenterImplementation = instrumenter;
}
/**
* Gets the currently set instrumenter, a No-Op instrumenter by default.
*
* @returns The currently set instrumenter
*/
export function getInstrumenter() {
if (!state.instrumenterImplementation) {
state.instrumenterImplementation = createDefaultInstrumenter();
}
return state.instrumenterImplementation;
}
//# sourceMappingURL=instrumenter.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"instrumenter.js","sourceRoot":"","sources":["../../src/instrumenter.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AASlC,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnC,MAAM,UAAU,wBAAwB;IACtC,OAAO;QACL,GAAG,EAAE,GAAG,EAAE;YACR,OAAO;QACT,CAAC;QACD,WAAW,EAAE,GAAG,EAAE,CAAC,KAAK;QACxB,eAAe,EAAE,GAAG,EAAE;YACpB,OAAO;QACT,CAAC;QACD,YAAY,EAAE,GAAG,EAAE;YACjB,OAAO;QACT,CAAC;QACD,SAAS,EAAE,GAAG,EAAE;YACd,OAAO;QACT,CAAC;KACF,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,yBAAyB;IACvC,OAAO;QACL,oBAAoB,EAAE,GAA2B,EAAE;YACjD,OAAO,EAAE,CAAC;QACZ,CAAC;QACD,sBAAsB,EAAE,GAA+B,EAAE;YACvD,OAAO,SAAS,CAAC;QACnB,CAAC;QACD,SAAS,EAAE,CACT,KAAa,EACb,WAAoC,EACmB,EAAE;YACzD,OAAO;gBACL,IAAI,EAAE,wBAAwB,EAAE;gBAChC,cAAc,EAAE,oBAAoB,CAAC,EAAE,aAAa,EAAE,WAAW,CAAC,cAAc,EAAE,CAAC;aACpF,CAAC;QACJ,CAAC;QACD,WAAW,CAIT,QAAwB,EACxB,QAAkB,EAClB,GAAG,YAA0B;YAE7B,OAAO,QAAQ,CAAC,GAAG,YAAY,CAAC,CAAC;QACnC,CAAC;KACF,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAC,YAA0B;IACxD,KAAK,CAAC,0BAA0B,GAAG,YAAY,CAAC;AAClD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,eAAe;IAC7B,IAAI,CAAC,KAAK,CAAC,0BAA0B,EAAE,CAAC;QACtC,KAAK,CAAC,0BAA0B,GAAG,yBAAyB,EAAE,CAAC;IACjE,CAAC;IACD,OAAO,KAAK,CAAC,0BAA0B,CAAC;AAC1C,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n Instrumenter,\n InstrumenterSpanOptions,\n TracingContext,\n TracingSpan,\n} from \"./interfaces.js\";\n\nimport { createTracingContext } from \"./tracingContext.js\";\nimport { state } from \"./state.js\";\n\nexport function createDefaultTracingSpan(): TracingSpan {\n return {\n end: () => {\n // noop\n },\n isRecording: () => false,\n recordException: () => {\n // noop\n },\n setAttribute: () => {\n // noop\n },\n setStatus: () => {\n // noop\n },\n };\n}\n\nexport function createDefaultInstrumenter(): Instrumenter {\n return {\n createRequestHeaders: (): Record<string, string> => {\n return {};\n },\n parseTraceparentHeader: (): TracingContext | undefined => {\n return undefined;\n },\n startSpan: (\n _name: string,\n spanOptions: InstrumenterSpanOptions,\n ): { span: TracingSpan; tracingContext: TracingContext } => {\n return {\n span: createDefaultTracingSpan(),\n tracingContext: createTracingContext({ parentContext: spanOptions.tracingContext }),\n };\n },\n withContext<\n CallbackArgs extends unknown[],\n Callback extends (...args: CallbackArgs) => ReturnType<Callback>,\n >(\n _context: TracingContext,\n callback: Callback,\n ...callbackArgs: CallbackArgs\n ): ReturnType<Callback> {\n return callback(...callbackArgs);\n },\n };\n}\n\n/**\n * Extends the Azure SDK with support for a given instrumenter implementation.\n *\n * @param instrumenter - The instrumenter implementation to use.\n */\nexport function useInstrumenter(instrumenter: Instrumenter): void {\n state.instrumenterImplementation = instrumenter;\n}\n\n/**\n * Gets the currently set instrumenter, a No-Op instrumenter by default.\n *\n * @returns The currently set instrumenter\n */\nexport function getInstrumenter(): Instrumenter {\n if (!state.instrumenterImplementation) {\n state.instrumenterImplementation = createDefaultInstrumenter();\n }\n return state.instrumenterImplementation;\n}\n"]}

View file

@ -0,0 +1,254 @@
/**
* A narrower version of TypeScript 4.5's Awaited type which Recursively
* unwraps the "awaited type", emulating the behavior of `await`.
*/
export type Resolved<T> = T extends {
then(onfulfilled: infer F): any;
} ? F extends (value: infer V) => any ? Resolved<V> : never : T;
/**
* Represents a client that can integrate with the currently configured {@link Instrumenter}.
*
* Create an instance using {@link createTracingClient}.
*/
export interface TracingClient {
/**
* Wraps a callback in a tracing span, calls the callback, and closes the span.
*
* This is the primary interface for using Tracing and will handle error recording as well as setting the status on the span.
*
* Both synchronous and asynchronous functions will be awaited in order to reflect the result of the callback on the span.
*
* Example:
*
* ```ts
* const myOperationResult = await tracingClient.withSpan("myClassName.myOperationName", options, (updatedOptions) => myOperation(updatedOptions));
* ```
* @param name - The name of the span. By convention this should be `${className}.${methodName}`.
* @param operationOptions - The original options passed to the method. The callback will receive these options with the newly created {@link TracingContext}.
* @param callback - The callback to be invoked with the updated options and newly created {@link TracingSpan}.
*/
withSpan<Options extends {
tracingOptions?: OperationTracingOptions;
}, Callback extends (updatedOptions: Options, span: Omit<TracingSpan, "end">) => ReturnType<Callback>>(name: string, operationOptions: Options, callback: Callback, spanOptions?: TracingSpanOptions): Promise<Resolved<ReturnType<Callback>>>;
/**
* Starts a given span but does not set it as the active span.
*
* You must end the span using {@link TracingSpan.end}.
*
* Most of the time you will want to use {@link withSpan} instead.
*
* @param name - The name of the span. By convention this should be `${className}.${methodName}`.
* @param operationOptions - The original operation options.
* @param spanOptions - The options to use when creating the span.
*
* @returns A {@link TracingSpan} and the updated operation options.
*/
startSpan<Options extends {
tracingOptions?: OperationTracingOptions;
}>(name: string, operationOptions?: Options, spanOptions?: TracingSpanOptions): {
span: TracingSpan;
updatedOptions: OptionsWithTracingContext<Options>;
};
/**
* Wraps a callback with an active context and calls the callback.
* Depending on the implementation, this may set the globally available active context.
*
* Useful when you want to leave the boundaries of the SDK (make a request or callback to user code) and are unable to use the {@link withSpan} API.
*
* @param context - The {@link TracingContext} to use as the active context in the scope of the callback.
* @param callback - The callback to be invoked with the given context set as the globally active context.
* @param callbackArgs - The callback arguments.
*/
withContext<CallbackArgs extends unknown[], Callback extends (...args: CallbackArgs) => ReturnType<Callback>>(context: TracingContext, callback: Callback, ...callbackArgs: CallbackArgs): ReturnType<Callback>;
/**
* Parses a traceparent header value into a {@link TracingSpanContext}.
*
* @param traceparentHeader - The traceparent header to parse.
* @returns An implementation-specific identifier for the span.
*/
parseTraceparentHeader(traceparentHeader: string): TracingContext | undefined;
/**
* Creates a set of request headers to propagate tracing information to a backend.
*
* @param tracingContext - The context containing the span to propagate.
* @returns The set of headers to add to a request.
*/
createRequestHeaders(tracingContext?: TracingContext): Record<string, string>;
}
/**
* Options that can be passed to {@link createTracingClient}
*/
export interface TracingClientOptions {
/** The value of the az.namespace tracing attribute on newly created spans. */
namespace: string;
/** The name of the package invoking this trace. */
packageName: string;
/** An optional version of the package invoking this trace. */
packageVersion?: string;
}
/** The kind of span. */
export type TracingSpanKind = "client" | "server" | "producer" | "consumer" | "internal";
/** Options used to configure the newly created span. */
export interface TracingSpanOptions {
/** The kind of span. Implementations should default this to "client". */
spanKind?: TracingSpanKind;
/** A collection of {@link TracingSpanLink} to link to this span. */
spanLinks?: TracingSpanLink[];
/** Initial set of attributes to set on a span. */
spanAttributes?: {
[key: string]: unknown;
};
}
/** A pointer from the current {@link TracingSpan} to another span in the same or a different trace. */
export interface TracingSpanLink {
/** The {@link TracingContext} containing the span context to link to. */
tracingContext: TracingContext;
/** A set of attributes on the link. */
attributes?: {
[key: string]: unknown;
};
}
/**
* Represents an implementation agnostic instrumenter.
*/
export interface Instrumenter {
/**
* Creates a new {@link TracingSpan} with the given name and options and sets it on a new context.
* @param name - The name of the span. By convention this should be `${className}.${methodName}`.
* @param spanOptions - The options to use when creating the span.
*
* @returns A {@link TracingSpan} that can be used to end the span, and the context this span has been set on.
*/
startSpan(name: string, spanOptions: InstrumenterSpanOptions): {
span: TracingSpan;
tracingContext: TracingContext;
};
/**
* Wraps a callback with an active context and calls the callback.
* Depending on the implementation, this may set the globally available active context.
*
* @param context - The {@link TracingContext} to use as the active context in the scope of the callback.
* @param callback - The callback to be invoked with the given context set as the globally active context.
* @param callbackArgs - The callback arguments.
*/
withContext<CallbackArgs extends unknown[], Callback extends (...args: CallbackArgs) => ReturnType<Callback>>(context: TracingContext, callback: Callback, ...callbackArgs: CallbackArgs): ReturnType<Callback>;
/**
* Provides an implementation-specific method to parse a {@link https://www.w3.org/TR/trace-context/#traceparent-header}
* into a {@link TracingSpanContext} which can be used to link non-parented spans together.
*/
parseTraceparentHeader(traceparentHeader: string): TracingContext | undefined;
/**
* Provides an implementation-specific method to serialize a {@link TracingSpan} to a set of headers.
* @param tracingContext - The context containing the span to serialize.
*/
createRequestHeaders(tracingContext?: TracingContext): Record<string, string>;
}
/**
* Options passed to {@link Instrumenter.startSpan} as a superset of {@link TracingSpanOptions}.
*/
export interface InstrumenterSpanOptions extends TracingSpanOptions {
/** The name of the package invoking this trace. */
packageName: string;
/** The version of the package invoking this trace. */
packageVersion?: string;
/** The current tracing context. Defaults to an implementation-specific "active" context. */
tracingContext?: TracingContext;
}
/**
* Status representing a successful operation that can be sent to {@link TracingSpan.setStatus}
*/
export type SpanStatusSuccess = {
status: "success";
};
/**
* Status representing an error that can be sent to {@link TracingSpan.setStatus}
*/
export type SpanStatusError = {
status: "error";
error?: Error | string;
};
/**
* Represents the statuses that can be passed to {@link TracingSpan.setStatus}.
*
* By default, all spans will be created with status "unset".
*/
export type SpanStatus = SpanStatusSuccess | SpanStatusError;
/**
* Represents an implementation agnostic tracing span.
*/
export interface TracingSpan {
/**
* Sets the status of the span. When an error is provided, it will be recorded on the span as well.
*
* @param status - The {@link SpanStatus} to set on the span.
*/
setStatus(status: SpanStatus): void;
/**
* Sets a given attribute on a span.
*
* @param name - The attribute's name.
* @param value - The attribute's value to set. May be any non-nullish value.
*/
setAttribute(name: string, value: unknown): void;
/**
* Ends the span.
*/
end(): void;
/**
* Records an exception on a {@link TracingSpan} without modifying its status.
*
* When recording an unhandled exception that should fail the span, please use {@link TracingSpan.setStatus} instead.
*
* @param exception - The exception to record on the span.
*
*/
recordException(exception: Error | string): void;
/**
* Returns true if this {@link TracingSpan} is recording information.
*
* Depending on the span implementation, this may return false if the span is not being sampled.
*/
isRecording(): boolean;
}
/** An immutable context bag of tracing values for the current operation. */
export interface TracingContext {
/**
* Sets a given object on a context.
* @param key - The key of the given context value.
* @param value - The value to set on the context.
*
* @returns - A new context with the given value set.
*/
setValue(key: symbol, value: unknown): TracingContext;
/**
* Gets an object from the context if it exists.
* @param key - The key of the given context value.
*
* @returns - The value of the given context value if it exists, otherwise `undefined`.
*/
getValue(key: symbol): unknown;
/**
* Deletes an object from the context if it exists.
* @param key - The key of the given context value to delete.
*/
deleteValue(key: symbol): TracingContext;
}
/**
* Tracing options to set on an operation.
*/
export interface OperationTracingOptions {
/** The context to use for created Tracing Spans. */
tracingContext?: TracingContext;
}
/**
* A utility type for when we know a TracingContext has been set
* as part of an operation's options.
*/
export type OptionsWithTracingContext<Options extends {
tracingOptions?: OperationTracingOptions;
}> = Options & {
tracingOptions: {
tracingContext: TracingContext;
};
};
//# sourceMappingURL=interfaces.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../src/interfaces.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,MAAM,MAAM,QAAQ,CAAC,CAAC,IAAI,CAAC,SAAS;IAAE,IAAI,CAAC,WAAW,EAAE,MAAM,CAAC,GAAG,GAAG,CAAA;CAAE,GACnE,CAAC,SAAS,CAAC,KAAK,EAAE,MAAM,CAAC,KAAK,GAAG,GAC/B,QAAQ,CAAC,CAAC,CAAC,GACX,KAAK,GACP,CAAC,CAAC;AAEN;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC5B;;;;;;;;;;;;;;;OAeG;IACH,QAAQ,CACN,OAAO,SAAS;QAAE,cAAc,CAAC,EAA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;IACpD,cAAc,CAAC,EAAE,cAAc,CAAC;CACjC;AAED;;;GAGG;AACH,MAAM,MAAM,yBAAyB,CACnC,OAAO,SAAS;IAAE,cAAc,CAAC,EAAE,uBAAuB,CAAA;CAAE,IAC1D,OAAO,GAAG;IACZ,cAAc,EAAE;QACd,cAAc,EAAE,cAAc,CAAC;KAChC,CAAC;CACH,CAAC"}

View file

@ -0,0 +1,4 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
export {};
//# sourceMappingURL=interfaces.js.map

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,3 @@
{
"type": "module"
}

8
node_modules/@azure/core-tracing/dist/esm/state.d.ts generated vendored Normal file
View file

@ -0,0 +1,8 @@
import { Instrumenter } from "./interfaces.js";
/**
* Defines the shared state between CJS and ESM by re-exporting the CJS state.
*/
export declare const state: {
instrumenterImplementation: Instrumenter | undefined;
};
//# sourceMappingURL=state.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../src/state.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAK/C;;GAEG;AACH,eAAO,MAAM,KAAK;gCACY,YAAY,GAAG,SAAS;CACrD,CAAC"}

10
node_modules/@azure/core-tracing/dist/esm/state.js generated vendored Normal file
View file

@ -0,0 +1,10 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
// @ts-expect-error The recommended approach to sharing module state between ESM and CJS.
// See https://github.com/isaacs/tshy/blob/main/README.md#module-local-state for additional information.
import { state as cjsState } from "../commonjs/state.js";
/**
* Defines the shared state between CJS and ESM by re-exporting the CJS state.
*/
export const state = cjsState;
//# sourceMappingURL=state.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"state.js","sourceRoot":"","sources":["../../src/state.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,yFAAyF;AACzF,wGAAwG;AACxG,OAAO,EAAE,KAAK,IAAI,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAEzD;;GAEG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,QAEpB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { Instrumenter } from \"./interfaces.js\";\n// @ts-expect-error The recommended approach to sharing module state between ESM and CJS.\n// See https://github.com/isaacs/tshy/blob/main/README.md#module-local-state for additional information.\nimport { state as cjsState } from \"../commonjs/state.js\";\n\n/**\n * Defines the shared state between CJS and ESM by re-exporting the CJS state.\n */\nexport const state = cjsState as {\n instrumenterImplementation: Instrumenter | undefined;\n};\n"]}

View file

@ -0,0 +1,9 @@
import { TracingClient, TracingClientOptions } from "./interfaces.js";
/**
* Creates a new tracing client.
*
* @param options - Options used to configure the tracing client.
* @returns - An instance of {@link TracingClient}.
*/
export declare function createTracingClient(options: TracingClientOptions): TracingClient;
//# sourceMappingURL=tracingClient.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"tracingClient.d.ts","sourceRoot":"","sources":["../../src/tracingClient.ts"],"names":[],"mappings":"AAGA,OAAO,EAIL,aAAa,EACb,oBAAoB,EAIrB,MAAM,iBAAiB,CAAC;AAIzB;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,oBAAoB,GAAG,aAAa,CAkGhF"}

View file

@ -0,0 +1,74 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
import { getInstrumenter } from "./instrumenter.js";
import { knownContextKeys } from "./tracingContext.js";
/**
* Creates a new tracing client.
*
* @param options - Options used to configure the tracing client.
* @returns - An instance of {@link TracingClient}.
*/
export function createTracingClient(options) {
const { namespace, packageName, packageVersion } = options;
function startSpan(name, operationOptions, spanOptions) {
var _a;
const startSpanResult = getInstrumenter().startSpan(name, Object.assign(Object.assign({}, spanOptions), { packageName: packageName, packageVersion: packageVersion, tracingContext: (_a = operationOptions === null || operationOptions === void 0 ? void 0 : operationOptions.tracingOptions) === null || _a === void 0 ? void 0 : _a.tracingContext }));
let tracingContext = startSpanResult.tracingContext;
const span = startSpanResult.span;
if (!tracingContext.getValue(knownContextKeys.namespace)) {
tracingContext = tracingContext.setValue(knownContextKeys.namespace, namespace);
}
span.setAttribute("az.namespace", tracingContext.getValue(knownContextKeys.namespace));
const updatedOptions = Object.assign({}, operationOptions, {
tracingOptions: Object.assign(Object.assign({}, operationOptions === null || operationOptions === void 0 ? void 0 : operationOptions.tracingOptions), { tracingContext }),
});
return {
span,
updatedOptions,
};
}
async function withSpan(name, operationOptions, callback, spanOptions) {
const { span, updatedOptions } = startSpan(name, operationOptions, spanOptions);
try {
const result = await withContext(updatedOptions.tracingOptions.tracingContext, () => Promise.resolve(callback(updatedOptions, span)));
span.setStatus({ status: "success" });
return result;
}
catch (err) {
span.setStatus({ status: "error", error: err });
throw err;
}
finally {
span.end();
}
}
function withContext(context, callback, ...callbackArgs) {
return getInstrumenter().withContext(context, callback, ...callbackArgs);
}
/**
* Parses a traceparent header value into a span identifier.
*
* @param traceparentHeader - The traceparent header to parse.
* @returns An implementation-specific identifier for the span.
*/
function parseTraceparentHeader(traceparentHeader) {
return getInstrumenter().parseTraceparentHeader(traceparentHeader);
}
/**
* Creates a set of request headers to propagate tracing information to a backend.
*
* @param tracingContext - The context containing the span to serialize.
* @returns The set of headers to add to a request.
*/
function createRequestHeaders(tracingContext) {
return getInstrumenter().createRequestHeaders(tracingContext);
}
return {
startSpan,
withSpan,
withContext,
parseTraceparentHeader,
createRequestHeaders,
};
}
//# sourceMappingURL=tracingClient.js.map

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,34 @@
import { TracingContext, TracingSpan } from "./interfaces.js";
/** @internal */
export declare const knownContextKeys: {
span: symbol;
namespace: symbol;
};
/**
* Creates a new {@link TracingContext} with the given options.
* @param options - A set of known keys that may be set on the context.
* @returns A new {@link TracingContext} with the given options.
*
* @internal
*/
export declare function createTracingContext(options?: CreateTracingContextOptions): TracingContext;
/** @internal */
export declare class TracingContextImpl implements TracingContext {
private _contextMap;
constructor(initialContext?: TracingContext);
setValue(key: symbol, value: unknown): TracingContext;
getValue(key: symbol): unknown;
deleteValue(key: symbol): TracingContext;
}
/**
* Represents a set of items that can be set when creating a new {@link TracingContext}.
*/
export interface CreateTracingContextOptions {
/** The {@link parentContext} - the newly created context will contain all the values of the parent context unless overridden. */
parentContext?: TracingContext;
/** An initial span to set on the context. */
span?: TracingSpan;
/** The namespace to set on any child spans. */
namespace?: string;
}
//# sourceMappingURL=tracingContext.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"tracingContext.d.ts","sourceRoot":"","sources":["../../src/tracingContext.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9D,gBAAgB;AAChB,eAAO,MAAM,gBAAgB;;;CAG5B,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,GAAE,2BAAgC,GAAG,cAAc,CAS9F;AAED,gBAAgB;AAChB,qBAAa,kBAAmB,YAAW,cAAc;IACvD,OAAO,CAAC,WAAW,CAAuB;gBAC9B,cAAc,CAAC,EAAE,cAAc;IAO3C,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,cAAc;IAMrD,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAI9B,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc;CAKzC;AAED;;GAEG;AACH,MAAM,WAAW,2BAA2B;IAC1C,iIAAiI;IACjI,aAAa,CAAC,EAAE,cAAc,CAAC;IAC/B,6CAA6C;IAC7C,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,+CAA+C;IAC/C,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB"}

View file

@ -0,0 +1,47 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
/** @internal */
export const knownContextKeys = {
span: Symbol.for("@azure/core-tracing span"),
namespace: Symbol.for("@azure/core-tracing namespace"),
};
/**
* Creates a new {@link TracingContext} with the given options.
* @param options - A set of known keys that may be set on the context.
* @returns A new {@link TracingContext} with the given options.
*
* @internal
*/
export function createTracingContext(options = {}) {
let context = new TracingContextImpl(options.parentContext);
if (options.span) {
context = context.setValue(knownContextKeys.span, options.span);
}
if (options.namespace) {
context = context.setValue(knownContextKeys.namespace, options.namespace);
}
return context;
}
/** @internal */
export class TracingContextImpl {
constructor(initialContext) {
this._contextMap =
initialContext instanceof TracingContextImpl
? new Map(initialContext._contextMap)
: new Map();
}
setValue(key, value) {
const newContext = new TracingContextImpl(this);
newContext._contextMap.set(key, value);
return newContext;
}
getValue(key) {
return this._contextMap.get(key);
}
deleteValue(key) {
const newContext = new TracingContextImpl(this);
newContext._contextMap.delete(key);
return newContext;
}
}
//# sourceMappingURL=tracingContext.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"tracingContext.js","sourceRoot":"","sources":["../../src/tracingContext.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAIlC,gBAAgB;AAChB,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,IAAI,EAAE,MAAM,CAAC,GAAG,CAAC,0BAA0B,CAAC;IAC5C,SAAS,EAAE,MAAM,CAAC,GAAG,CAAC,+BAA+B,CAAC;CACvD,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,UAAU,oBAAoB,CAAC,UAAuC,EAAE;IAC5E,IAAI,OAAO,GAAmB,IAAI,kBAAkB,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;IAC5E,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;QACjB,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IAClE,CAAC;IACD,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC;QACtB,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAC,SAAS,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;IAC5E,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,gBAAgB;AAChB,MAAM,OAAO,kBAAkB;IAE7B,YAAY,cAA+B;QACzC,IAAI,CAAC,WAAW;YACd,cAAc,YAAY,kBAAkB;gBAC1C,CAAC,CAAC,IAAI,GAAG,CAAkB,cAAc,CAAC,WAAW,CAAC;gBACtD,CAAC,CAAC,IAAI,GAAG,EAAE,CAAC;IAClB,CAAC;IAED,QAAQ,CAAC,GAAW,EAAE,KAAc;QAClC,MAAM,UAAU,GAAG,IAAI,kBAAkB,CAAC,IAAI,CAAC,CAAC;QAChD,UAAU,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QACvC,OAAO,UAAU,CAAC;IACpB,CAAC;IAED,QAAQ,CAAC,GAAW;QAClB,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACnC,CAAC;IAED,WAAW,CAAC,GAAW;QACrB,MAAM,UAAU,GAAG,IAAI,kBAAkB,CAAC,IAAI,CAAC,CAAC;QAChD,UAAU,CAAC,WAAW,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACnC,OAAO,UAAU,CAAC;IACpB,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { TracingContext, TracingSpan } from \"./interfaces.js\";\n\n/** @internal */\nexport const knownContextKeys = {\n span: Symbol.for(\"@azure/core-tracing span\"),\n namespace: Symbol.for(\"@azure/core-tracing namespace\"),\n};\n\n/**\n * Creates a new {@link TracingContext} with the given options.\n * @param options - A set of known keys that may be set on the context.\n * @returns A new {@link TracingContext} with the given options.\n *\n * @internal\n */\nexport function createTracingContext(options: CreateTracingContextOptions = {}): TracingContext {\n let context: TracingContext = new TracingContextImpl(options.parentContext);\n if (options.span) {\n context = context.setValue(knownContextKeys.span, options.span);\n }\n if (options.namespace) {\n context = context.setValue(knownContextKeys.namespace, options.namespace);\n }\n return context;\n}\n\n/** @internal */\nexport class TracingContextImpl implements TracingContext {\n private _contextMap: Map<symbol, unknown>;\n constructor(initialContext?: TracingContext) {\n this._contextMap =\n initialContext instanceof TracingContextImpl\n ? new Map<symbol, unknown>(initialContext._contextMap)\n : new Map();\n }\n\n setValue(key: symbol, value: unknown): TracingContext {\n const newContext = new TracingContextImpl(this);\n newContext._contextMap.set(key, value);\n return newContext;\n }\n\n getValue(key: symbol): unknown {\n return this._contextMap.get(key);\n }\n\n deleteValue(key: symbol): TracingContext {\n const newContext = new TracingContextImpl(this);\n newContext._contextMap.delete(key);\n return newContext;\n }\n}\n\n/**\n * Represents a set of items that can be set when creating a new {@link TracingContext}.\n */\nexport interface CreateTracingContextOptions {\n /** The {@link parentContext} - the newly created context will contain all the values of the parent context unless overridden. */\n parentContext?: TracingContext;\n /** An initial span to set on the context. */\n span?: TracingSpan;\n /** The namespace to set on any child spans. */\n namespace?: string;\n}\n"]}

View file

@ -1,219 +0,0 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var api = require('@opentelemetry/api');
// Copyright (c) Microsoft Corporation.
(function (SpanKind) {
/** Default value. Indicates that the span is used internally. */
SpanKind[SpanKind["INTERNAL"] = 0] = "INTERNAL";
/**
* Indicates that the span covers server-side handling of an RPC or other
* remote request.
*/
SpanKind[SpanKind["SERVER"] = 1] = "SERVER";
/**
* Indicates that the span covers the client-side wrapper around an RPC or
* other remote request.
*/
SpanKind[SpanKind["CLIENT"] = 2] = "CLIENT";
/**
* Indicates that the span describes producer sending a message to a
* broker. Unlike client and server, there is no direct critical path latency
* relationship between producer and consumer spans.
*/
SpanKind[SpanKind["PRODUCER"] = 3] = "PRODUCER";
/**
* Indicates that the span describes consumer receiving a message from a
* broker. Unlike client and server, there is no direct critical path latency
* relationship between producer and consumer spans.
*/
SpanKind[SpanKind["CONSUMER"] = 4] = "CONSUMER";
})(exports.SpanKind || (exports.SpanKind = {}));
/**
* Return the span if one exists
*
* @param context - context to get span from
*/
function getSpan(context) {
return api.trace.getSpan(context);
}
/**
* Set the span on a context
*
* @param context - context to use as parent
* @param span - span to set active
*/
function setSpan(context, span) {
return api.trace.setSpan(context, span);
}
/**
* Wrap span context in a NoopSpan and set as span in a new
* context
*
* @param context - context to set active span on
* @param spanContext - span context to be wrapped
*/
function setSpanContext(context, spanContext) {
return api.trace.setSpanContext(context, spanContext);
}
/**
* Get the span context of the span if it exists.
*
* @param context - context to get values from
*/
function getSpanContext(context) {
return api.trace.getSpanContext(context);
}
/**
* Returns true of the given {@link SpanContext} is valid.
* A valid {@link SpanContext} is one which has a valid trace ID and span ID as per the spec.
*
* @param context - the {@link SpanContext} to validate.
*
* @returns true if the {@link SpanContext} is valid, false otherwise.
*/
function isSpanContextValid(context) {
return api.trace.isSpanContextValid(context);
}
function getTracer(name, version) {
return api.trace.getTracer(name || "azure/core-tracing", version);
}
/** Entrypoint for context API */
const context = api.context;
(function (SpanStatusCode) {
/**
* The default status.
*/
SpanStatusCode[SpanStatusCode["UNSET"] = 0] = "UNSET";
/**
* The operation has been validated by an Application developer or
* Operator to have completed successfully.
*/
SpanStatusCode[SpanStatusCode["OK"] = 1] = "OK";
/**
* The operation contains an error.
*/
SpanStatusCode[SpanStatusCode["ERROR"] = 2] = "ERROR";
})(exports.SpanStatusCode || (exports.SpanStatusCode = {}));
// Copyright (c) Microsoft Corporation.
function isTracingDisabled() {
var _a;
if (typeof process === "undefined") {
// not supported in browser for now without polyfills
return false;
}
const azureTracingDisabledValue = (_a = process.env.AZURE_TRACING_DISABLED) === null || _a === void 0 ? void 0 : _a.toLowerCase();
if (azureTracingDisabledValue === "false" || azureTracingDisabledValue === "0") {
return false;
}
return Boolean(azureTracingDisabledValue);
}
/**
* Creates a function that can be used to create spans using the global tracer.
*
* Usage:
*
* ```typescript
* // once
* const createSpan = createSpanFunction({ packagePrefix: "Azure.Data.AppConfiguration", namespace: "Microsoft.AppConfiguration" });
*
* // in each operation
* const span = createSpan("deleteConfigurationSetting", operationOptions);
* // code...
* span.end();
* ```
*
* @hidden
* @param args - allows configuration of the prefix for each span as well as the az.namespace field.
*/
function createSpanFunction(args) {
return function (operationName, operationOptions) {
const tracer = getTracer();
const tracingOptions = (operationOptions === null || operationOptions === void 0 ? void 0 : operationOptions.tracingOptions) || {};
const spanOptions = Object.assign({ kind: exports.SpanKind.INTERNAL }, tracingOptions.spanOptions);
const spanName = args.packagePrefix ? `${args.packagePrefix}.${operationName}` : operationName;
let span;
if (isTracingDisabled()) {
span = api.trace.wrapSpanContext(api.INVALID_SPAN_CONTEXT);
}
else {
span = tracer.startSpan(spanName, spanOptions, tracingOptions.tracingContext);
}
if (args.namespace) {
span.setAttribute("az.namespace", args.namespace);
}
let newSpanOptions = tracingOptions.spanOptions || {};
if (span.isRecording() && args.namespace) {
newSpanOptions = Object.assign(Object.assign({}, tracingOptions.spanOptions), { attributes: Object.assign(Object.assign({}, spanOptions.attributes), { "az.namespace": args.namespace }) });
}
const newTracingOptions = Object.assign(Object.assign({}, tracingOptions), { spanOptions: newSpanOptions, tracingContext: setSpan(tracingOptions.tracingContext || context.active(), span) });
const newOperationOptions = Object.assign(Object.assign({}, operationOptions), { tracingOptions: newTracingOptions });
return {
span,
updatedOptions: newOperationOptions
};
};
}
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
const VERSION = "00";
/**
* Generates a `SpanContext` given a `traceparent` header value.
* @param traceParent - Serialized span context data as a `traceparent` header value.
* @returns The `SpanContext` generated from the `traceparent` value.
*/
function extractSpanContextFromTraceParentHeader(traceParentHeader) {
const parts = traceParentHeader.split("-");
if (parts.length !== 4) {
return;
}
const [version, traceId, spanId, traceOptions] = parts;
if (version !== VERSION) {
return;
}
const traceFlags = parseInt(traceOptions, 16);
const spanContext = {
spanId,
traceId,
traceFlags
};
return spanContext;
}
/**
* Generates a `traceparent` value given a span context.
* @param spanContext - Contains context for a specific span.
* @returns The `spanContext` represented as a `traceparent` value.
*/
function getTraceParentHeader(spanContext) {
const missingFields = [];
if (!spanContext.traceId) {
missingFields.push("traceId");
}
if (!spanContext.spanId) {
missingFields.push("spanId");
}
if (missingFields.length) {
return;
}
const flags = spanContext.traceFlags || 0 /* NONE */;
const hexFlags = flags.toString(16);
const traceFlags = hexFlags.length === 1 ? `0${hexFlags}` : hexFlags;
// https://www.w3.org/TR/trace-context/#traceparent-header-field-values
return `${VERSION}-${spanContext.traceId}-${spanContext.spanId}-${traceFlags}`;
}
exports.context = context;
exports.createSpanFunction = createSpanFunction;
exports.extractSpanContextFromTraceParentHeader = extractSpanContextFromTraceParentHeader;
exports.getSpan = getSpan;
exports.getSpanContext = getSpanContext;
exports.getTraceParentHeader = getTraceParentHeader;
exports.getTracer = getTracer;
exports.isSpanContextValid = isSpanContextValid;
exports.setSpan = setSpan;
exports.setSpanContext = setSpanContext;
//# sourceMappingURL=index.js.map

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,4 @@
export { Instrumenter, InstrumenterSpanOptions, OperationTracingOptions, OptionsWithTracingContext, Resolved, SpanStatus, SpanStatusError, SpanStatusSuccess, TracingClient, TracingClientOptions, TracingContext, TracingSpan, TracingSpanKind, TracingSpanLink, TracingSpanOptions, } from "./interfaces.js";
export { useInstrumenter } from "./instrumenter.js";
export { createTracingClient } from "./tracingClient.js";
//# sourceMappingURL=index.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,YAAY,EACZ,uBAAuB,EACvB,uBAAuB,EACvB,yBAAyB,EACzB,QAAQ,EACR,UAAU,EACV,eAAe,EACf,iBAAiB,EACjB,aAAa,EACb,oBAAoB,EACpB,cAAc,EACd,WAAW,EACX,eAAe,EACf,eAAe,EACf,kBAAkB,GACnB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC"}

View file

@ -0,0 +1,5 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
export { useInstrumenter } from "./instrumenter.js";
export { createTracingClient } from "./tracingClient.js";
//# sourceMappingURL=index.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAmBlC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nexport {\n Instrumenter,\n InstrumenterSpanOptions,\n OperationTracingOptions,\n OptionsWithTracingContext,\n Resolved,\n SpanStatus,\n SpanStatusError,\n SpanStatusSuccess,\n TracingClient,\n TracingClientOptions,\n TracingContext,\n TracingSpan,\n TracingSpanKind,\n TracingSpanLink,\n TracingSpanOptions,\n} from \"./interfaces.js\";\nexport { useInstrumenter } from \"./instrumenter.js\";\nexport { createTracingClient } from \"./tracingClient.js\";\n"]}

View file

@ -0,0 +1,16 @@
import { Instrumenter, TracingSpan } from "./interfaces.js";
export declare function createDefaultTracingSpan(): TracingSpan;
export declare function createDefaultInstrumenter(): Instrumenter;
/**
* Extends the Azure SDK with support for a given instrumenter implementation.
*
* @param instrumenter - The instrumenter implementation to use.
*/
export declare function useInstrumenter(instrumenter: Instrumenter): void;
/**
* Gets the currently set instrumenter, a No-Op instrumenter by default.
*
* @returns The currently set instrumenter
*/
export declare function getInstrumenter(): Instrumenter;
//# sourceMappingURL=instrumenter.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"instrumenter.d.ts","sourceRoot":"","sources":["../../src/instrumenter.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,YAAY,EAGZ,WAAW,EACZ,MAAM,iBAAiB,CAAC;AAKzB,wBAAgB,wBAAwB,IAAI,WAAW,CAgBtD;AAED,wBAAgB,yBAAyB,IAAI,YAAY,CA4BxD;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,YAAY,EAAE,YAAY,GAAG,IAAI,CAEhE;AAED;;;;GAIG;AACH,wBAAgB,eAAe,IAAI,YAAY,CAK9C"}

View file

@ -0,0 +1,60 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
import { createTracingContext } from "./tracingContext.js";
import { state } from "./state.js";
export function createDefaultTracingSpan() {
return {
end: () => {
// noop
},
isRecording: () => false,
recordException: () => {
// noop
},
setAttribute: () => {
// noop
},
setStatus: () => {
// noop
},
};
}
export function createDefaultInstrumenter() {
return {
createRequestHeaders: () => {
return {};
},
parseTraceparentHeader: () => {
return undefined;
},
startSpan: (_name, spanOptions) => {
return {
span: createDefaultTracingSpan(),
tracingContext: createTracingContext({ parentContext: spanOptions.tracingContext }),
};
},
withContext(_context, callback, ...callbackArgs) {
return callback(...callbackArgs);
},
};
}
/**
* Extends the Azure SDK with support for a given instrumenter implementation.
*
* @param instrumenter - The instrumenter implementation to use.
*/
export function useInstrumenter(instrumenter) {
state.instrumenterImplementation = instrumenter;
}
/**
* Gets the currently set instrumenter, a No-Op instrumenter by default.
*
* @returns The currently set instrumenter
*/
export function getInstrumenter() {
if (!state.instrumenterImplementation) {
state.instrumenterImplementation = createDefaultInstrumenter();
}
return state.instrumenterImplementation;
}
//# sourceMappingURL=instrumenter.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"instrumenter.js","sourceRoot":"","sources":["../../src/instrumenter.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AASlC,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnC,MAAM,UAAU,wBAAwB;IACtC,OAAO;QACL,GAAG,EAAE,GAAG,EAAE;YACR,OAAO;QACT,CAAC;QACD,WAAW,EAAE,GAAG,EAAE,CAAC,KAAK;QACxB,eAAe,EAAE,GAAG,EAAE;YACpB,OAAO;QACT,CAAC;QACD,YAAY,EAAE,GAAG,EAAE;YACjB,OAAO;QACT,CAAC;QACD,SAAS,EAAE,GAAG,EAAE;YACd,OAAO;QACT,CAAC;KACF,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,yBAAyB;IACvC,OAAO;QACL,oBAAoB,EAAE,GAA2B,EAAE;YACjD,OAAO,EAAE,CAAC;QACZ,CAAC;QACD,sBAAsB,EAAE,GAA+B,EAAE;YACvD,OAAO,SAAS,CAAC;QACnB,CAAC;QACD,SAAS,EAAE,CACT,KAAa,EACb,WAAoC,EACmB,EAAE;YACzD,OAAO;gBACL,IAAI,EAAE,wBAAwB,EAAE;gBAChC,cAAc,EAAE,oBAAoB,CAAC,EAAE,aAAa,EAAE,WAAW,CAAC,cAAc,EAAE,CAAC;aACpF,CAAC;QACJ,CAAC;QACD,WAAW,CAIT,QAAwB,EACxB,QAAkB,EAClB,GAAG,YAA0B;YAE7B,OAAO,QAAQ,CAAC,GAAG,YAAY,CAAC,CAAC;QACnC,CAAC;KACF,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAC,YAA0B;IACxD,KAAK,CAAC,0BAA0B,GAAG,YAAY,CAAC;AAClD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,eAAe;IAC7B,IAAI,CAAC,KAAK,CAAC,0BAA0B,EAAE,CAAC;QACtC,KAAK,CAAC,0BAA0B,GAAG,yBAAyB,EAAE,CAAC;IACjE,CAAC;IACD,OAAO,KAAK,CAAC,0BAA0B,CAAC;AAC1C,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n Instrumenter,\n InstrumenterSpanOptions,\n TracingContext,\n TracingSpan,\n} from \"./interfaces.js\";\n\nimport { createTracingContext } from \"./tracingContext.js\";\nimport { state } from \"./state.js\";\n\nexport function createDefaultTracingSpan(): TracingSpan {\n return {\n end: () => {\n // noop\n },\n isRecording: () => false,\n recordException: () => {\n // noop\n },\n setAttribute: () => {\n // noop\n },\n setStatus: () => {\n // noop\n },\n };\n}\n\nexport function createDefaultInstrumenter(): Instrumenter {\n return {\n createRequestHeaders: (): Record<string, string> => {\n return {};\n },\n parseTraceparentHeader: (): TracingContext | undefined => {\n return undefined;\n },\n startSpan: (\n _name: string,\n spanOptions: InstrumenterSpanOptions,\n ): { span: TracingSpan; tracingContext: TracingContext } => {\n return {\n span: createDefaultTracingSpan(),\n tracingContext: createTracingContext({ parentContext: spanOptions.tracingContext }),\n };\n },\n withContext<\n CallbackArgs extends unknown[],\n Callback extends (...args: CallbackArgs) => ReturnType<Callback>,\n >(\n _context: TracingContext,\n callback: Callback,\n ...callbackArgs: CallbackArgs\n ): ReturnType<Callback> {\n return callback(...callbackArgs);\n },\n };\n}\n\n/**\n * Extends the Azure SDK with support for a given instrumenter implementation.\n *\n * @param instrumenter - The instrumenter implementation to use.\n */\nexport function useInstrumenter(instrumenter: Instrumenter): void {\n state.instrumenterImplementation = instrumenter;\n}\n\n/**\n * Gets the currently set instrumenter, a No-Op instrumenter by default.\n *\n * @returns The currently set instrumenter\n */\nexport function getInstrumenter(): Instrumenter {\n if (!state.instrumenterImplementation) {\n state.instrumenterImplementation = createDefaultInstrumenter();\n }\n return state.instrumenterImplementation;\n}\n"]}

View file

@ -0,0 +1,254 @@
/**
* A narrower version of TypeScript 4.5's Awaited type which Recursively
* unwraps the "awaited type", emulating the behavior of `await`.
*/
export type Resolved<T> = T extends {
then(onfulfilled: infer F): any;
} ? F extends (value: infer V) => any ? Resolved<V> : never : T;
/**
* Represents a client that can integrate with the currently configured {@link Instrumenter}.
*
* Create an instance using {@link createTracingClient}.
*/
export interface TracingClient {
/**
* Wraps a callback in a tracing span, calls the callback, and closes the span.
*
* This is the primary interface for using Tracing and will handle error recording as well as setting the status on the span.
*
* Both synchronous and asynchronous functions will be awaited in order to reflect the result of the callback on the span.
*
* Example:
*
* ```ts
* const myOperationResult = await tracingClient.withSpan("myClassName.myOperationName", options, (updatedOptions) => myOperation(updatedOptions));
* ```
* @param name - The name of the span. By convention this should be `${className}.${methodName}`.
* @param operationOptions - The original options passed to the method. The callback will receive these options with the newly created {@link TracingContext}.
* @param callback - The callback to be invoked with the updated options and newly created {@link TracingSpan}.
*/
withSpan<Options extends {
tracingOptions?: OperationTracingOptions;
}, Callback extends (updatedOptions: Options, span: Omit<TracingSpan, "end">) => ReturnType<Callback>>(name: string, operationOptions: Options, callback: Callback, spanOptions?: TracingSpanOptions): Promise<Resolved<ReturnType<Callback>>>;
/**
* Starts a given span but does not set it as the active span.
*
* You must end the span using {@link TracingSpan.end}.
*
* Most of the time you will want to use {@link withSpan} instead.
*
* @param name - The name of the span. By convention this should be `${className}.${methodName}`.
* @param operationOptions - The original operation options.
* @param spanOptions - The options to use when creating the span.
*
* @returns A {@link TracingSpan} and the updated operation options.
*/
startSpan<Options extends {
tracingOptions?: OperationTracingOptions;
}>(name: string, operationOptions?: Options, spanOptions?: TracingSpanOptions): {
span: TracingSpan;
updatedOptions: OptionsWithTracingContext<Options>;
};
/**
* Wraps a callback with an active context and calls the callback.
* Depending on the implementation, this may set the globally available active context.
*
* Useful when you want to leave the boundaries of the SDK (make a request or callback to user code) and are unable to use the {@link withSpan} API.
*
* @param context - The {@link TracingContext} to use as the active context in the scope of the callback.
* @param callback - The callback to be invoked with the given context set as the globally active context.
* @param callbackArgs - The callback arguments.
*/
withContext<CallbackArgs extends unknown[], Callback extends (...args: CallbackArgs) => ReturnType<Callback>>(context: TracingContext, callback: Callback, ...callbackArgs: CallbackArgs): ReturnType<Callback>;
/**
* Parses a traceparent header value into a {@link TracingSpanContext}.
*
* @param traceparentHeader - The traceparent header to parse.
* @returns An implementation-specific identifier for the span.
*/
parseTraceparentHeader(traceparentHeader: string): TracingContext | undefined;
/**
* Creates a set of request headers to propagate tracing information to a backend.
*
* @param tracingContext - The context containing the span to propagate.
* @returns The set of headers to add to a request.
*/
createRequestHeaders(tracingContext?: TracingContext): Record<string, string>;
}
/**
* Options that can be passed to {@link createTracingClient}
*/
export interface TracingClientOptions {
/** The value of the az.namespace tracing attribute on newly created spans. */
namespace: string;
/** The name of the package invoking this trace. */
packageName: string;
/** An optional version of the package invoking this trace. */
packageVersion?: string;
}
/** The kind of span. */
export type TracingSpanKind = "client" | "server" | "producer" | "consumer" | "internal";
/** Options used to configure the newly created span. */
export interface TracingSpanOptions {
/** The kind of span. Implementations should default this to "client". */
spanKind?: TracingSpanKind;
/** A collection of {@link TracingSpanLink} to link to this span. */
spanLinks?: TracingSpanLink[];
/** Initial set of attributes to set on a span. */
spanAttributes?: {
[key: string]: unknown;
};
}
/** A pointer from the current {@link TracingSpan} to another span in the same or a different trace. */
export interface TracingSpanLink {
/** The {@link TracingContext} containing the span context to link to. */
tracingContext: TracingContext;
/** A set of attributes on the link. */
attributes?: {
[key: string]: unknown;
};
}
/**
* Represents an implementation agnostic instrumenter.
*/
export interface Instrumenter {
/**
* Creates a new {@link TracingSpan} with the given name and options and sets it on a new context.
* @param name - The name of the span. By convention this should be `${className}.${methodName}`.
* @param spanOptions - The options to use when creating the span.
*
* @returns A {@link TracingSpan} that can be used to end the span, and the context this span has been set on.
*/
startSpan(name: string, spanOptions: InstrumenterSpanOptions): {
span: TracingSpan;
tracingContext: TracingContext;
};
/**
* Wraps a callback with an active context and calls the callback.
* Depending on the implementation, this may set the globally available active context.
*
* @param context - The {@link TracingContext} to use as the active context in the scope of the callback.
* @param callback - The callback to be invoked with the given context set as the globally active context.
* @param callbackArgs - The callback arguments.
*/
withContext<CallbackArgs extends unknown[], Callback extends (...args: CallbackArgs) => ReturnType<Callback>>(context: TracingContext, callback: Callback, ...callbackArgs: CallbackArgs): ReturnType<Callback>;
/**
* Provides an implementation-specific method to parse a {@link https://www.w3.org/TR/trace-context/#traceparent-header}
* into a {@link TracingSpanContext} which can be used to link non-parented spans together.
*/
parseTraceparentHeader(traceparentHeader: string): TracingContext | undefined;
/**
* Provides an implementation-specific method to serialize a {@link TracingSpan} to a set of headers.
* @param tracingContext - The context containing the span to serialize.
*/
createRequestHeaders(tracingContext?: TracingContext): Record<string, string>;
}
/**
* Options passed to {@link Instrumenter.startSpan} as a superset of {@link TracingSpanOptions}.
*/
export interface InstrumenterSpanOptions extends TracingSpanOptions {
/** The name of the package invoking this trace. */
packageName: string;
/** The version of the package invoking this trace. */
packageVersion?: string;
/** The current tracing context. Defaults to an implementation-specific "active" context. */
tracingContext?: TracingContext;
}
/**
* Status representing a successful operation that can be sent to {@link TracingSpan.setStatus}
*/
export type SpanStatusSuccess = {
status: "success";
};
/**
* Status representing an error that can be sent to {@link TracingSpan.setStatus}
*/
export type SpanStatusError = {
status: "error";
error?: Error | string;
};
/**
* Represents the statuses that can be passed to {@link TracingSpan.setStatus}.
*
* By default, all spans will be created with status "unset".
*/
export type SpanStatus = SpanStatusSuccess | SpanStatusError;
/**
* Represents an implementation agnostic tracing span.
*/
export interface TracingSpan {
/**
* Sets the status of the span. When an error is provided, it will be recorded on the span as well.
*
* @param status - The {@link SpanStatus} to set on the span.
*/
setStatus(status: SpanStatus): void;
/**
* Sets a given attribute on a span.
*
* @param name - The attribute's name.
* @param value - The attribute's value to set. May be any non-nullish value.
*/
setAttribute(name: string, value: unknown): void;
/**
* Ends the span.
*/
end(): void;
/**
* Records an exception on a {@link TracingSpan} without modifying its status.
*
* When recording an unhandled exception that should fail the span, please use {@link TracingSpan.setStatus} instead.
*
* @param exception - The exception to record on the span.
*
*/
recordException(exception: Error | string): void;
/**
* Returns true if this {@link TracingSpan} is recording information.
*
* Depending on the span implementation, this may return false if the span is not being sampled.
*/
isRecording(): boolean;
}
/** An immutable context bag of tracing values for the current operation. */
export interface TracingContext {
/**
* Sets a given object on a context.
* @param key - The key of the given context value.
* @param value - The value to set on the context.
*
* @returns - A new context with the given value set.
*/
setValue(key: symbol, value: unknown): TracingContext;
/**
* Gets an object from the context if it exists.
* @param key - The key of the given context value.
*
* @returns - The value of the given context value if it exists, otherwise `undefined`.
*/
getValue(key: symbol): unknown;
/**
* Deletes an object from the context if it exists.
* @param key - The key of the given context value to delete.
*/
deleteValue(key: symbol): TracingContext;
}
/**
* Tracing options to set on an operation.
*/
export interface OperationTracingOptions {
/** The context to use for created Tracing Spans. */
tracingContext?: TracingContext;
}
/**
* A utility type for when we know a TracingContext has been set
* as part of an operation's options.
*/
export type OptionsWithTracingContext<Options extends {
tracingOptions?: OperationTracingOptions;
}> = Options & {
tracingOptions: {
tracingContext: TracingContext;
};
};
//# sourceMappingURL=interfaces.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../src/interfaces.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,MAAM,MAAM,QAAQ,CAAC,CAAC,IAAI,CAAC,SAAS;IAAE,IAAI,CAAC,WAAW,EAAE,MAAM,CAAC,GAAG,GAAG,CAAA;CAAE,GACnE,CAAC,SAAS,CAAC,KAAK,EAAE,MAAM,CAAC,KAAK,GAAG,GAC/B,QAAQ,CAAC,CAAC,CAAC,GACX,KAAK,GACP,CAAC,CAAC;AAEN;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC5B;;;;;;;;;;;;;;;OAeG;IACH,QAAQ,CACN,OAAO,SAAS;QAAE,cAAc,CAAC,EAAE,uBAAuB,CAAA;KAAE,EAC5D,QAAQ,SAAS,CACf,cAAc,EAAE,OAAO,EACvB,IAAI,EAAE,IAAI,CAAC,WAAW,EAAE,KAAK,CAAC,KAC3B,UAAU,CAAC,QAAQ,CAAC,EAEzB,IAAI,EAAE,MAAM,EACZ,gBAAgB,EAAE,OAAO,EACzB,QAAQ,EAAE,QAAQ,EAClB,WAAW,CAAC,EAAE,kBAAkB,GAC/B,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IAC3C;;;;;;;;;;;;OAYG;IACH,SAAS,CAAC,OAAO,SAAS;QAAE,cAAc,CAAC,EAAE,uBAAuB,CAAA;KAAE,EACpE,IAAI,EAAE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AIG;AACH,MAAM,MAAM,UAAU,GAAG,iBAAiB,GAAG,eAAe,CAAC;AAE7D;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B;;;;OAIG;IACH,SAAS,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI,CAAC;IAEpC;;;;;OAKG;IACH,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CAAC;IAEjD;;OAEG;IACH,GAAG,IAAI,IAAI,CAAC;IAEZ;;;;;;;OAOG;IACH,eAAe,CAAC,SAAS,EAAE,KAAK,GAAG,MAAM,GAAG,IAAI,CAAC;IAEjD;;;;OAIG;IACH,WAAW,IAAI,OAAO,CAAC;CACxB;AAED,4EAA4E;AAC5E,MAAM,WAAW,cAAc;IAC7B;;;;;;OAMG;IACH,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,cAAc,CAAC;IACtD;;;;;OAKG;IACH,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;IAC/B;;;OAGG;IACH,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc,CAAC;CAC1C;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,oDAAoD;IACpD,cAAc,CAAC,EAAE,cAAc,CAAC;CACjC;AAED;;;GAGG;AACH,MAAM,MAAM,yBAAyB,CACnC,OAAO,SAAS;IAAE,cAAc,CAAC,EAAE,uBAAuB,CAAA;CAAE,IAC1D,OAAO,GAAG;IACZ,cAAc,EAAE;QACd,cAAc,EAAE,cAAc,CAAC;KAChC,CAAC;CACH,CAAC"}

View file

@ -0,0 +1,4 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
export {};
//# sourceMappingURL=interfaces.js.map

Some files were not shown because too many files have changed in this diff Show more