otgrpc

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2021 License: MIT Imports: 13 Imported by: 0

README

otgrpc

OpenTracing plugin for grpc.

Usage

Server
package main

import (
	"github.com/yuewokeji/opentracing-go-plugins/module/otgrpc"
	"google.golang.org/grpc"
	"net"
)

func main() {
	lis, err := net.Listen("tcp", ":8080")
	if err != nil {
		panic(err)
	}

	server := grpc.NewServer(
		grpc.UnaryInterceptor(otgrpc.NewUnaryServerInterceptor()),
	)

	if err := server.Serve(lis); err != nil {
		panic(err)
	}
}

Client
package main

import (
	"github.com/yuewokeji/opentracing-go-plugins/module/otgrpc"
	"google.golang.org/grpc"
)

func main() {
	// ...
	conn, err := grpc.Dial(":8080", grpc.WithUnaryInterceptor(
		otgrpc.NewUnaryClientInterceptor(),
	))

	// do something
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ComponentTag = opentracing.Tag{Key: string(ext.Component), Value: "grpc " + grpc.Version}
)

Functions

func GetPeerAddr

func GetPeerAddr(ctx context.Context) string

func NewUnaryClientInterceptor

func NewUnaryClientInterceptor(options ...ClientOption) grpc.UnaryClientInterceptor

func NewUnaryServerInterceptor

func NewUnaryServerInterceptor(options ...ServerOption) grpc.UnaryServerInterceptor

Types

type ClientOption

type ClientOption func(*clientOptions)

func WithClientTracer

func WithClientTracer(tracer opentracing.Tracer) ClientOption

type MDReaderWriter

type MDReaderWriter struct {
	metadata.MD
}

func (MDReaderWriter) ForeachKey

func (m MDReaderWriter) ForeachKey(handler func(key, val string) error) error

func (MDReaderWriter) Set

func (m MDReaderWriter) Set(key, val string)

type RequestIgnorerFunc

type RequestIgnorerFunc func(*grpc.UnaryServerInfo) bool

type ServerOption

type ServerOption func(*serverOptions)

func WithServerRequestIgnorer

func WithServerRequestIgnorer(r RequestIgnorerFunc) ServerOption

func WithServerTracer

func WithServerTracer(tracer opentracing.Tracer) ServerOption

Jump to

Keyboard shortcuts

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