commit | 8b06e3503bc5cd9b6c48866619a29ccbedb3ea36 | [log] [tgz] |
---|---|---|
author | wahidw <abdulwahid.w@nokia.com> | Mon Aug 31 23:18:47 2020 +0530 |
committer | wahidw <abdulwahid.w@nokia.com> | Mon Aug 31 23:18:50 2020 +0530 |
tree | 99a627ec9e301ac2fdda446b8264feef0d3410a1 | |
parent | aa241eea7ec9f79bd4aaab918336576b12922d7d [diff] |
Documentation for tracelibgo Change-Id: I213867deeea7ccffa5fdce596148eb0bf43d1703 Signed-off-by: wahidw <abdulwahid.w@nokia.com>
The library creates a configured tracer instance.
Create a tracer instance and set it as a global tracer:
import (
"github.com/opentracing/opentracing-go"
"gerrit.o-ran-sc.org/ric-plt/tracelibgo/pkg/tracelibgo"
...
)
tracer, closer := tracelibgo.CreateTracer("my-service-name")
defer closer.Close()
opentracing.SetGlobalTracer(tracer)
Serialize span context to a byte array that can be sent to another component via some messaging. For example, using the RMR library. The serialization uses JSON format.
carrier := make(map[string]string) opentracing.GlobalTracer().Inject( span.Context(), opentracing.TextMap, opentracing.TextMapCarrier(carrier)) b, err := json.Marshal(carrier) // b is a []byte and contains serilized span context
Extract a span context from byte array and create a new child span from it. The serialized span context is got, for example, from the RMR library.
var carrier map[string]string err = json.Unmarshal(data, &carrier) // data is []byte containing serialized span context if err != nil { ... } context, err := opentracing.GlobalTracer().Extract(opentracing.TextMap, opentracing.TextMapCarrier(carrier)) if err != nil { ... } span := opentracing.GlobalTracer().StartSpan("go test span", opentracing.ChildOf(context))
The trace library currently supports only Jaeger golang client tracer implementation. The configuration is done using environment variables:
environment variable | values | default |
---|---|---|
TRACING_ENABLED | 1, true, 0, false | false |
TRACING_JAEGER_SAMPLER_TYPE | const, propabilistic, ratelimiting | const |
TRACING_JAEGER_SAMPLER_PARAM | float | 0.001 |
TRACING_JAEGER_AGENT_ADDR | IP addr[:port] | 127.0.0.1:6831 |
TRACING_JAEGER_LOG_LEVEL | all, error, none | none |
Meaning of the configuration variables is described in Jaeger web pages. By default a no-op tracer is created.
GO111MODULE=on go mod download go test ./pkg/tracelibgo
See LICENSES.txt file.