@logcaffe/shared

v0.4.0

Published

Shared observability contracts and TypeScript types for self-hosted LogCaffe SDKs/services.

Readme

@logcaffe/shared

npm License

Wire-format contracts and helpers shared by the LogCaffe SDKs and server. You usually don't install this directly — @logcaffe/node and @logcaffe/browser already depend on it.

Install only if you're writing a custom integration:

npm install @logcaffe/shared

What's in here

  • Telemetry typesLogEntry, MetricEntry, ApiCallEntry, FrontendErrorEntry, SpanEntry, IngestBatch, Breadcrumb.
  • Distributed tracing helpersparseTraceparent, formatTraceparent, generateTraceId, generateSpanId, computeResourceHash.
  • Constants — default ingest batch size, rate-limit windows, API-key prefix, parseTenantFromApiKey, role/feature presets.
  • Crypto helpersencryption.ts, credit-security.ts.

What's new in 0.4.0

  • MetricEntry is now histogram-friendly. Two new optional fields:

    • name — free-form OTLP-style metric identifier (e.g. http.server.duration, db.client.operation.duration). Set this when type='CUSTOM'.
    • tagsRecord<string, string> for low-cardinality labels (service, http.method, db.system, …). Lives alongside meta for richer payloads.

    Old SDKs that omit these fields keep working — both fields are optional and the collector defaults tags = {} and name = ''.

import type { MetricEntry } from '@logcaffe/shared';

const m: MetricEntry = {
  host: 'web-1',
  type: 'CUSTOM',
  name: 'http.server.duration',
  value: 124.5,
  unit: 'ms',
  tags: { service: 'api', 'http.method': 'GET', 'http.status_code': '200' },
};

Compatibility

| @logcaffe/shared | Compatible collector | |---|---| | 0.4.x | >=0.4.0 (older collectors silently drop name/tags) | | 0.3.x | >=0.3.0 |

License

MIT — see LICENSE.

Repository

https://github.com/logcaffe/LogCaffe