This module contains instrumentation code for github.com/sirupsen/logrus logger.
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/instalogrusThe 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")