| ... | @@ -4,7 +4,6 @@ import { assert, describe, it } from "@effect/vitest"; | ... | @@ -4,7 +4,6 @@ import { assert, describe, it } from "@effect/vitest"; |
| 4 | import * as Effect from "effect/Effect"; | 4 | import * as Effect from "effect/Effect"; |
| 5 | import * as FileSystem from "effect/FileSystem"; | 5 | import * as FileSystem from "effect/FileSystem"; |
| 6 | import * as Layer from "effect/Layer"; | 6 | import * as Layer from "effect/Layer"; |
| 7 | import * as Metric from "effect/Metric"; | | |
| 8 | import * as Schema from "effect/Schema"; | 7 | import * as Schema from "effect/Schema"; |
| 9 | import * as HttpClient from "effect/unstable/http/HttpClient"; | 8 | import * as HttpClient from "effect/unstable/http/HttpClient"; |
| 10 | import * as HttpClientResponse from "effect/unstable/http/HttpClientResponse"; | 9 | import * as HttpClientResponse from "effect/unstable/http/HttpClientResponse"; |
| ... | @@ -428,32 +427,6 @@ describe("DesktopObservability", () => { | ... | @@ -428,32 +427,6 @@ describe("DesktopObservability", () => { |
| 428 | ); | 427 | ); |
| 429 | }); | 428 | }); |
| 430 | | 429 | |
| 431 | it.effect("exports main process metrics to the configured metrics endpoint", () => { | | |
| 432 | const requests: Array<ExportedRequest> = []; | | |
| 433 | return Effect.gen(function* () { | | |
| 434 | const fileSystem = yield* FileSystem.FileSystem; | | |
| 435 | const baseDir = yield* fileSystem.makeTempDirectoryScoped({ | | |
| 436 | prefix: "t3-desktop-observability-test-", | | |
| 437 | }); | | |
| 438 | const environmentLayer = makeEnvironmentLayer(baseDir, true, { | | |
| 439 | T3CODE_OTLP_METRICS_URL: "https://collector.example.com/v1/metrics", | | |
| 440 | }); | | |
| 441 | | | |
| 442 | yield* Effect.scoped( | | |
| 443 | Metric.update(Metric.counter("desktop_metrics_export_test_total"), 1).pipe( | | |
| 444 | Effect.provide(DesktopObservability.layer.pipe(Layer.provideMerge(environmentLayer))), | | |
| 445 | ), | | |
| 446 | ); | | |
| 447 | | | |
| 448 | assert.lengthOf(requests, 1); | | |
| 449 | assert.strictEqual(requests[0]?.url, "https://collector.example.com/v1/metrics"); | | |
| 450 | assert.include(requests[0]?.body ?? "", "desktop_metrics_export_test_total"); | | |
| 451 | }).pipe( | | |
| 452 | Effect.scoped, | | |
| 453 | Effect.provide(Layer.mergeAll(NodeServices.layer, collectorLayer(requests))), | | |
| 454 | ); | | |
| 455 | }); | | |
| 456 | | | |
| 457 | it.effect("reads every signal endpoint from Settings when the environment names none", () => { | 430 | it.effect("reads every signal endpoint from Settings when the environment names none", () => { |
| 458 | const requests: Array<ExportedRequest> = []; | 431 | const requests: Array<ExportedRequest> = []; |
| 459 | return Effect.gen(function* () { | 432 | return Effect.gen(function* () { |
| ... | @@ -463,30 +436,31 @@ describe("DesktopObservability", () => { | ... | @@ -463,30 +436,31 @@ describe("DesktopObservability", () => { |
| 463 | }); | 436 | }); |
| 464 | const environmentLayer = makeEnvironmentLayer(baseDir); | 437 | const environmentLayer = makeEnvironmentLayer(baseDir); |
| 465 | yield* writeObservabilitySettings(environmentLayer, { | 438 | yield* writeObservabilitySettings(environmentLayer, { |
| | 439 | otlpTracesUrl: "https://settings.example.com/v1/traces", |
| 466 | otlpLogsUrl: "https://settings.example.com/v1/logs", | 440 | otlpLogsUrl: "https://settings.example.com/v1/logs", |
| | 441 | // The main process records no metrics yet, so this endpoint must |
| | 442 | // not produce a request. |
| 467 | otlpMetricsUrl: "https://settings.example.com/v1/metrics", | 443 | otlpMetricsUrl: "https://settings.example.com/v1/metrics", |
| 468 | }); | 444 | }); |
| 469 | | 445 | |
| 470 | yield* Effect.scoped( | 446 | yield* Effect.scoped( |
| 471 | Effect.gen(function* () { | 447 | Effect.logInfo("desktop log export from settings").pipe( |
| 472 | yield* Effect.logInfo("desktop log export from settings"); | 448 | Effect.withSpan("desktop-settings-export-test"), |
| 473 | yield* Metric.update(Metric.counter("desktop_settings_export_test_total"), 1); | | |
| 474 | }).pipe( | | |
| 475 | Effect.provide(DesktopObservability.layer.pipe(Layer.provideMerge(environmentLayer))), | 449 | Effect.provide(DesktopObservability.layer.pipe(Layer.provideMerge(environmentLayer))), |
| 476 | ), | 450 | ), |
| 477 | ); | 451 | ); |
| 478 | | 452 | |
| 479 | assert.deepEqual(requests.map((request) => request.url).toSorted(), [ | 453 | assert.deepEqual(requests.map((request) => request.url).toSorted(), [ |
| 480 | "https://settings.example.com/v1/logs", | 454 | "https://settings.example.com/v1/logs", |
| 481 | "https://settings.example.com/v1/metrics", | 455 | "https://settings.example.com/v1/traces", |
| 482 | ]); | 456 | ]); |
| 483 | assert.include( | 457 | assert.include( |
| 484 | requests.find((request) => request.url.endsWith("/v1/logs"))?.body ?? "", | 458 | requests.find((request) => request.url.endsWith("/v1/logs"))?.body ?? "", |
| 485 | "desktop log export from settings", | 459 | "desktop log export from settings", |
| 486 | ); | 460 | ); |
| 487 | assert.include( | 461 | assert.include( |
| 488 | requests.find((request) => request.url.endsWith("/v1/metrics"))?.body ?? "", | 462 | requests.find((request) => request.url.endsWith("/v1/traces"))?.body ?? "", |
| 489 | "desktop_settings_export_test_total", | 463 | "desktop-settings-export-test", |
| 490 | ); | 464 | ); |
| 491 | }).pipe( | 465 | }).pipe( |
| 492 | Effect.scoped, | 466 | Effect.scoped, |