Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SafeAttr ¶
Example (Bool) ¶
package main
import (
"fmt"
"github.com/SUNET/vc/pkg/trace"
)
func main() {
b := true
attr := trace.SafeAttr("enabled", &b)
fmt.Println(attr.Key)
fmt.Println(attr.Value.AsBool())
}
Output: enabled true
Example (Float64) ¶
package main
import (
"fmt"
"github.com/SUNET/vc/pkg/trace"
)
func main() {
f := 3.14
attr := trace.SafeAttr("pi", &f)
fmt.Println(attr.Key)
fmt.Println(attr.Value.AsFloat64())
}
Output: pi 3.14
Example (Int) ¶
package main
import (
"fmt"
"github.com/SUNET/vc/pkg/trace"
)
func main() {
n := 42
attr := trace.SafeAttr("count", &n)
fmt.Println(attr.Key)
fmt.Println(attr.Value.AsInt64())
}
Output: count 42
Example (Nil) ¶
package main
import (
"fmt"
"github.com/SUNET/vc/pkg/trace"
)
func main() {
attr := trace.SafeAttr("missing", nil)
fmt.Println(attr.Key)
}
Output: missing.unsupported
Example (String) ¶
package main
import (
"fmt"
"github.com/SUNET/vc/pkg/trace"
)
func main() {
s := "hello"
attr := trace.SafeAttr("greeting", &s)
fmt.Println(attr.Key)
fmt.Println(attr.Value.AsString())
}
Output: greeting hello
Example (StringSlice) ¶
package main
import (
"fmt"
"github.com/SUNET/vc/pkg/trace"
)
func main() {
vals := []string{"a", "b", "c"}
attr := trace.SafeAttr("tags", &vals)
fmt.Println(attr.Key)
fmt.Println(attr.Value.AsStringSlice())
}
Output: tags [a b c]
Types ¶
type Tracer ¶
type Tracer struct {
TP *sdktrace.TracerProvider
trace.Tracer
// contains filtered or unexported fields
}
Tracer is a wrapper for opentelemetry tracer
func NewForTesting ¶
NewForTesting return a new tracer for testing purpose without exporting the trace
Click to show internal directories.
Click to hide internal directories.