Skip to content

Latest commit

 

History

History
45 lines (31 loc) · 1.32 KB

File metadata and controls

45 lines (31 loc) · 1.32 KB

Instana instrumentation for github.com/sirupsen/logrus

This module contains instrumentation code for github.com/sirupsen/logrus logger.

PkgGoDev

Installation

To add the module to your go.mod file run the following command in your project directory:

$ go get github.com/instana/go-sensor/instrumentation/instalogrus

Usage

The instalogrus.NewHook() collects any warning or errors logged with logrus.Logger, associates them with the current span and sends to Instana.

// Create a collector
collector := instana.InitCollector(&instana.Options{
	Service: "my-web-server",
	Tracer:  instana.DefaultTracerOptions(),
})

// Register the instalogrus hook
logrus.AddHook(instalogrus.NewHook(collector))

// ...

// Make sure that you provide context.Context while logging so that
// the hook could corellate log records to operations:
logrus.WithContext(ctx).
	Error("something went wrong")

Full example