How jinkoso/jinko-observability works
jinko-observability is a shared Go library that standardizes logging, trace context, identity baggage, HTTP instrumentation, and async-job trace continuity for Jinko services. Its principal workflow configures OpenTelemetry, instruments inbound requests, carries identity and trace context through internal HTTP calls, and correlates logs with active spans; outbound third-party calls retain tracing but strip baggage. Async jobs use a separate inject/enqueue/extract flow. The README documents these capabilities; some subsystem internals were not sampled, so their paths and wiring are limited to evidence in the tree and documentation.
Main entry points: telemetry.go Telemetry setup · logger.go Logger · jobs.go Job propagation · baggage.go Identity baggage
Components 19
Shared conventions
- Conventions
pkg/conventions - Baggage keys
pkg/conventions/baggage.go - Environment rules
pkg/conventions/environment.go
Trace context
- Telemetry setup
pkg/telemetry/telemetry.go - Identity baggage
pkg/telemetry/baggage.go - Baggage span copy
pkg/telemetry/telemetry.go
HTTP instrumentation
- Gin middleware
pkg/httpx/server.go - Traced client
pkg/httpx/client.go - External client
pkg/httpx/client.go
Logs and jobs
- Logger
pkg/logger/logger.go - Zap backend
pkg/logger/zap.go - Trace log fields
pkg/logger/trace.go - Job propagation
pkg/jobs/jobs.go
Other components
- Go service
- OTLP collector
- Internal service
- Third-party API
- Async job queue
- Job worker
Connections 21
- Go service → Telemetry setup: initializes
- Telemetry setup → Environment rules: validates
- Telemetry setup → Baggage span copy: configures
- Telemetry setup → OTLP collector: exports traces
- Go service → Gin middleware: installs middleware
- Gin middleware → Go service: provides request context
- Go service → Identity baggage: sets identity
- Identity baggage → Baggage keys: uses keys
- Baggage span copy → Baggage keys: promotes prefixes
- Go service → Traced client: makes internal calls
- Traced client → Internal service: propagates trace and baggage
- Go service → External client: makes vendor calls
- External client → Third-party API: sends trace; strips baggage
- Go service → Logger: emits logs
- Logger → Trace log fields: adds span IDs
- Logger → Zap backend: writes structured logs
- Go service → Job propagation: injects trace carrier
- Job propagation → Go service: returns carrier
- Go service → Async job queue: enqueues carrier
- Async job queue → Job worker: delivers job
- Job worker → Job propagation: extracts carrier