go-trace
Logging & tracing utilities for micro services.
Based on:
go.uber.org/zap
go.opencensus.io/trace
Tested to be compatible wih Datadog tracing.
Logging
The main idea is to unify logging and tracing, and insulate the app layer from the intricacies of tracing.
This repo provides a few wrappers around a zap.Logger:
- a logger factory based on zap logger, with a convenient builder to link logs to trace spans
- a logger builder, e.g. to initialize a root logger for your service
- a simple middleware to trace a
http.Handler
Exporters
Various opencensus exporters.
- influxdb: export opencensus metrics to an influxdb sink
- amplitude (experimental): propagate trace event to the amplitude API
TODOs:
- [] opentelemetry/opentracing
Tracing
Simple utilities to instrument tracing inside apps.
Example Usage
Middleware
log/middleware/LogRequests
logs all requests from a http server, using the logger factory
tracer.Middleware
wraps the ochttp
opencensus plugin in a more convenient middleware.
Credits
Much inspired by prior art from @casualjim. Thanks so much.