Building a context-first observability library that brings structured errors, logging, metrics, and distributed tracing under a unified API.
From Error Handling to Observability
When I initially built Crumbs, the goal was straightforward: make errors in Go more meaningful by preserving structured context throughout the execution chain.
However, contextual errors only solve one part of the observability problem.
In distributed systems, developers repeatedly attach the same information to logs, metrics, traces, and errors. Each signal has its own instrumentation API, context propagation mechanism, and configuration requirements.
This introduces unnecessary boilerplate, inconsistent telemetry, and additional maintenance overhead.
With Crumbs v0.1.0, I decided to address this broader problem through a ground-up architectural redesign.
The Core Idea: Context as the Source of Truth
Rather than treating observability signals as independent concerns, Crumbs uses context.Context as the shared foundation.
Application context is captured once and reused wherever telemetry is generated.
The objective is to make observability a natural consequence of writing application code rather than an additional layer of instrumentation.
What’s New in v0.1.0
- Contextual attributes: Immutable, structured attributes propagated through execution boundaries.
- Contextual errors: Preserve diagnostic information across error chains without flattening it into strings.
- Structured logging: Native integration with Go’s standard
log/slogpackage. - Metrics: OpenTelemetry-backed application and operation metrics.
- Distributed tracing: Context-aware span creation and propagation.
- Operation instrumentation: Automatically capture invocation counts, execution duration, and spans.
- Cardinality management: Explicit separation between diagnostic fields and metric labels.
- Optional SDK: Independently configurable OTLP/gRPC telemetry export.
Architectural Decisions
1. Immutable Context Propagation
Contextual attributes are immutable. Adding new attributes creates a derived context without modifying its parent.
This makes context propagation predictable across nested operations and concurrent workloads.
2. Standards Over Custom Abstractions
Instead of introducing proprietary logging interfaces or telemetry protocols, Crumbs builds on existing ecosystem standards:
context.Contextfor propagation.log/slogfor structured logging.- OpenTelemetry for metrics and tracing.
- OTLP/gRPC for telemetry export.
The intention is to complement existing observability infrastructure rather than replace it.
3. Cardinality as an Explicit Design Concern
Not every contextual attribute belongs in a metric.
Request IDs, user IDs, and transaction IDs provide valuable diagnostic context but can introduce significant cardinality problems when used as metric dimensions.
Crumbs distinguishes between two attribute policies:
- Field: Diagnostic context excluded from metric dimensions.
- Label: An attribute explicitly eligible for use as a metric dimension.
This makes cardinality management an application-level engineering decision rather than an accidental consequence of instrumentation.
4. Instrumentation at Operation Boundaries
Crumbs introduces Start and Run abstractions for instrumenting application operations.
Each instrumented operation records an invocation counter, a duration histogram, and a trace span.
This reduces repetitive instrumentation code while establishing consistent telemetry across application components.
5. Separation of API and SDK
The core library does not require an active telemetry exporter.
Metrics and traces remain no-ops until appropriate OpenTelemetry providers are configured. Applications can use their existing providers or the optional Crumbs SDK.
This separation provides greater control over dependencies, configuration, and telemetry lifecycle management.
6. Performance-Conscious Design
Observability libraries frequently operate on application hot paths.
Crumbs is designed around concurrency safety, efficient attribute lookup, instrument caching, and minimizing unnecessary allocations.
The objective is to make instrumentation practical for high-throughput backend systems.
Why a Ground-Up Redesign?
Rather than incrementally adding features to the original error-handling library, I chose to revisit its fundamental abstractions.
Maintaining backward compatibility at this stage would have introduced unnecessary complexity and constrained the architecture.
Version 0.1.0 is therefore an intentional breaking release, establishing a cleaner foundation for future development.
What’s Next?
Crumbs is still evolving. My focus going forward is on:
- Performance benchmarking across realistic workloads.
- Improving instrumentation ergonomics.
- Expanding integration examples for distributed systems.
- Exploring context-rich telemetry for AI-assisted production debugging.
Conclusion
Observability is not just about generating more telemetry. It is about preserving enough context to understand how a system behaves and why it fails.
With Crumbs, I want to explore what observability looks like when context becomes the primary abstraction rather than an afterthought.
Crumbs v0.1.0 is now available as an open-source Go library.