Skip to content

mizcausevic-dev/otel-genai-diff

otel-genai-diff

CI License: AGPL-3.0-or-later

Diff two otel-genai-rollup outputs and flag breaking changes for a CI gate — e.g., a new model appeared, per-row cost jumped > 10%, span count exploded, or currency changed.

Makes the diff family a quintet alongside the per-protocol diffs:

Part of the Kinetic Gain Suite.


Why

otel-genai-rollup produces daily aggregates of GenAI usage and cost. This diff tool lets you compare two such rollups — today vs yesterday, this PR vs main, this region vs that — and fail a CI gate when something noteworthy changed.

Change reasons

dimension reasons
fleet model-added, model-removed, provider-added, provider-removed
volume spans-jumped, spans-dropped, input-tokens-jumped, output-tokens-jumped
economics cost-increased, cost-decreased, currency-changed, pricing-status-changed
meta window-shifted

Breaking reasons (set diff.breaking = true, CLI exits 1):

  • model-added / model-removed (new model = needs re-evaluation)
  • cost-increased, input-tokens-jumped, output-tokens-jumped, spans-jumped (cost / scale regressions)
  • currency-changed

cost-decreased, spans-dropped, and pricing-status-changed are informational.

CLI

otel-genai-diff previous-rollup.json next-rollup.json
    [--format json|markdown|summary]
    [--threshold 0.10]
    [--strict] [--out FILE]

--threshold (default 0.10) — minimum relative delta to flag a token / span / cost change. Pass 0.25 for tail-of-week reports where you only care about > 25% jumps.

Exit codes:

  • 0 — no changes (or only non-breaking)
  • 1 — breaking diff (or --strict and any change)
  • 2 — usage / I/O error

Library

import { diffRollups, toMarkdown } from "otel-genai-diff";
import type { RollupReport } from "otel-genai-diff";

const prev: RollupReport = JSON.parse(readFileSync("yesterday.json", "utf8"));
const next: RollupReport = JSON.parse(readFileSync("today.json", "utf8"));

const diff = diffRollups(prev, next, { threshold: 0.1 });
console.log(diff.breaking, diff.changes.length, diff.added.models);
console.log(toMarkdown(diff));

Composes with

License

AGPL-3.0-or-later

About

Diff two otel-genai-rollup outputs (per OTel GenAI semconv). Flag model added/removed, cost or token jumps > 10%, span volume shifts, currency changes. CI gate for GenAI FinOps. Makes the diff family a quintet.

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors