Skip to content

feat(datadog): Monitor and ServiceLevelObjective resources - #1215

Draft
gwkline wants to merge 3 commits into
alchemy-run:mainfrom
gwkline:gwkline/datadog
Draft

feat(datadog): Monitor and ServiceLevelObjective resources#1215
gwkline wants to merge 3 commits into
alchemy-run:mainfrom
gwkline:gwkline/datadog

Conversation

@gwkline

@gwkline gwkline commented Aug 13, 2026

Copy link
Copy Markdown

New Datadog provider with Monitor and ServiceLevelObjective resources, for declaring alerting and SLO targets (e.g. latency/availability of tRPC endpoints or backend workflows) alongside the infrastructure they observe.

Built on @distilled.cloud/datadog — companion PR: alchemy-run/distilled#456 (new SDK package generated from Datadog's official v1 OpenAPI spec, Monitors + Service Level Objectives services). This PR bumps the distilled submodule to that branch; the pointer needs retargeting after the distilled PR merges.

import * as Datadog from "alchemy/Datadog";

const monitor = yield* Datadog.Monitor("checkout-errors", {
  name: "tRPC checkout.create error rate",
  type: "query alert",
  query:
    "sum(last_10m):sum:trace.express.request.errors{env:prod,resource_name:checkout.create}.as_count() / sum:trace.express.request.hits{env:prod,resource_name:checkout.create}.as_count() > 0.05",
  message: "checkout.create is failing for >5% of requests. @slack-alerts",
  options: { thresholds: { critical: 0.05, warning: 0.01 } },
});

yield* Datadog.ServiceLevelObjective("checkout-uptime", {
  name: "checkout.create uptime",
  type: "monitor",
  monitor_ids: [monitor.id.as<number>()],
  thresholds: [{ timeframe: "30d", target: 99.9 }],
  timeframe: "30d",
  target_threshold: 99.9,
});
  • Props are the distilled request types verbatim (CreateMonitorRequest / CreateSLORequest, snake_case wire names) — same shape as the Axiom Monitor resource. Queries built in the Datadog UI port over directly; metric, monitor, and time_slice SLOs are all supported.
  • Reconcile observes by cached id via getMonitor/getSLO, catches the typed NotFound tag to re-create after out-of-band deletion, PUTs in place otherwise. type changes replace (except the equivalent metric alert/query alert pair, which Datadog normalizes between). list paginates for account-wide enumeration.
  • Credentials resolve via the Alchemy AuthProvider (alchemy login, registered in the CLI's builtin auth providers) or env (DD_API_KEY / DD_APP_KEY / optional DD_SITE for regional sites).
  • Live-cloud tests (test/Datadog/) cover create → list → update → destroy for monitors, metric SLOs, and a monitor-backed SLO referencing the monitor's output id; they skipIf-gate when DD_API_KEY/DD_APP_KEY are absent.

🤖 Generated with Claude Code

New Datadog provider with Monitor and ServiceLevelObjective resources,
an Effect-native HTTP client with typed tagged errors, env/stored
credential resolution via the Alchemy AuthProvider, and live-cloud
tests gated on DD_API_KEY/DD_APP_KEY.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Comment thread packages/alchemy/src/Datadog/Api.ts Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You'll need to add data dog to distilled first.

Cc @Mkassabov

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Done — added @distilled.cloud/datadog in alchemy-run/distilled#456 (Monitors + Service Level Objectives services, generated from Datadog's official v1 OpenAPI spec via the github-style tag-bucketed pipeline). This hand-rolled client is gone; the provider now consumes the generated ops (createMonitor, getSLO, …) with typed catchTag("NotFound") handling, per the Axiom shape. The submodule pointer here targets my fork's branch until the distilled PR lands.

gwkline and others added 2 commits August 13, 2026 20:40
…tadog

Replace the hand-rolled HTTP client with the generated Datadog SDK from
distilled (alchemy-run/distilled#456): typed per-op error unions
(catchTag("NotFound")), wire-verbatim request/response schemas, and the
shared Credentials/protocol/retry machinery. Follows the Axiom provider
shape exactly.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@sam-goodwin

Copy link
Copy Markdown
Contributor

Doe this cover 100% of data dog's features? We should run a workflow to cover all instead of just doing a few

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants