UNPKG

@temporalio/interceptors-opentelemetry

Version:
48 lines 1.86 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.SpanExporter = void 0; const core_1 = require("@opentelemetry/core"); const workflow_imports_1 = require("./workflow-imports"); class SpanExporter { exporter; export(spans, resultCallback) { if (!this.exporter) { this.exporter = (0, workflow_imports_1.proxySinks)().exporter; } this.exporter.export(spans.map((span) => this.makeSerializable(span))); resultCallback({ code: core_1.ExportResultCode.SUCCESS }); } async shutdown() { // Nothing to shut down } makeSerializable(span) { const { traceState, ...restSpanContext } = span.spanContext(); // Serialize traceState to a string because TraceState objects lose their // prototype methods when crossing the V8 isolate boundary. // See: https://github.com/temporalio/sdk-typescript/issues/1738 const serializableSpanContext = { traceState: traceState?.serialize(), ...restSpanContext, }; return { name: span.name, kind: span.kind, spanContext: serializableSpanContext, parentSpanId: span.parentSpanId, startTime: span.startTime, endTime: span.endTime, status: span.status, attributes: span.attributes, links: span.links, events: span.events, duration: span.duration, ended: span.ended, droppedAttributesCount: span.droppedAttributesCount, droppedEventsCount: span.droppedEventsCount, droppedLinksCount: span.droppedLinksCount, instrumentationLibrary: span.instrumentationLibrary, }; } } exports.SpanExporter = SpanExporter; //# sourceMappingURL=span-exporter.js.map