test(diagnostics-otel): update mocks for OpenTelemetry v2.x API
Update test mocks to match the new OpenTelemetry v2.x API: - Replace Resource class with resourceFromAttributes function - Replace SemanticResourceAttributes with ATTR_SERVICE_NAME - Update LoggerProvider mock to accept processors in constructor This fixes the test failures that were blocking CI checks. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
df26d4a164
commit
8d35b044c1
@ -65,7 +65,9 @@ vi.mock("@opentelemetry/exporter-logs-otlp-http", () => ({
|
|||||||
vi.mock("@opentelemetry/sdk-logs", () => ({
|
vi.mock("@opentelemetry/sdk-logs", () => ({
|
||||||
BatchLogRecordProcessor: class {},
|
BatchLogRecordProcessor: class {},
|
||||||
LoggerProvider: class {
|
LoggerProvider: class {
|
||||||
addLogRecordProcessor = vi.fn();
|
constructor(_options?: unknown) {
|
||||||
|
// v2.x: processors are passed in constructor
|
||||||
|
}
|
||||||
getLogger = vi.fn(() => ({
|
getLogger = vi.fn(() => ({
|
||||||
emit: logEmit,
|
emit: logEmit,
|
||||||
}));
|
}));
|
||||||
@ -83,16 +85,13 @@ vi.mock("@opentelemetry/sdk-trace-base", () => ({
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
vi.mock("@opentelemetry/resources", () => ({
|
vi.mock("@opentelemetry/resources", () => ({
|
||||||
Resource: class {
|
resourceFromAttributes: vi.fn((attributes?: unknown) => ({
|
||||||
// eslint-disable-next-line @typescript-eslint/no-useless-constructor
|
attributes,
|
||||||
constructor(_value?: unknown) {}
|
})),
|
||||||
},
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
vi.mock("@opentelemetry/semantic-conventions", () => ({
|
vi.mock("@opentelemetry/semantic-conventions", () => ({
|
||||||
SemanticResourceAttributes: {
|
ATTR_SERVICE_NAME: "service.name",
|
||||||
SERVICE_NAME: "service.name",
|
|
||||||
},
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
vi.mock("openclaw/plugin-sdk", async () => {
|
vi.mock("openclaw/plugin-sdk", async () => {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user