import TelemetryContext from "./TelemetryContext";
/**
 * Copies the ambient {@link TelemetryContext} attributes (projectId, userId,
 * monitorId, incidentId, requestId, ...) onto every span at creation time.
 *
 * Combined with `TelemetryContext` scopes seeded at each entry point (HTTP
 * request, worker job, probe check, cron run), this makes the full
 * tenant/business context queryable on all spans — including the ~1958
 * attribute-less `@CaptureSpan` spans — without touching any of those call
 * sites.
 */
export default class ContextSpanProcessor {
    onStart(span, _parentContext) {
        try {
            const attributes = TelemetryContext.getAttributes();
            for (const key in attributes) {
                const value = attributes[key];
                if (value !== undefined && value !== null) {
                    span.setAttribute(key, value);
                }
            }
        }
        catch (_a) {
            // Context enrichment must never break span creation.
        }
    }
    onEnd(_span) {
        // no-op: enrichment happens entirely in onStart.
    }
    shutdown() {
        return Promise.resolve();
    }
    forceFlush() {
        return Promise.resolve();
    }
}
//# sourceMappingURL=ContextSpanProcessor.js.map