@egeria-systems/observability

中文文档
0.3.0发布于 2026/08/14Apache-2.0TypeScriptES Module零依赖构建来源已验证近 30 天下载 4851
原始使用文档
文档目录4 节
  1. API surfaces
  2. Privacy and failure contract
  3. Compatibility and release state
  4. Source and license

@egeria-systems/observability

Bounded operational event and restricted error-diagnostic contracts with injected delivery boundaries for generated applications.

The package has zero runtime dependencies. It imports no framework, platform SDK, browser API, or Node.js runtime API. Applications inject clocks, structured-log writers, HTTP requests, and browser senders at their composition roots.

API surfaces

  • @egeria-systems/observability creates immutable schema 2.0.0 allowlisted events and bounded error reports. OperationalSink receives safe events only; DiagnosticSink explicitly opts into restricted diagnostics. Both dispatch paths contain telemetry failure.
  • @egeria-systems/observability/server provides injected structured-object logging plus distinct safe and restricted Better Stack HTTP adapters. Exact HTTP 202 is the only success status.
  • @egeria-systems/observability/browser emits distinct schema 2.0.0 operational-event and error-report envelopes. Error reports are reduced deterministically to at most 8,192 UTF-8 bytes and use an injected same-origin transport.
  • @egeria-systems/observability/testing provides safe and diagnostic in-memory sinks with content-safe assertions.
import {
  createOperationalEvent,
  dispatchOperationalEvent,
} from "@egeria-systems/observability";
import { createMemorySink } from "@egeria-systems/observability/testing";

const created = createOperationalEvent(
  {
    name: "example.application.ready",
    kind: "application.lifecycle",
    runtime: "server",
    severity: "info",
    context: {
      eventId: "example-event",
      correlationId: "example-operation",
      service: "web",
    },
  },
  { clock: { now: () => new Date() } },
);

if (created.ok) {
  const memory = createMemorySink();
  await dispatchOperationalEvent(created.value, [memory.sink]);
}

Unexpected errors use a separate report and sink contract:

import {
  createOperationalErrorReport,
  createOperationalEvent,
  dispatchOperationalErrorReport,
} from "@egeria-systems/observability";

const errorEvent = createOperationalEvent(
  {
    name: "example.application.error",
    kind: "application.error",
    runtime: "server",
    severity: "error",
    context: { eventId: "example-error", service: "web" },
    errorCategory: "unexpected",
  },
  { clock: { now: () => new Date() } },
);
const report = errorEvent.ok
  ? createOperationalErrorReport(
      errorEvent.value,
      new Error("example failure"),
      { mechanism: "selected-catch", handled: true },
      {},
    )
  : undefined;

if (report?.ok) {
  await dispatchOperationalErrorReport(report.value, {
    operationalSinks: [workersLogsSink],
    diagnosticSinks: [approvedDiagnosticSink],
  });
}

The example sink variables are application-owned injected boundaries. The package does not discover providers or credentials.

Privacy and failure contract

Event names, context tokens, and string attributes use bounded token vocabularies. Attributes are flat scalar values admitted only through an explicit allowlist. Prohibited private-data keys, unsafe strings, nested values, non-finite numbers, raw errors, messages, stacks, causes, request data, and arbitrary objects are excluded from the safe event tier.

Error reports read only known Error-like fields through guarded access. They bound messages to 2,048 UTF-8 bytes, stacks to 16,384 UTF-8 bytes and 64 lines, causes to two links, and replace common secret, credential, token, email, IP, URL-detail, and absolute-path shapes. These reports are restricted operational data. Regex-based redaction reduces obvious exposure but is not a privacy guarantee. Provider access, region, retention, deletion, and operator handling require separate review and certification.

The Better Stack boundary accepts only a validated betterstackdata.com ingestion host and a bounded server-held bearer token. It never exposes configuration, provider response content, request payloads, or thrown error content in results. The top-level diagnostic record uses dotted provider keys; its exception.cause value retains the recursive ExceptionDiagnostics wire shape with camelCase fields such as exceptionType and exceptionStacktrace. Safe error delivery is suppressed when the same approved Better Stack identifier receives the enriched diagnostic report, avoiding duplicate provider records. The browser surface contains no provider token, storage, replay, behavioral capture, analytics, or console interception.

Every sink returns a bounded delivery category. The dispatcher attempts every sink and contains thrown, rejected, or malformed results so observability cannot become an application failure path.

Analytics remains an independent capability. Importing this package never enables Cloudflare Web Analytics or another visitor-analytics provider. The canonical ownership boundary is recorded in Package Ownership.

Compatibility and release state

The source candidate advances events and browser envelopes from schema 1.0.0 to 2.0.0, requires eventId and service, and makes correlationId optional. It is materialized in the manifest as the 0.3.0 release candidate and is not backward compatible with the published 0.2.0 contract. Version materialization does not authorize publication; live registry validation, exact-final-diff approval, integration, push, and publication remain separate gates.

Run pnpm run verify in this package to build declarations and JavaScript, lint the strict source, run behavior tests, and type-check the package.

Source and license

The package source is packages/observability. It is licensed under Apache-2.0.

版本与发布记录

@egeria-systems/observability 共发布 3 个版本,首次发布于 2026/08/07;过去 12 个月发布了 3 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.3.0latest2026/08/142 个月前
0.2.02026/08/113 个月前
0.1.02026/08/073 个月前

关于 @egeria-systems/observability 的常见问题

如何安装 @egeria-systems/observability?

在项目目录运行 npm install @egeria-systems/observability,或使用 pnpm add / yarn add / bun add。

@egeria-systems/observability 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@egeria-systems/observability 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@egeria-systems/observability 可以商用吗?

@egeria-systems/observability 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@egeria-systems/observability 的下载量有多少?

根据 npm 官方下载统计,@egeria-systems/observability 在 2026/10/13 – 2026/11/11 这 30 天内被下载 4,851 次,日均约 162 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@egeria-systems/observability 还在维护吗?

最新版本 0.3.0 发布于 2026/08/14(2 个月前);至今共发布 3 个版本,其中过去 12 个月发布了 3 个;首次发布于 2026/08/07。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。