Skip to content

Commit 4f6f436

Browse files
committed
test(server): pin the server resource's service instance id
Signed-off-by: Yordis Prieto <[email protected]>
1 parent 5646dcb commit 4f6f436

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

‎apps/server/src/config.test.ts‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { describe, expect, it } from "@effect/vitest";
2+
import * as OtelEnvironment from "@t3tools/shared/otelEnvironment";
3+
4+
import { otlpResource } from "./config.ts";
5+
6+
describe("otlpResource", () => {
7+
it("gives every resource of one process the same service instance id", () => {
8+
const config = { mode: "web" as const, otelEnvironment: OtelEnvironment.none };
9+
10+
const logs = otlpResource(config, "host-a");
11+
const traces = otlpResource(config, "host-a");
12+
13+
expect(logs.attributes["service.instance.id"]).not.toBe("");
14+
expect(traces.attributes["service.instance.id"]).toBe(logs.attributes["service.instance.id"]);
15+
});
16+
17+
it("uses the operator's service instance id instead of a generated one", () => {
18+
const resource = otlpResource(
19+
{
20+
mode: "web",
21+
otelEnvironment: {
22+
...OtelEnvironment.none,
23+
resourceAttributes: { "service.instance.id": "pod-7" },
24+
},
25+
},
26+
"host-a",
27+
);
28+
29+
expect(resource.attributes["service.instance.id"]).toBe("pod-7");
30+
});
31+
});

0 commit comments

Comments
 (0)