@logcaffe/shared
v0.4.0
Published
Shared observability contracts and TypeScript types for self-hosted LogCaffe SDKs/services.
Maintainers
Readme
@logcaffe/shared
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/sharedWhat's in here
- Telemetry types —
LogEntry,MetricEntry,ApiCallEntry,FrontendErrorEntry,SpanEntry,IngestBatch,Breadcrumb. - Distributed tracing helpers —
parseTraceparent,formatTraceparent,generateTraceId,generateSpanId,computeResourceHash. - Constants — default ingest batch size, rate-limit windows, API-key prefix,
parseTenantFromApiKey, role/feature presets. - Crypto helpers —
encryption.ts,credit-security.ts.
What's new in 0.4.0
MetricEntryis 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 whentype='CUSTOM'.tags—Record<string, string>for low-cardinality labels (service,http.method,db.system, …). Lives alongsidemetafor richer payloads.
Old SDKs that omit these fields keep working — both fields are optional and the collector defaults
tags = {}andname = ''.
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.