import { globalLogger } from "../../logger.js";
const METRICS_KEY = 'metrics';
export const trackTransactionMetrics = (tr, type, meta) => {
    tr.setMeta(METRICS_KEY, { type, meta });
    return tr;
};
export const logTransactionMetrics = (tr, logger) => {
    const metrics = tr.getMeta(METRICS_KEY);
    if (metrics) {
        globalLogger.metrics({
            component: 'transaction',
            event: metrics.type,
            duration: Date.now() - tr.time,
            meta: metrics.meta,
        });
        logger.metrics({
            component: 'transaction',
            event: metrics.type,
            duration: Date.now() - tr.time,
            meta: metrics.meta,
        });
    }
};
//# sourceMappingURL=metrics.js.map
