UNPKG

@wesjet/function.js

Version:
28 lines (27 loc) 1.16 kB
/** * Copyright (c) Wesbitty, Inc. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * */ export declare const tracer: import("@opentelemetry/api").Tracer; export declare const traceAsync: <Res>(spanName: string, fn: () => Promise<Res>) => Promise<Res>; /** * For convenience (instead of providing a mapping function) * an array of object keys for the first argument can be provided */ type ArgKeysOrArgsMapper<T extends any[]> = (keyof T[0])[] | ((...args: T) => any); export declare const traceAsyncFn: <T extends any[]>(spanName: string, argsMapper?: ArgKeysOrArgsMapper<T>) => <U>(fn: (...args: T) => Promise<U>) => (...args: T) => Promise<U>; export declare const traceFn: <T extends any[]>(spanName: string, argsMapper?: ArgKeysOrArgsMapper<T>) => <U>(fn: (...args: T) => U) => (...args: T) => U; /** * Creates a tuple of a `start` and `end` function for a span. * e.g. helpful when used together with RxJS taps */ type SpanTuple = { start: () => void; end: () => void; }; export declare const makeSpanTuple: (spanName: string) => SpanTuple; export {};