Observability and CloudWatch logging

The SDKs are deliberately cloud-agnostic and do not ship an AWS SDK or logging dependency. On AWS (ECS/Fargate or Lambda), emit structured JSON logs to stdout using the runecode.aggregator.log.v1 contract below. AWS ships stdout to CloudWatch Logs automatically with zero network latency in the wallet hot path, and RGS Admin → Aggregator Logs consumes this exact schema for RuneCode-hosted aggregators.

1. AWS CloudWatch log group convention

Every RuneCode-hosted aggregator writes to a dedicated log group following this naming convention:

/runecode/<env>/aggregator-<slug>

For example: /runecode/prod/aggregator-timelesstech or /runecode/dev/aggregator-timelesstech.

``json "logConfiguration": { "logDriver": "awslogs", "options": { "awslogs-group": "/runecode/prod/aggregator-timelesstech", "awslogs-region": "us-east-1", "awslogs-stream-prefix": "wallet" } } ``

2. Log contract (runecode.aggregator.log.v1)

Emit one JSON object per line to stdout. RGS Admin parses these fields directly to power filtering, retry tracing, and round drill-downs:

Required fields

FieldTypeDescription
schemastringAlways "runecode.aggregator.log.v1"
tsstringRFC 3339 UTC timestamp (e.g. "2026-11-20T08:15:00.123Z")
levelstring"info", "warn", or "error"
msgstringEvent type: "wallet_call", "provider_call", or "retry_scheduled"
aggregatorstringAggregator / integration slug (e.g. "timeless-tech")
endpointstringWallet path: "/v1/balance", "/v1/debit", "/v1/credit", "/v1/rollback"
http_statusnumberHTTP status returned to the RGS (200, 400, 500, …)
latency_msnumberEnd-to-end handler duration in milliseconds

Optional correlation fields

FieldTypeDescription
sub_operatorstring | nullSub-operator id resolved from SessionRecord
tx_idstring | nullRGS transaction id (debit.id, credit.id, or first rollbacks[].id)
roundnumber | nullRGS round id (clickable to Round Detail in RGS Admin)
retry_attemptnumberValue of the x-retry-attempt request header (0 on first try, 1+ on retries)
retry_after_snumber | nullValue sent in Retry-After response header, if any
error_codestring | nullWallet error code (ERR_GE, ERR_IPB, …)
provider_codestring | nullUpstream provider error code (e.g. "GS_12", "GS_50")
provider_tx_idstring | nullUpstream provider transaction id or reference
Security rule: Never log token, x-signature, raw signed request bodies, or provider secret_key values. High-RPS cost optimization (recommended): Skip routine fast 200 OK calls on attempt 0 — log 100% of errors (http_status >= 400), retries and retry recoveries (retry_attempt >= 1), and slow calls (latency_ms >= 1000). Both the TypeScript (shouldLogWalletEvent(ev)) and Rust (ev.should_log(DEFAULT_SLOW_LOG_THRESHOLD_MS)) SDKs provide this helper out of the box, cutting CloudWatch ingestion cost by ~95–99% at high RPS while keeping full auditability in Core Postgres (wallet.wallet_tx.receipt).

3. Examples

Rust (tracing + tracing-subscriber with the json feature)

// Once at startup:
tracing_subscriber::fmt()
    .json()
    .with_current_span(false)
    .flatten_event(true)
    .init();

// After handling a wallet call:
tracing::info!(
    schema = "runecode.aggregator.log.v1",
    aggregator = "timeless-tech",
    sub_operator = %session.sub_operator,
    endpoint = "/v1/credit",
    tx_id = %credit_id,
    round = round_id,
    retry_attempt,
    retry_after_s = retry_after.map(|d| d.as_secs()),
    http_status = status,
    error_code = ?err_code,
    provider_code = ?provider_code,
    latency_ms = elapsed.as_millis() as u64,
    "wallet_call"
);

TypeScript / Node

const startedAt = Date.now();
const { status, body } = await router.handle(req.method, req.path, rawBody, req.headers);

console.log(JSON.stringify({
  schema: "runecode.aggregator.log.v1",
  ts: new Date().toISOString(),
  level: status >= 500 ? "error" : status >= 400 ? "warn" : "info",
  msg: "wallet_call",
  aggregator: "timeless-tech",
  sub_operator: session?.subOperator ?? null,
  endpoint: req.path,
  tx_id: parsed?.credit?.id ?? parsed?.debit?.id ?? parsed?.rollbacks?.[0]?.id ?? null,
  round: parsed?.round ?? null,
  retry_attempt: Number(req.headers["x-retry-attempt"] ?? 0),
  retry_after_s: retryAfterSecs ?? null,
  http_status: status,
  error_code: status >= 400 ? (JSON.parse(body).code ?? null) : null,
  provider_code: providerCode ?? null,
  latency_ms: Date.now() - startedAt,
}));

4. CloudWatch Logs Insights queries

Filter retryable failures for a specific aggregator:

fields @timestamp, aggregator, sub_operator, endpoint, tx_id, round, retry_attempt, retry_after_s, http_status, error_code, provider_code, latency_ms
| filter schema = "runecode.aggregator.log.v1" and aggregator = "timeless-tech" and http_status >= 500
| sort @timestamp desc
| limit 50

Trace every attempt for a single transaction (tx_id):

fields @timestamp, aggregator, sub_operator, endpoint, retry_attempt, retry_after_s, http_status, error_code, provider_code, latency_ms
| filter tx_id = "019a1b2c-4e5f-7a80-9b1c-2d3e4f5a6b7c"
| sort @timestamp asc

5. Consuming in RGS Admin & alarms