@cerbos/opentelemetry
Version:
OpenTelemetry instrumentation for the @cerbos/grpc and @cerbos/http client libraries
75 lines • 2.44 kB
TypeScript
import type { MeterProvider, Tracer, TracerProvider } from "@opentelemetry/api";
import type { Instrumentation, InstrumentationConfig } from "@opentelemetry/instrumentation";
import { Instruments } from "./instruments";
/**
* Configuration for OpenTelemetry instrumentation of Cerbos clients.
*
* @remarks
* See {@link https://open-telemetry.github.io/opentelemetry-js/interfaces/_opentelemetry_instrumentation.InstrumentationConfig.html | InstrumentationConfig documentation from OpenTelemetry}.
*
* @public
*/
export type CerbosInstrumentationConfig = InstrumentationConfig;
/**
* OpenTelemetry instrumentation for Cerbos clients.
*
* @example
* ```typescript
* import { CerbosInstrumentation } from "@cerbos/opentelemetry";
* import { registerInstrumentations } from "@opentelemetry/instrumentation";
*
* registerInstrumentations({
* instrumentations: [...yourOtherInstrumentations, new CerbosInstrumentation()],
* });
* ```
*
* @public
*/
export declare class CerbosInstrumentation implements Instrumentation {
/**
* Name of the instrumentation.
*/
readonly instrumentationName: string;
/**
* Version of the instrumentation.
*/
readonly instrumentationVersion: string;
/** @internal */
_tracer: Tracer;
private readonly diag;
private readonly instrumenter;
private config;
private instruments;
constructor(config?: CerbosInstrumentationConfig);
/**
* Gets the instrumentation configuration.
*/
getConfig(): CerbosInstrumentationConfig;
/**
* Sets the instrumentation configuration.
*
* @remarks
* Changing `enabled` via this method has no effect.
* Use the {@link CerbosInstrumentation.disable} and {@link CerbosInstrumentation.enable} methods instead.
*/
setConfig(config: CerbosInstrumentationConfig): void;
/**
* Override the meter provider, which otherwise defaults to the global meter provider.
*/
setMeterProvider(meterProvider: MeterProvider): void;
/**
* Override the tracer provider, which otherwise defaults to the global tracer provider.
*/
setTracerProvider(tracerProvider: TracerProvider): void;
/**
* Enables the instrumentation.
*/
enable(): void;
/**
* Disables the instrumentation.
*/
disable(): void;
/** @internal */
get _instruments(): Instruments;
}
//# sourceMappingURL=instrumentation.d.ts.map