go-trace

module
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 15, 2023 License: Apache-2.0

README

go-trace

Lint CI Coverage Status Vulnerability Check Go Report Card

GitHub tag (latest by date) Go Reference license

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.

Directories

Path Synopsis
log
Package log exposes logging utilities based on go.uber.org/zap.
Package log exposes logging utilities based on go.uber.org/zap.
Package tracer starts an opencensus span with a logger automatically signed with the current calling function.
Package tracer starts an opencensus span with a logger automatically signed with the current calling function.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL