The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 07:15 UTC
| 1 | # @alchemy.run/axiom |
| 2 | |
| 3 | [Axiom](https://axiom.co) for [Alchemy](https://alchemy.run). Declare OpenTelemetry datasets, ingest tokens, monitors, and dashboards next to the code that emits the data. |
| 4 | |
| 5 | ```sh |
| 6 | npm install alchemy @alchemy.run/axiom effect |
| 7 | ``` |
| 8 | |
| 9 | Datasets for traces and logs, an ingest-only token, and a monitor: |
| 10 | |
| 11 | ```typescript |
| 12 | // alchemy.run.ts |
| 13 | import * as Alchemy from "alchemy"; |
| 14 | import * as Axiom from "@alchemy.run/axiom"; |
| 15 | import * as Effect from "effect/Effect"; |
| 16 | |
| 17 | export default Alchemy.Stack( |
| 18 | "Observability", |
| 19 | { |
| 20 | providers: Axiom.providers(), |
| 21 | state: Alchemy.localState(), |
| 22 | }, |
| 23 | Effect.gen(function* () { |
| 24 | const traces = yield* Axiom.Dataset("traces", { name: "app-traces", kind: "otel:traces:v1" }); |
| 25 | const logs = yield* Axiom.Dataset("logs", { name: "app-logs", kind: "otel:logs:v1" }); |
| 26 | |
| 27 | // Can write to the two datasets and nothing else. |
| 28 | const ingest = yield* Axiom.ApiToken("ingest", { |
| 29 | name: "app-ingest", |
| 30 | datasetCapabilities: { |
| 31 | "app-traces": { ingest: ["create"] }, |
| 32 | "app-logs": { ingest: ["create"] }, |
| 33 | }, |
| 34 | }); |
| 35 | |
| 36 | yield* Axiom.Monitor("panics", { |
| 37 | name: "Service panic", |
| 38 | type: "MatchEvent", |
| 39 | aplQuery: `['app-logs'] | where message contains "panic:"`, |
| 40 | intervalMinutes: 1, |
| 41 | rangeMinutes: 1, |
| 42 | }); |
| 43 | |
| 44 | return { |
| 45 | tracesEndpoint: traces.otelTracesEndpoint, |
| 46 | logsEndpoint: logs.otelLogsEndpoint, |
| 47 | token: ingest.token, |
| 48 | }; |
| 49 | }), |
| 50 | ); |
| 51 | ``` |
| 52 | |
| 53 | Pass the endpoints and token to a Worker or Lambda as environment variables and its OpenTelemetry exporter ships straight to Axiom. |
| 54 | |
| 55 | ## Learn more |
| 56 | |
| 57 | - [Axiom on alchemy.run](https://alchemy.run/axiom) |
| 58 | - [Setup](https://alchemy.run/axiom/setup) |
| 59 | - [Telemetry](https://alchemy.run/infrastructure-as-effects/telemetry) |