Skip to content

Commit f252ed0

Browse files
authored
fix(observability): custom resource attributes use the t3code prefix (pingdotgg#23974)
Signed-off-by: Yordis Prieto <[email protected]>
1 parent bf5ffe8 commit f252ed0

5 files changed

Lines changed: 22 additions & 4 deletions

File tree

‎apps/server/src/config.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ export const otlpResource = (
111111
attributes: {
112112
"service.namespace": "t3code",
113113
"service.runtime": "t3-server",
114-
"service.mode": config.mode,
114+
"t3code.server.managed_by": config.mode === "desktop" ? "desktop" : "standalone",
115115
"host.name": config.otelEnvironment.resourceAttributes["host.name"] || hostName,
116116
},
117117
});

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,19 @@ const printThroughConsole = (fields: object) =>
152152
});
153153

154154
describe("ServerLoggerLive", () => {
155+
it.effect("exports a resource that names whether the desktop app launched the server", () =>
156+
Effect.gen(function* () {
157+
const { requests } = yield* logInSpanThrough({
158+
otlpLogsUrl: "https://collector.example.com/v1/logs",
159+
mode: "desktop",
160+
});
161+
162+
const body = requests.map((request) => request.body).join("\n");
163+
assert.include(body, '"key":"t3code.server.managed_by","value":{"stringValue":"desktop"}');
164+
assert.notInclude(body, "service.mode");
165+
}),
166+
);
167+
155168
it.effect("prints a cause passed as a log field instead of collapsing it", () =>
156169
Effect.gen(function* () {
157170
const output = yield* printThroughConsole({

‎apps/web/src/observability/clientTracing.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const CLIENT_TRACING_RESOURCE = {
2020
"service.namespace": "t3code",
2121
"deployment.environment.name": import.meta.env.DEV ? "development" : "production",
2222
"service.runtime": "t3-web",
23-
"service.mode": isElectron ? "electron" : "browser",
23+
"t3code.client.surface": isElectron ? "desktop" : "web",
2424
"service.version": APP_VERSION,
2525
},
2626
} as const;

‎docs/operations/observability.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,11 @@ resource attributes, such as `OTEL_RESOURCE_ATTRIBUTES=deployment.environment.na
629629
The UI reports `deployment.environment.name` from its build: `development` under the Vite dev server
630630
and `production` otherwise.
631631

632+
Attributes specific to T3 Code use the `t3code.` prefix. The UI runs as `t3code-web` in both a
633+
browser and the desktop window, since it is the same code, and `t3code.client.surface` is `desktop`
634+
or `web`. The server's `t3code.server.managed_by` is `desktop` when the desktop app launched it and
635+
`standalone` otherwise.
636+
632637
If the OTLP URLs are unset, local tracing still works, metrics stay in-process only, and logs stay
633638
on stdout only.
634639

‎packages/shared/src/relayTracing.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,8 @@ export function layer(
173173
attributes: {
174174
"service.namespace": "t3code",
175175
"service.runtime": resource.runtime,
176-
"service.component": resource.component ?? "relay-client",
177-
"t3.client.surface": resource.client,
176+
"t3code.component": resource.component ?? "relay-client",
177+
"t3code.client.surface": resource.client,
178178
},
179179
},
180180
}).pipe(Layer.provide(OtlpSerialization.layerJson));

0 commit comments

Comments
 (0)