You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+31-6Lines changed: 31 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@ A DX-focused OpenTelemetry wrapper for **Bun** and **Node.js**.
5
5
Vanilla OTel works, but the setup is verbose, the logger plumbing is awkward, and PII scrubbing is on you. `@photon-ai/otel` wraps the OTLP/HTTP stack into a few well-named functions:
6
6
7
7
-**`setupOtel()`** — idempotent one-call bootstrap for traces + logs + metrics. Honors standard `OTEL_EXPORTER_OTLP_*` env vars.
8
-
-**`createIsolatedOtel()`** — creates an isolated trace + log runtime with its own Resourceand configurable propagation header, without replacing global providers or context.
8
+
-**`createIsolatedOtel()`** — creates an isolated trace + log runtime with its own Resource, configurable trace carrier, and optional private Baggage carrier, without replacing global providers or context.
9
9
-**`otel.getMeter(name)`** — creates standard OpenTelemetry instruments from this setup's meter provider, with identical behavior in global and scoped mode.
10
10
-**`createLogger(module)`** — structured logger that writes to both the OTel logger provider and `console`, with automatic trace correlation and exception capture. Every level (`debug`/`info`/`warn`/`error`) accepts `attrs`**and** an `error`, and shares one configurable level gate.
11
11
-**`withSpan(name, attrs?, fn)`** — wrap any sync or async function in a span; errors are recorded and PII in the error message is scrubbed before being attached to span status.
@@ -95,7 +95,7 @@ attribute guidance, and scoped mode.
|`setupOtel(options): OtelHandle`| Boots OTLP/HTTP traces + logs + metrics. The handle exposes `getMeter()`, providers, and `shutdown()`. Pass `register: false` for scoped mode. |
98
-
|`createIsolatedOtel(options): IsolatedOtelHandle`| Creates an isolated, non-global trace + log runtime with its own endpoint, Resource, and propagation header. Returns a new runtime on every call. |
98
+
|`createIsolatedOtel(options): IsolatedOtelHandle`| Creates an isolated, non-global trace + log runtime with its own endpoint, Resource, private trace carrier, and optional private Baggage carrier. Returns a new runtime on every call. |
99
99
|`isOtelActive(): boolean`| Returns `true` if `setupOtel` has already run in this process. |
100
100
|`instrumentFetch(options?): FetchInstrumentation`| Low-level wrap of `globalThis.fetch` for CLIENT spans + W3C propagation. Returns `{ unpatch() }`. `setupOtel` calls this on Bun; on Node it prefers native undici. |
101
101
|`createInstrumentedFetch(baseFetch?, options?): typeof fetch`| Returns a NEW instrumented fetch (CLIENT spans + W3C propagation) wrapping `baseFetch` (default `globalThis.fetch`) without touching the global. For SDKs that take a `fetch` option. |
@@ -116,19 +116,31 @@ recorded trace/log stream to a different OTLP backend without taking over the
0 commit comments