Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/maksim-paskal/logrus-hook-opentracing
https://github.com/maksim-paskal/logrus-hook-opentracing
Last synced: 5 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/maksim-paskal/logrus-hook-opentracing
- Owner: maksim-paskal
- License: apache-2.0
- Created: 2021-01-06T08:37:06.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2023-02-25T07:19:02.000Z (almost 2 years ago)
- Last Synced: 2024-05-19T00:37:18.192Z (8 months ago)
- Language: Go
- Size: 17.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## installation
```
go get github.com/maksim-paskal/logrus-hook-opentracing
```## environment
```bash
export JAEGER_AGENT_HOST=localhost
export JAEGER_AGENT_PORT=6831
```
## usage```go
package mainimport (
"errors"logrushookopentracing "github.com/maksim-paskal/logrus-hook-opentracing"
log "github.com/sirupsen/logrus"
"github.com/uber/jaeger-client-go"
jaegercfg "github.com/uber/jaeger-client-go/config"
"github.com/uber/jaeger-lib/metrics"
)var ErrTest error = errors.New("test error")
func main() {
hook, err := logrushookopentracing.NewHook(logrushookopentracing.Options{})
if err != nil {
log.WithError(err).Fatal()
}log.AddHook(hook)
cfg, err := jaegercfg.FromEnv()
if err != nil {
log.WithError(err).Panic("Could not parse Jaeger env vars")
}cfg.ServiceName = "test-app"
cfg.Sampler.Type = jaeger.SamplerTypeConst
cfg.Sampler.Param = 1
cfg.Reporter.LogSpans = truejMetricsFactory := metrics.NullFactory
tracer, closer, err := cfg.NewTracer(
jaegercfg.Metrics(jMetricsFactory),
)
if err != nil {
log.WithError(err).Panic("Could not create tracer")
}
defer closer.Close()span := tracer.StartSpan("main")
defer span.Finish()log.Info("test info")
log.Warn("test warn")
log.WithField(logrushookopentracing.SpanKey, span).WithError(ErrTest).Error("test error")
}
```