otocadapter

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 2, 2020 License: MIT Imports: 11 Imported by: 0

README

gRPC OpenTracing to OpenCensus Adapter

This adapter injects an OpenCensus span in the metadata of a gRPC call, which is extracted from an OpenTracing span.

If your project uses OpenTracing and you call a service via gRPC, which uses OpenCensus, this adapter makes the span available in the remote servie.

d, err := grpc.Dial("localhost:9080", grpc.WithInsecure(),
    grpc.WithUnaryInterceptor(otocadapter.OpenCensusAdapterClientInterceptor(tracer)),
)
if err != nil {
    logrus.Fatalln("Can't connect to DGraph:", err)
}
defer func() {
    d.Close()
    logrus.Info("Closed Dgraph connection...")
}()
dgraphClient := dgo.NewDgraphClient(api.NewDgraphClient(d))

Documentation

Overview

Package otocadapter provides an interceptor to inject a OpenCensus span, derived from an OpenTracing span, to send it over gRPC to a service, which uses OpenCensus for tracing.

This implementation assumes, Jaeger tracing implementation is used.

Package otocadapter provides

Index

Constants

View Source
const (
	OPENCENSUS_TRACE_KEY = "grpc-trace-bin"
)
View Source
const (
	OPENTRACING_TRACE_ID_LENGTH = 8
)

Variables

View Source
var (
	ErrOTTraceIDLen = errors.New("expected OpenTracing trace ID with 8 bytes")
)

Functions

func OpenCensusAdapterClientInterceptor

func OpenCensusAdapterClientInterceptor(tracer opentracing.Tracer) grpc.UnaryClientInterceptor

OpenCensusAdapterClientInterceptor injects a OpenTracing span in an OpenCensus format into the context.

func OpenTracingSpanIDToOpenCensusSpanID

func OpenTracingSpanIDToOpenCensusSpanID(otSpanID jaeger.SpanID) trace.SpanID

Convert an OpenTracing SpanID to an OpenCensus SpanID.

func OpenTracingTracIDToOpenCensusTraceID

func OpenTracingTracIDToOpenCensusTraceID(otTraceID jaeger.TraceID) (trace.TraceID, error)

Convert an OpenTracing TraceID to an OpenCensus TraceID.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL