npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@structure-ai/observability

v0.4.1

Published

Structured logging, correlation context, OpenTelemetry tracing and metrics layers.

Readme

@structure-ai/observability

Structured logging, correlation, metrics, and telemetry export for Effect apps. One layer wires the full stack; every log record is a single JSON line with stable fields, bounded sizes, and the correlation ids of the workflow that produced it.

Usage

import * as Observability from "@structure-ai/observability";
import { Effect, LogLevel } from "effect";

const obs = Observability.layer({
  service: { name: "billing", version: "1.4.2" },
  logLevel: LogLevel.Info,
  logFormat: "json",            // "pretty" for local development
  otlpUrl: "http://localhost:4318", // omit → no telemetry export
  redactKeys: ["authorization", "password"], // optional key-based redaction, any depth
});

const handler = Effect.gen(function* () {
  yield* Effect.log("invoice accepted");    // carries correlation ids automatically
}).pipe(
  Observability.Correlation.within({ requestId: "req-1" }),
  Observability.Metrics.track("billing_accept"), // span + calls/errors/latency metrics
  Effect.provide(obs),
);

Exports

| Export | What it is | | --- | --- | | layer(options) | Composed stack: ServiceMeta + logger + level + optional OTLP export. | | ServiceMeta | Service identity tag (name/version/instance) + ServiceMeta.layer(...). | | Correlation.within(ctx) / Correlation.scoped() | Merge correlation/causation/request/actor ids into the fiber; annotate logs and spans. scoped mints a correlationId when absent. | | Correlation.current / Correlation.newId() | Read the active context / make an id. | | Metrics.boundary(name) / Metrics.track(name) | Traffic + error counters and latency histogram, plus a span, for a named boundary. | | makeJsonLogger(service, write?, options?) / layerJson(write?, options?) | The structured logger; inject write to capture output in tests. options.redactKeys censors keys at any depth. layerJson becomes the only printing logger: it replaces the default logger and drops the pretty one BunRuntime.runMain installs (@structure-ai/runtime's launch already disables it). | | layerPretty / layerSilent / layerMinimumLevel(level) | Dev logger, no-logs (tests), level filter. | | layerOtlp({ baseUrl, headers? }) | Pure-Effect OTLP export of traces/metrics/logs (no OTel JS SDK). | | observabilitySettings | Ready-made @structure-ai/config settings (LOG_LEVEL, LOG_FORMAT, OTLP_URL). |

Telemetry export failure never takes down the workload.

Structured annotations and messages

Annotation values and non-string message values are rendered as JSON structure, not String(): Effect.annotateLogs({ req: { method, route, status } }) lands as annotations.req.method in the record, and Effect.log("request completed", { method, status }) yields event: "request completed" plus data: { method, status } (data holds the single structured value, or an array when several were passed; when a call carries no string, event is the JSON text of the payload).

Rendering rules, applied recursively:

| Value | Rendered as | | --- | --- | | plain object / array / Map / Set | JSON object / array (Map keys stringified) | | Redacted | "<redacted>" | | Date | ISO string | | Error | { name, message, ...ownFields } (stack omitted; tagged errors keep _tag and classification) | | Effect data types (Schema.Class, Option, Chunk…) | their toJSON() output | | bigint | decimal string | | anything with its own toString (URL, RegExp…) | that string |

Every axis is bounded so a record can't grow unbounded, and each bound leaves a marker instead of silently dropping data:

| Bound | Limit | Marker | | --- | --- | --- | | string length | 2 KB | …[truncated] suffix | | keys per object (including the top-level annotations) | 64 | extra key "…[truncated]": <dropped count> | | items per array | 128 | trailing "…[truncated: <dropped count>]" | | nesting depth | 8 | "[truncated: depth]" | | cycles | — | "[circular]" (never throws) |

redactKeys (on layer, layerJson, makeJsonLogger) is the second wall behind Redacted values, for payloads the caller did not build: any key matching one of the names (case-insensitive) renders as "[redacted]" at any depth, including top-level annotation keys. It is a backstop, not a license: never log secrets, tokens, or prompt bodies.