UNPKG

@itwin/core-bentley

Version:

Bentley JavaScript core components

51 lines 2.51 kB
/** @packageDocumentation * @module Logging */ import type { SpanAttributes, SpanContext, SpanOptions, Tracer } from "@opentelemetry/api"; /** * Mirrors the SpanKind enum from [@opentelemetry/api](https://open-telemetry.github.io/opentelemetry-js/enums/_opentelemetry_api.SpanKind.html) * @public * @deprecated in 4.4 - will not be removed until after 2026-06-13. OpenTelemetry Tracing helpers will become internal in a future release. Apps should use `@opentelemetry/api` directly. */ export declare enum SpanKind { INTERNAL = 0, SERVER = 1, CLIENT = 2, PRODUCER = 3, CONSUMER = 4 } /** * Enables OpenTelemetry tracing in addition to traditional logging. * @public * @deprecated in 4.4 - will not be removed until after 2026-06-13. OpenTelemetry Tracing helpers will become internal in a future release. Apps should use `@opentelemetry/api` directly. */ export declare class Tracing { private static _tracer?; private static _openTelemetry?; /** * If OpenTelemetry tracing is enabled, creates a new span and runs the provided function in it. * If OpenTelemetry tracing is _not_ enabled, runs the provided function. * @param name name of the new span * @param fn function to run inside the new span * @param options span options * @param parentContext optional context used to retrieve parent span id */ static withSpan<T>(name: string, fn: () => Promise<T>, options?: SpanOptions, parentContext?: SpanContext): Promise<T>; /** * Adds a span event describing a runtime exception, as advised in OpenTelemetry documentation * @param e error (exception) object */ static recordException(e: Error): void; /** * Enable logging to OpenTelemetry. [[Tracing.withSpan]] will be enabled, all log entries will be attached to active span as span events. * [IModelHost.startup]($backend) will call this automatically if the `enableOpenTelemetry` option is enabled and it succeeds in requiring `@opentelemetry/api`. * @note Node.js OpenTelemetry SDK should be initialized by the user. */ static enableOpenTelemetry(tracer: Tracer, api: typeof Tracing._openTelemetry): void; private static withOpenTelemetry; /** Set attributes on currently active openTelemetry span. Doesn't do anything if openTelemetry logging is not initialized. * @param attributes The attributes to set */ static setAttributes(attributes: SpanAttributes): void; } //# sourceMappingURL=Tracing.d.ts.map