TypeScript
fix(observability): custom resource attributes use the t3code prefix (#23974)
Yordis Prietof252ed0cdde0
diff --git a/apps/server/src/config.ts b/apps/server/src/config.tsindex c5178547b43..d0bc87cf0ff 100644--- a/apps/server/src/config.ts+++ b/apps/server/src/config.ts@@ -111,7 +111,7 @@ export const otlpResource = (attributes: {"service.namespace": "t3code","service.runtime": "t3-server",- "service.mode": config.mode,+ "t3code.server.managed_by": config.mode === "desktop" ? "desktop" : "standalone","host.name": config.otelEnvironment.resourceAttributes["host.name"] || hostName,},});diff --git a/apps/server/src/serverLogger.test.ts b/apps/server/src/serverLogger.test.tsindex 75c35a61b03..2191b072b32 100644--- a/apps/server/src/serverLogger.test.ts+++ b/apps/server/src/serverLogger.test.ts@@ -152,6 +152,19 @@ const printThroughConsole = (fields: object) =>});describe("ServerLoggerLive", () => {+ it.effect("exports a resource that names whether the desktop app launched the server", () =>+ Effect.gen(function* () {+ const { requests } = yield* logInSpanThrough({+ otlpLogsUrl: "https://collector.example.com/v1/logs",+ mode: "desktop",+ });++ const body = requests.map((request) => request.body).join("\n");+ assert.include(body, '"key":"t3code.server.managed_by","value":{"stringValue":"desktop"}');+ assert.notInclude(body, "service.mode");+ }),+ );+it.effect("prints a cause passed as a log field instead of collapsing it", () =>Effect.gen(function* () {const output = yield* printThroughConsole({diff --git a/apps/web/src/observability/clientTracing.ts b/apps/web/src/observability/clientTracing.tsindex 94e06c11bf2..73a2611c7d4 100644--- a/apps/web/src/observability/clientTracing.ts+++ b/apps/web/src/observability/clientTracing.ts@@ -20,7 +20,7 @@ const CLIENT_TRACING_RESOURCE = {"service.namespace": "t3code","deployment.environment.name": import.meta.env.DEV ? "development" : "production","service.runtime": "t3-web",- "service.mode": isElectron ? "electron" : "browser",+ "t3code.client.surface": isElectron ? "desktop" : "web","service.version": APP_VERSION,},} as const;diff --git a/docs/operations/observability.md b/docs/operations/observability.mdindex 59eb410ab08..a9d03758ebf 100644--- a/docs/operations/observability.md+++ b/docs/operations/observability.md@@ -629,6 +629,11 @@ resource attributes, such as `OTEL_RESOURCE_ATTRIBUTES=deployment.environment.naThe UI reports `deployment.environment.name` from its build: `development` under the Vite dev serverand `production` otherwise.+Attributes specific to T3 Code use the `t3code.` prefix. The UI runs as `t3code-web` in both a+browser and the desktop window, since it is the same code, and `t3code.client.surface` is `desktop`+or `web`. The server's `t3code.server.managed_by` is `desktop` when the desktop app launched it and+`standalone` otherwise.+If the OTLP URLs are unset, local tracing still works, metrics stay in-process only, and logs stayon stdout only.diff --git a/packages/shared/src/relayTracing.ts b/packages/shared/src/relayTracing.tsindex 2d726760d10..66f7e79665d 100644--- a/packages/shared/src/relayTracing.ts+++ b/packages/shared/src/relayTracing.ts@@ -173,8 +173,8 @@ export function layer(attributes: {"service.namespace": "t3code","service.runtime": resource.runtime,- "service.component": resource.component ?? "relay-client",- "t3.client.surface": resource.client,+ "t3code.component": resource.component ?? "relay-client",+ "t3code.client.surface": resource.client,},},}).pipe(Layer.provide(OtlpSerialization.layerJson));