feat(core-shared): Sentry-as-OTel-exporter bridge module

This commit is contained in:
2026-05-11 11:23:49 +02:00
parent 12aeb8bf37
commit 3a32838c71
2 changed files with 70 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
import { describe, it, expect, vi, beforeEach } from "vitest";
beforeEach(() => vi.resetModules());
describe("createSentryOtelBridge", () => {
it("returns a span processor when given a DSN", async () => {
// Mock @sentry/opentelemetry — we only verify the shape of what the bridge returns.
vi.doMock("@sentry/opentelemetry", () => ({
SentrySpanProcessor: class {
onStart() {}
onEnd() {}
forceFlush() {
return Promise.resolve();
}
shutdown() {
return Promise.resolve();
}
},
}));
const { createSentryOtelBridge } = await import("./sentry-bridge");
const bridge = createSentryOtelBridge({ dsn: "https://test@sentry.io/1" });
expect(bridge.spanProcessor).toBeDefined();
// logRecordProcessor is null in Phase 1 — @sentry/opentelemetry 10.x does not
// export SentryLogRecordProcessor. It will be wired in Phase 3 via @sentry/node.
expect(bridge.logRecordProcessor).toBeNull();
});
it("returns null processors when no DSN provided", async () => {
const { createSentryOtelBridge } = await import("./sentry-bridge");
const bridge = createSentryOtelBridge({ dsn: "" });
expect(bridge.spanProcessor).toBeNull();
expect(bridge.logRecordProcessor).toBeNull();
});
});