@boxyhq/metrics
Version:
Internal SDK for OTel instrumentation
25 lines (24 loc) • 902 B
TypeScript
import type { Attributes } from '@opentelemetry/api';
type InstrumentOperationParams = {
/** OTel meter name */
meter: string;
/** Function name being instrumented */
name: string;
/** Handle to execute the function */
delegate: () => unknown;
/** Metric Attributes in the form of key value pairs */
instrumentAttributes?: Attributes;
};
/**
* Run the given function, recording throughput, latency and errors
*
* @param operationParams
*/
declare function instrument({ meter, name, delegate, instrumentAttributes }: InstrumentOperationParams): Promise<unknown>;
/**
* Decorator that instruments a class method
*
* @param meter - Name of OTel meter
*/
declare function instrumented(meter: string): (target: any, key: string, descriptor?: PropertyDescriptor) => PropertyDescriptor | undefined;
export { instrument, instrumented, type InstrumentOperationParams };