Skip to content

Commit 91dc7f4

Browse files
committed
test(observability): pin exported relay resource identity
Signed-off-by: Yordis Prieto <[email protected]>
1 parent f94d593 commit 91dc7f4

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

‎infra/relay/src/observability.test.ts‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ it.effect("exports schema error fields as span attributes", () =>
6262

6363
const request = yield* Deferred.await(exportedRequest).pipe(Effect.timeout("1 second"));
6464
const payload = (yield* decodeJson(request.body)) as OtlpTracer.TraceData;
65+
const resourceAttributes = Object.fromEntries(
66+
payload.resourceSpans
67+
.flatMap((resourceSpan) => resourceSpan.resource.attributes)
68+
.map((attribute) => [attribute.key, otlpAttributeValue(attribute.value)]),
69+
);
6570
const span = payload.resourceSpans
6671
.flatMap((resourceSpan) => resourceSpan.scopeSpans)
6772
.flatMap((scopeSpan) => scopeSpan.spans)
@@ -75,6 +80,10 @@ it.effect("exports schema error fields as span attributes", () =>
7580

7681
expect(request.authorization).toBe("Bearer test-token");
7782
expect(request.dataset).toBe("relay-test-traces");
83+
expect(resourceAttributes).toMatchObject({
84+
"service.name": "t3code-relay",
85+
"service.namespace": "t3code",
86+
});
7887
expect(attributes).toMatchObject({
7988
"error.type": "EnvironmentConnectNotAuthorized",
8089
"error.environmentId": "environment-1",

‎packages/shared/src/relayTracing.test.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ describe("withRelayClientTracing", () => {
9797
const payload = new TextDecoder().decode(fetchFn.mock.calls[0]?.[1]?.body as Uint8Array);
9898
expect(payload).toContain("relay request failed");
9999
expect(payload).toContain("relay socket closed");
100+
expect(payload).toContain('"key":"service.name","value":{"stringValue":"relay-test"}');
101+
expect(payload).toContain('"key":"service.namespace","value":{"stringValue":"t3code"}');
100102
}),
101103
),
102104
);

0 commit comments

Comments
 (0)