@theaiinc/argus-sdk
v0.2.0
Published
Client SDK for reporting service health, logs and errors to Argus.
Readme
@theaiinc/argus-sdk
Client SDK for reporting service health, logs and errors to Argus.
Install
npm install @theaiinc/argus-sdkUsage
import { ArgusClient } from "@theaiinc/argus-sdk";
const client = new ArgusClient({
endpoint: "https://argus.theaiinc.com",
token: process.env.ARGUS_TOKEN
});
await client.report({
service: { name: "orders", version: "2.4.0", environment: "production" },
checks: [
{ id: "database", name: "Primary database", type: "dependency", status: "HEALTHY", latencyMs: 12 }
],
dependencies: [
{ target: "postgres", type: "database", criticality: "required" }
],
reportedAt: new Date().toISOString()
});report() is best-effort: it retries on failure and never throws, so it's
safe to call from a host service's own health-check path without risking an
unrelated outage if Argus itself is unreachable.
Logs and errors
import { ArgusClient, createAegisTokenProvider } from "@theaiinc/argus-sdk";
const client = new ArgusClient({
endpoint: "https://argus.theaiinc.com",
tokenProvider: createAegisTokenProvider({
issuer: "https://id.theaiinc.com",
clientId: process.env.ARGUS_CLIENT_ID!,
clientSecret: process.env.ARGUS_CLIENT_SECRET!,
resource: "https://argus.theaiinc.com"
})
});
const service = { name: "orders", environment: "production" };
await client.log({
service,
entries: [{ timestamp: new Date().toISOString(), level: "info", message: "order created", route: "/orders", statusCode: 201 }]
});
await client.captureError(service, new Error("payment declined"), { route: "/orders", method: "POST" });The service must be registered in Argus to the Aegis client whose token you
send. log() takes up to 200 entries per call. Entries at level error or
fatal are grouped into issues by fingerprint. Argus removes anything shaped
like a credential before storing a log, but do not send one: leave request
bodies, headers and query strings out of your entries.
log() and captureError() are best-effort in the same way as report().
