Debian Codegraph @

examples/dapperish/trivialrecorder.go

raw symbols SCIP
1 package dapperish
2
3 import (
4 "fmt"
5
6 "github.com/opentracing/basictracer-go"
7 )
8
9 // TrivialRecorder implements the basictracer.SpanRecorder interface.
10 type TrivialRecorder struct {
11 processName string
12 tags map[string]string
13 }
14
15 // NewTrivialRecorder returns a TrivialRecorder for the given `processName`.
16 func NewTrivialRecorder(processName string) *TrivialRecorder {
17 return &TrivialRecorder{
18 processName: processName,
19 tags: make(map[string]string),
20 }
21 }
22
23 // ProcessName returns the process name.
24 func (t *TrivialRecorder) ProcessName() string { return t.processName }
25
26 // SetTag sets a tag.
27 func (t *TrivialRecorder) SetTag(key string, val interface{}) *TrivialRecorder {
28 t.tags[key] = fmt.Sprint(val)
29 return t
30 }
31
32 // RecordSpan complies with the basictracer.Recorder interface.
33 func (t *TrivialRecorder) RecordSpan(span basictracer.RawSpan) {
34 fmt.Printf(
35 "RecordSpan: %v[%v, %v us] --> %v logs. context: %v; baggage: %v\n",
36 span.Operation, span.Start, span.Duration, len(span.Logs),
37 span.Context, span.Context.Baggage)
38 for i, l := range span.Logs {
39 fmt.Printf(
40 " log %v @ %v: %v\n", i, l.Timestamp, l.Fields)
41 }
42 }