Lines 51-91javascript
51const cache = /* @__PURE__ */ new Map();
53* Load a trace exporter for the given protocol.
54* Backward-compatible with existing usage in tracing.ts.
56async function loadExporter(protocol, provider) {
57 return loadSignalExporter("traces", protocol, provider);
60* Load a signal-specific exporter class for the given protocol.
61* Returns the constructor, or null if the package isn't installed.
63async function loadSignalExporter(signal, protocol, provider) {
64 const spec = EXPORTER_SPECS[signal]?.[protocol];
66 if (protocol === "zipkin") console.warn(`[OtelExporter] Zipkin does not support OTLP ${signal}. ${capitalize(signal)} export will be disabled.`);
69 const cacheKey = `${signal}:${protocol}`;
70 if (cache.has(cacheKey)) return cache.get(cacheKey);
72 const ExporterClass = (await import(spec.pkg))[spec.exportName];
73 if (typeof ExporterClass !== "function") {
MediumDynamic Require
Package source references dynamic require/import behavior.
dist/index.jsView on unpkg · L71 74 console.error(`[OtelExporter] ${capitalize(signal)} ${protocol} exporter package "${spec.pkg}" did not expose a "${spec.exportName}" export. ${capitalize(signal)} export will be disabled.`);
77 cache.set(cacheKey, ExporterClass);
80 const providerInfo = provider ? ` (required for ${provider})` : "";
81 const allPkgs = [spec.pkg, ...spec.extras ?? []].join(" ");
82 console.error(`[OtelExporter] ${capitalize(signal)} ${protocol} exporter is not installed${providerInfo}.\n Install the required package(s):\n npm install ${allPkgs}`);
86function capitalize(s) {
87 return s.charAt(0).toUpperCase() + s.slice(1);
90//#region src/log-converter.ts