opentracing

package module
v2.0.0-rc.3 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Example
package main

import (
	"google.golang.org/grpc"

	grpcopentracing "github.com/grpc-ecosystem/go-grpc-middleware/providers/opentracing/v2"

	"github.com/grpc-ecosystem/go-grpc-middleware/v2/interceptors/tracing"
)

func main() {
	_ = grpc.NewServer(
		grpc.ChainUnaryInterceptor(
			tracing.UnaryServerInterceptor(grpcopentracing.InterceptorTracer()),
		),
		grpc.ChainStreamInterceptor(
			tracing.StreamServerInterceptor(grpcopentracing.InterceptorTracer()),
		),
	)

	_, _ = grpc.Dial("",
		grpc.WithUnaryInterceptor(tracing.UnaryClientInterceptor(grpcopentracing.InterceptorTracer())),
		grpc.WithStreamInterceptor(tracing.StreamClientInterceptor(grpcopentracing.InterceptorTracer())),
	)
}
Output:

Index

Examples

Constants

View Source
const (
	TagTraceId = "trace.traceid"
	TagSpanId  = "trace.spanid"
	TagSampled = "trace.sampled"
)

Variables

This section is empty.

Functions

func ClientAddContextTags

func ClientAddContextTags(ctx context.Context, tags opentracing.Tags) context.Context

ClientAddContextTags returns a context with specified opentracing tags, which are used by UnaryClientInterceptor/StreamClientInterceptor when creating a new span.

func InterceptorTracer

func InterceptorTracer(opts ...Option) *tracer

InterceptorTracer converts OpenTracing tracer to Tracer adapter.

Types

type Option

type Option func(*options)

func WithTraceHeaderName

func WithTraceHeaderName(name string) Option

WithTraceHeaderName customizes the trace header name where trace metadata passed with requests. Default one is `uber-trace-id`

func WithTracer

func WithTracer(tracer opentracing.Tracer) Option

WithTracer sets a custom tracer to be used for this middleware, otherwise the opentracing.GlobalTracer is used.

Jump to

Keyboard shortcuts

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