NewConsole bootstraps the OTel SDK with three logz-backed exporters: - Trace: WithSyncer, one log line per closed span (immediate, no batch) - Metric: PeriodicReader (60s), flushed on shutdown - OTel log: BatchProcessor, for third-party libs using OTel log API ConsoleConfig requires only ServiceName — no OTLP endpoint needed. Adds logz v1.0.1 as direct dependency; module tier bumped 1 → 2.
64 lines
2.1 KiB
Markdown
64 lines
2.1 KiB
Markdown
# v1.1.0
|
|
|
|
> `code.nochebuena.dev/go/telemetry`
|
|
|
|
## Overview
|
|
|
|
v1.1.0 adds `NewConsole` — a logz-backed alternative to `New` for local development.
|
|
All OTel signals (traces, metrics, OTel log records) are emitted as structured logz log
|
|
lines instead of being forwarded to a Grafana Alloy collector. No infrastructure required.
|
|
|
|
## What Changed Since v1.0.0
|
|
|
|
### New: `NewConsole`
|
|
|
|
```go
|
|
func NewConsole(ctx context.Context, logger logz.Logger, cfg ConsoleConfig) (func(context.Context) error, error)
|
|
```
|
|
|
|
Same shutdown pattern as `New` — drop-in swap for development environments.
|
|
|
|
**ConsoleConfig** requires only service identity fields:
|
|
|
|
| Field | Env var | Required | Default |
|
|
|-------|---------|----------|---------|
|
|
| `ServiceName` | `OTEL_SERVICE_NAME` | yes | — |
|
|
| `ServiceVersion` | `OTEL_SERVICE_VERSION` | no | `unknown` |
|
|
| `Environment` | `OTEL_ENVIRONMENT` | no | `development` |
|
|
|
|
**Output format:**
|
|
```
|
|
INFO otel: span name=GET /api/v1/permisos trace_id=3f2a9c... duration_ms=18 status=Ok
|
|
INFO otel: metric name=http.server.duration kind=histogram count=5 sum=87.3 unit=ms
|
|
INFO otel: log body=cache miss severity=INFO
|
|
```
|
|
|
|
**Signal details:**
|
|
- **Traces** — synchronous (`WithSyncer`): one log line immediately on `span.End()`
|
|
- **Metrics** — periodic reader (60s interval), flushed on shutdown
|
|
- **OTel logs** — batch processor, for third-party libs using the OTel log API
|
|
|
|
**Warning:** do not wire the OTel slog bridge alongside `NewConsole`. It would create a
|
|
feedback loop: logz → slog → OTel log API → logLogExporter → logz.
|
|
|
|
### Dependency update
|
|
|
|
- `logz v1.0.1` added as direct dependency; module tier bumped from 1 → 2
|
|
|
|
## Full API (stable)
|
|
|
|
- `Config` — `ServiceName`, `ServiceVersion`, `Environment`, `OTLPEndpoint`, `OTLPInsecure`
|
|
- `ConsoleConfig` — `ServiceName`, `ServiceVersion`, `Environment`
|
|
- `New(ctx, cfg) (func(context.Context) error, error)`
|
|
- `NewConsole(ctx, logger, cfg) (func(context.Context) error, error)`
|
|
|
|
## Installation
|
|
|
|
```
|
|
go get code.nochebuena.dev/go/telemetry@v1.1.0
|
|
```
|
|
|
|
## Changelog
|
|
|
|
See [CHANGELOG.md](CHANGELOG.md#110---2026-05-12).
|