Observability
Error capture, event tracking, metrics and feature flags.
Overview
Base path:
/v1/observabilityPython namespace:
infratext
# Python
from infrai import infra
# TypeScript
import { InfraiClient } from "@infrai/sdk";
const client = new InfraiClient({ apiKey: process.env.INFRAI_API_KEY! });
// → client.observabilityMethods
observability.error.capture
POST /v1/observability/errors
Capture an application error with optional tags.
Python
python
infra.error.capture(...)TypeScript
typescript
client.observability.captureError(err): Promise<{ ok, error_id }>Parameters
| Name | Type | Required | Description |
|---|---|---|---|
message | string | Required | Human-readable error message. |
code | string | Optional | Optional application error code. |
stack | string | Optional | Optional stack trace. |
tags | Record<string, string> | Optional | Key/value tags for grouping. |
Returns
{ ok, error_id }Example
一次性前置(每个范例都假定已完成):
bash
pip install infrai
# one-time auth (no secret needed): anonymous account + trial, writes ~/.infrai/credentials
python -c "from infrai import infra; infra.activate()"
# returning user instead: export INFRAI_API_KEY=ifr_pk_proj_...python
from infrai import infra
res = infra.error.capture(message="payment webhook failed",
code="WEBHOOK_TIMEOUT", tags={"service": "billing"})
print("error_id:", res.get("error_id"))observability.event.track
POST /v1/observability/events
Track a product event with properties.
Python
python
infra.analytics.track(event=..., properties=...)TypeScript
typescript
client.observability.track(ev: TrackEvent): Promise<{ ok }>Parameters
| Name | Type | Required | Description |
|---|---|---|---|
event | string | Required | Event name. |
properties | Record<string, unknown> | Optional | Arbitrary event properties. |
distinct_id | string | Optional | Stable id of the acting user. |
Returns
{ ok: boolean }Example
一次性前置(每个范例都假定已完成):
bash
pip install infrai
# one-time auth (no secret needed): anonymous account + trial, writes ~/.infrai/credentials
python -c "from infrai import infra; infra.activate()"
# returning user instead: export INFRAI_API_KEY=ifr_pk_proj_...python
from infrai import infra
infra.analytics.track(event="checkout_completed",
properties={"plan": "pro", "amount_usd": 20})
print("tracked")observability.metric.report
POST /v1/observability/metrics
Report one or more metric points.
Python
python
# see capability observability.metric.reportTypeScript
typescript
client.observability.metric(m: MetricPoint | MetricPoint[]): Promise<{ ok }>Parameters
| Name | Type | Required | Description |
|---|---|---|---|
name | string | Required | Metric name. |
value | number | Required | Numeric metric value. |
tags | Record<string, string> | Optional | Key/value tags for grouping. |
Returns
{ ok: boolean }Example
一次性前置(每个范例都假定已完成):
bash
pip install infrai
# one-time auth (no secret needed): anonymous account + trial, writes ~/.infrai/credentials
python -c "from infrai import infra; infra.activate()"
# returning user instead: export INFRAI_API_KEY=ifr_pk_proj_...python
from infrai import infra
infra.metric.report(name="queue.depth", value=42, tags={"queue": "emails"})
print("reported")observability.flag.is_enabled
GET /v1/observability/flags/{key}
Evaluate a feature flag for the current context.
Python
python
infra.flag.is_enabled(key)TypeScript
typescript
// see ROUTES["observability.flag.is_enabled"]Parameters
| Name | Type | Required | Description |
|---|---|---|---|
key | string | Required | Feature flag key. |
Returns
{ enabled: boolean }Example
一次性前置(每个范例都假定已完成):
bash
pip install infrai
# one-time auth (no secret needed): anonymous account + trial, writes ~/.infrai/credentials
python -c "from infrai import infra; infra.activate()"
# returning user instead: export INFRAI_API_KEY=ifr_pk_proj_...python
from infrai import infra
if infra.flag.is_enabled("new_checkout", user_id="u_123"):
... # gated path
print("flag read")