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

@ -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;
};
};
//#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AAI,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,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"]}