/**
* BSB (Better-Service-Base) is an event-bus based microservice framework.
* Copyright (C) 2016 - 2025 BetterCorp (PTY) Ltd
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alternatively, you may obtain a commercial license for this program.
* The commercial license allows you to use the Program in a closed-source manner,
* including the right to create derivative works that are not subject to the terms
* of the AGPL.
*
* To obtain a commercial license, please contact the copyright holders at
* https://www.bettercorp.dev. The terms and conditions of the commercial license
* will be provided upon request.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see .
*/
import { BSBObservable, BSBObservableConstructor, BSBError } from "@bsb/base";
import { DTrace, LogMeta } from "@bsb/base";
import * as av from "anyvali";
/**
* Configuration schema for OpenTelemetry plugin
*/
export declare const OpenTelemetryConfigSchema: av.ObjectSchema<{
serviceName: av.StringSchema;
serviceVersion: av.OptionalSchema;
endpoint: av.StringSchema;
export: av.ObjectSchema<{
protocol: av.EnumSchema;
interval: av.Int32Schema;
maxBatchSize: av.Int32Schema;
}>;
enabled: av.ObjectSchema<{
traces: av.BoolSchema;
metrics: av.BoolSchema;
logs: av.BoolSchema;
}>;
resourceAttributes: av.RecordSchema;
samplingRate: av.NumberSchema;
}>;
export type OpenTelemetryConfig = av.Infer;
export declare const Config: import("@bsb/base").BSBPluginConfigClass;
endpoint: av.StringSchema;
export: av.ObjectSchema<{
protocol: av.EnumSchema;
interval: av.Int32Schema;
maxBatchSize: av.Int32Schema;
}>;
enabled: av.ObjectSchema<{
traces: av.BoolSchema;
metrics: av.BoolSchema;
logs: av.BoolSchema;
}>;
resourceAttributes: av.RecordSchema;
samplingRate: av.NumberSchema;
}>>;
/**
* OpenTelemetry observable plugin with OTLP export
*/
export declare class Plugin extends BSBObservable> {
static Config: import("@bsb/base").BSBPluginConfigClass;
endpoint: av.StringSchema;
export: av.ObjectSchema<{
protocol: av.EnumSchema;
interval: av.Int32Schema;
maxBatchSize: av.Int32Schema;
}>;
enabled: av.ObjectSchema<{
traces: av.BoolSchema;
metrics: av.BoolSchema;
logs: av.BoolSchema;
}>;
resourceAttributes: av.RecordSchema;
samplingRate: av.NumberSchema;
}>>;
private logFormatter;
private sdk;
private tracer;
private meter;
private logger;
private loggerProvider;
private isDisposed;
private counters;
private gauges;
private histograms;
private spans;
constructor(config: BSBObservableConstructor>);
init(): Promise;
run(): Promise;
/**
* Map DTrace to OpenTelemetry trace context
*/
private getTraceContext;
/**
* Write log entry via OpenTelemetry
*/
private writeLog;
debug(trace: DTrace, pluginName: string, message: string, meta: LogMeta): void;
info(trace: DTrace, pluginName: string, message: string, meta: LogMeta): void;
warn(trace: DTrace, pluginName: string, message: string, meta: LogMeta): void;
error(trace: DTrace, pluginName: string, message: string | BSBError, meta?: LogMeta): void;
createCounter(timestamp: number, pluginName: string, name: string, description: string, help: string, labels?: string[]): void;
incrementCounter(timestamp: number, pluginName: string, name: string, value: number, labels?: Record): void;
createGauge(timestamp: number, pluginName: string, name: string, description: string, help: string, labels?: string[]): void;
setGauge(timestamp: number, pluginName: string, name: string, value: number, labels?: Record): void;
createHistogram(timestamp: number, pluginName: string, name: string, description: string, help: string, boundaries?: number[], labels?: string[]): void;
observeHistogram(timestamp: number, pluginName: string, name: string, value: number, labels?: Record): void;
spanStart(timestamp: number, trace: DTrace, pluginName: string, spanName: string, parentSpanId: string | null, attributes?: Record): void;
spanEnd(timestamp: number, trace: DTrace, pluginName: string, attributes?: Record): void;
spanError(timestamp: number, trace: DTrace, pluginName: string, error: Error, attributes?: Record): void;
dispose(): Promise;
}