octri_monitoring (Dart)

Error and performance monitoring for Dart applications. Report a thrown object with its stack trace, emit your own application events, time spans into a request waterfall, and continue a W3C distributed trace that started in whichever client called you.

Octri turns an OpenAPI spec into a documentation site, client SDKs for ten languages, an MCP server your AI assistant can call, and monitoring for the API behind them. This package is the Dart monitoring runtime, and it works on its own: a generated Octri API SDK is not required. See octri.dev/monitoring.

Dart 3.2 or newer, on the Dart VM. No runtime dependencies.

Install

dart pub add octri_monitoring

Setup

Call init once at startup.

import 'dart:io';
import 'package:octri_monitoring/octri_monitoring.dart';

Octri.init(OctriConfig(
  url: 'https://monitoring.example.com',            // your monitoring base URL
  token: Platform.environment['OCTRI_TOKEN'],       // your project ingest token
  environment: '<your project id>',                 // the dashboard project id
  release: Platform.environment['GIT_SHA'],         // optional
));

Hosted users copy the project-scoped URL, token, and environment from the Monitoring connection settings in the dashboard. Pass token: null only when you point at an open self-hosted ingest endpoint.

Every call is asynchronous, best effort, and carries an idempotency key. Transport failures are suppressed, so a monitoring outage cannot affect the process it is watching.

Application events

Octri.captureEvent(
  'checkout.completed',
  options: const OctriEventOptions(
    level: 'info',
    tags: {'region': 'eu-west', 'plan': 'growth'},
    context: {'orderId': 'ord_912'},
  ),
);

OctriEventOptions also carries user, breadcrumbs, fingerprint, operationId, method, path, statusCode, latencyMs, attempt, and requestId. Supplying eventId makes a retried delivery idempotent.

Errors

try {
  await handle(request);
} catch (error, stackTrace) {
  Octri.captureError(
    error,
    stackTrace: stackTrace,
    options: const OctriErrorOptions(
      method: 'POST',
      path: '/orders',
      statusCode: 500,
    ),
  );
}

Omitting stackTrace still reports the error, with the current stack.

Joining the caller's trace

Your generated client SDK sends traceparent: 00-<traceId>-<spanId>-01 on every request. Read it on the way in and pass the result as trace, and the dashboard groups the client call and the server error under one traceId: the request that failed, beside the frame that threw.

final trace = Octri.traceFromHeader(request.headers.value('traceparent'));

Octri.captureError(error, options: OctriErrorOptions(trace: trace));

traceFromHeader(null) starts a fresh trace, so the same code path works for traffic that arrives without a header.

Spans

A span is a completed unit of work. Report one per request to get the waterfall, and one per sub-operation to see where the time went inside it.

final started = DateTime.now();
final rows = await db.query(sql);

Octri.captureSpan(OctriSpan(
  traceId: trace.traceId,
  spanId: spanId,
  parentSpanId: trace.parentSpanId,
  name: 'orders.list',
  operationId: 'listOrders',
  startTime: started,
  endTime: DateTime.now(),
));

Spans sharing a traceId nest by parentSpanId in the dashboard waterfall.


What gets redacted

Payloads are scrubbed on the way out, so a credential that ended up in a log line or a context object never reaches the dashboard.

Any key whose name looks like a credential (password, secret, token, apiKey, authorization, cookie, ssn and the rest of the usual list) has its value replaced with [redacted], at any depth. Matching ignores case and separators, so api_key, apiKey and X-API-KEY are all the same key.

Free text is swept too: the message, an error message and its stack, and anything else you send as a string. Bearer tokens, JWTs, card numbers and email addresses come out as [redacted]. A card number has to pass the Luhn check first, so an order number or a timestamp survives.

user is the exception. It is the field you fill with an identity on purpose, so user.email is reported exactly as you set it. Credential-shaped keys inside it are still redacted.

Add your own key names:

Octri.addScrubFields(['accountNumber', 'otp']);

Or take the payload yourself, and return null to drop the event:

Octri.setBeforeSend((payload) => payload['path'] == '/health' ? null : payload);

Redaction runs after your hook, so a hook cannot leak a credential by accident.

The rest of Octri

Product What it does
API Studio Your OpenAPI spec becomes a hosted documentation site with a live request playground, editable page by page.
SDK Studio The same spec becomes client libraries for ten languages, versioned and released together.
MCP Your endpoints and docs become tools an AI assistant can call, generated from the same spec.
Monitoring Errors, traces, uptime and releases for the API, joined to the SDK calls that reached it.

Monitoring runtimes

More

MIT licensed.

Libraries

octri_monitoring
Standalone error and performance monitoring for Dart applications.