Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions apps/desktop/src/app/DesktopObservability.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as NodeHttpClient from "@effect/platform-node/NodeHttpClient";
import desktopPackageJson from "../../package.json" with { type: "json" };
import * as NodeServices from "@effect/platform-node/NodeServices";
import { assert, describe, it } from "@effect/vitest";
import * as ConfigProvider from "effect/ConfigProvider";
Expand Down Expand Up @@ -312,4 +313,33 @@ describe("DesktopObservability", () => {
),
);
});

it.effect("reports the app's own version for an unpackaged desktop run", () => {
const requests: Array<ExportedRequest> = [];
return Effect.gen(function* () {
const fileSystem = yield* FileSystem.FileSystem;
const baseDir = yield* fileSystem.makeTempDirectoryScoped({
prefix: "t3-desktop-observability-test-",
});
const layerEnvironment = layerEnvironmentFor(baseDir);
yield* writeObservabilitySettings(layerEnvironment, {
otlpLogsUrl: "https://settings.example.com/v1/logs",
});

yield* Effect.scoped(
Effect.logInfo("desktop resource under test").pipe(
Effect.provide(DesktopObservability.layer.pipe(Layer.provideMerge(layerEnvironment))),
),
);

const body = requests.map((request) => request.body).join("\n");
assert.include(
body,
`"key":"service.version","value":{"stringValue":"${desktopPackageJson.version}"}`,
);
}).pipe(
Effect.scoped,
Effect.provide(Layer.mergeAll(NodeServices.layer, layerCollector(requests), layerEmptyEnv)),
);
});
});
5 changes: 4 additions & 1 deletion apps/desktop/src/app/DesktopObservability.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ import * as SynchronizedRef from "effect/SynchronizedRef";
import * as Tracer from "effect/Tracer";
import { OtlpExporter, OtlpLogger, OtlpTracer } from "effect/observability";

import desktopPackageJson from "../../package.json" with { type: "json" };

import * as DesktopEnvironment from "./DesktopEnvironment.ts";

const DESKTOP_LOG_FILE_MAX_BYTES = 10 * 1024 * 1024;
Expand Down Expand Up @@ -597,7 +599,8 @@ const layerTelemetry = Layer.unwrap(
const endpoints = yield* resolveOtlpEndpoints;
const resource = {
serviceName: "t3code-desktop",
serviceVersion: environment.appVersion,
// Unpackaged runs launch a script, so Electron reports its own version.
serviceVersion: environment.isPackaged ? environment.appVersion : desktopPackageJson.version,
attributes: {
"service.namespace": "t3code",
"service.runtime": "desktop",
Expand Down
1 change: 1 addition & 0 deletions apps/web/src/observability/clientTracing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const CLIENT_TRACING_RESOURCE = {
serviceName: "t3code-web",
attributes: {
"service.namespace": "t3code",
"deployment.environment.name": import.meta.env.DEV ? "development" : "production",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we wanna differentaite different stages of production here? development, preview, nightly, stable ? or save that for another attribute? i guess it's already kidna included in service.version

"service.runtime": "t3-web",
"service.mode": isElectron ? "electron" : "browser",
"service.version": APP_VERSION,
Expand Down
2 changes: 2 additions & 0 deletions docs/operations/observability.md
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,8 @@ Service names are fixed: `t3code-server` for the backend and `t3code-desktop` fo
process, both in `service.namespace` `t3code`. `OTEL_SERVICE_NAME` and a `service.name` or
`service.namespace` in `OTEL_RESOURCE_ATTRIBUTES` are ignored. Tell installations apart with other
resource attributes, such as `OTEL_RESOURCE_ATTRIBUTES=deployment.environment.name=development`.
The UI reports `deployment.environment.name` from its build: `development` under the Vite dev server
and `production` otherwise.

If the OTLP URLs are unset, local tracing still works, metrics stay in-process only, and logs stay
on stdout only.
Expand Down
Loading