logfire client for zig

docs: update README for otel-zig backend

- clarify we now use otel-zig with OTLP/protobuf (not JSON)
- update status: metrics are stubs, logging is console-only
- add example showing nested span parent-child linking
- note cross-platform support (macOS + Linux)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

+24 -29
+24 -29
README.md
··· 1 1 # logfire-zig 2 2 3 - unofficial Zig SDK for [Pydantic Logfire](https://logfire.pydantic.dev/) - OTLP HTTP/JSON export for traces, logs, and metrics. 3 + unofficial Zig SDK for [Pydantic Logfire](https://logfire.pydantic.dev/) - built on [otel-zig](https://github.com/open-telemetry/opentelemetry-zig) for OTLP/protobuf export. 4 4 5 5 aiming for parity with [logfire-rust](https://github.com/pydantic/logfire-rust). 6 6 ··· 45 45 }); 46 46 defer lf.shutdown(); 47 47 48 - // structured logging 48 + // structured logging (console output) 49 49 logfire.info("application started", .{}); 50 50 51 - // spans for timing operations 51 + // spans for timing operations (exported to Logfire) 52 52 { 53 53 const span = logfire.span("process.files", .{}); 54 54 defer span.end(); 55 55 56 - // work happens here 57 - std.time.sleep(10 * std.time.ns_per_ms); 56 + // nested spans automatically link to parent 57 + { 58 + const child = logfire.span("process.single_file", .{ .filename = "data.csv" }); 59 + defer child.end(); 60 + std.time.sleep(10 * std.time.ns_per_ms); 61 + } 58 62 } 59 63 60 - // metrics 61 - logfire.counter("files.processed", 42); 62 - logfire.gaugeInt("queue.depth", 10); 63 - 64 64 // flush before exit 65 65 try lf.flush(); 66 66 } ··· 76 76 77 77 ## Features 78 78 79 - - **Spans** - timing and tracing with attributes 80 - - **Logging** - trace, debug, info, warn, err with structured data 81 - - **Metrics** - counters, gauges (int/double) 82 - - **OTLP Export** - HTTP/JSON to logfire or any OTLP-compatible backend 79 + - **Spans** - timing and tracing with attributes, automatic parent-child linking 80 + - **Logging** - trace, debug, info, warn, err (console output) 81 + - **OTLP Export** - HTTP/protobuf via otel-zig to Logfire or any OTLP-compatible backend 83 82 - **Zero Config** - reads token and endpoint from environment 83 + - **Cross-platform** - works on macOS and Linux 84 84 85 85 ## API 86 86 ··· 89 89 const lf = try logfire.configure(.{ 90 90 .service_name = "my-service", 91 91 .service_version = "1.0.0", 92 - .environment = "production", 93 92 }); 94 93 defer lf.shutdown(); 95 94 96 - // spans 95 + // spans (exported to Logfire via OTLP/protobuf) 97 96 const span = logfire.span("operation.name", .{ 98 97 .user_id = @as(i64, 123), 99 98 .request_path = "/api/search", 100 99 }); 101 100 defer span.end(); 102 101 103 - // logging 102 + // add attributes after creation 103 + span.setAttribute("result_count", @as(i64, 42)); 104 + 105 + // logging (console output only for now) 104 106 logfire.trace("detailed trace", .{}); 105 107 logfire.debug("debug info", .{}); 106 108 logfire.info("something happened", .{}); 107 109 logfire.warn("warning message", .{}); 108 110 logfire.err("error occurred", .{}); 109 - 110 - // metrics 111 - logfire.counter("requests.total", 1); 112 - logfire.gaugeInt("connections.active", 42); 113 - logfire.gaugeDouble("cpu.usage", 0.75); 114 111 115 112 // manual flush 116 113 try lf.flush(); ··· 138 135 139 136 ## Status 140 137 141 - This is an unofficial community SDK aiming for parity with [logfire-rust](https://github.com/pydantic/logfire-rust). Current status: 138 + This is an unofficial community SDK aiming for parity with [logfire-rust](https://github.com/pydantic/logfire-rust). Built on [otel-zig](https://github.com/open-telemetry/opentelemetry-zig). 142 139 143 140 - [x] Spans with attributes 144 - - [x] Structured logging (trace/debug/info/warn/err) 145 - - [x] Metrics (counter, gauge) 146 - - [x] OTLP HTTP/JSON export 141 + - [x] Parent-child span linking (thread-local context) 142 + - [x] OTLP HTTP/protobuf export 147 143 - [x] Environment-based configuration 148 - - [x] Batched async export (background flush thread) 149 - - [x] Parent-child span linking (thread-local) 150 - - [ ] Histograms (types implemented, no convenience API yet) 151 - - [ ] Protobuf encoding (JSON only) 144 + - [x] Cross-platform (macOS + Linux) 145 + - [ ] Structured logging export (console only, OTLP TODO) 146 + - [ ] Metrics (API stubs, implementation TODO) 152 147 - [ ] W3C trace context propagation (cross-service) 153 148 154 149 ## License