dd-trace-go.v1: gopkg.in/DataDog/dd-trace-go.v1/contrib/google.golang.org/grpc.v12 Index | Examples | Files

package grpc

import "gopkg.in/DataDog/dd-trace-go.v1/contrib/google.golang.org/grpc.v12"

Package grpc is a generated protocol buffer package.

It is generated from these files:

fixtures_test.proto

It has these top-level messages:

FixtureRequest
FixtureReply

Package grpc provides functions to trace the google.golang.org/grpc package v1.2.

Code:

// Create the client interceptor using the grpc trace package.
i := grpctrace.UnaryClientInterceptor(grpctrace.WithServiceName("my-grpc-client"))

// Dial in using the created interceptor...
conn, err := grpc.Dial("localhost:50051", grpc.WithInsecure(), grpc.WithUnaryInterceptor(i))
if err != nil {
    log.Fatal(err)
}
defer conn.Close()

// And continue using the connection as normal.

Code:

// Create a listener for the server.
ln, err := net.Listen("tcp", ":50051")
if err != nil {
    log.Fatal(err)
}

// Create the unary server interceptor using the grpc trace package.
i := grpctrace.UnaryServerInterceptor(grpctrace.WithServiceName("my-grpc-client"))

// Initialize the grpc server as normal, using the tracing interceptor.
s := grpc.NewServer(grpc.UnaryInterceptor(i))

// ... register your services

// Start serving incoming connections.
if err := s.Serve(ln); err != nil {
    log.Fatalf("failed to serve: %v", err)
}

Index

Examples

Package Files

fixtures_test.pb.go grpc.go option.go tags.go

func RegisterFixtureServer Uses

func RegisterFixtureServer(s *grpc1.Server, srv FixtureServer)

func UnaryClientInterceptor Uses

func UnaryClientInterceptor(opts ...InterceptorOption) grpc.UnaryClientInterceptor

UnaryClientInterceptor will add tracing to a gprc client.

func UnaryServerInterceptor Uses

func UnaryServerInterceptor(opts ...InterceptorOption) grpc.UnaryServerInterceptor

UnaryServerInterceptor will trace requests to the given grpc server.

type FixtureClient Uses

type FixtureClient interface {
    Ping(ctx context.Context, in *FixtureRequest, opts ...grpc1.CallOption) (*FixtureReply, error)
}

func NewFixtureClient Uses

func NewFixtureClient(cc *grpc1.ClientConn) FixtureClient

type FixtureReply Uses

type FixtureReply struct {
    Message string `protobuf:"bytes,1,opt,name=message" json:"message,omitempty"`
}

The response message containing the greetings

func (*FixtureReply) Descriptor Uses

func (*FixtureReply) Descriptor() ([]byte, []int)

func (*FixtureReply) GetMessage Uses

func (m *FixtureReply) GetMessage() string

func (*FixtureReply) ProtoMessage Uses

func (*FixtureReply) ProtoMessage()

func (*FixtureReply) Reset Uses

func (m *FixtureReply) Reset()

func (*FixtureReply) String Uses

func (m *FixtureReply) String() string

type FixtureRequest Uses

type FixtureRequest struct {
    Name string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"`
}

The request message containing the user's name.

func (*FixtureRequest) Descriptor Uses

func (*FixtureRequest) Descriptor() ([]byte, []int)

func (*FixtureRequest) GetName Uses

func (m *FixtureRequest) GetName() string

func (*FixtureRequest) ProtoMessage Uses

func (*FixtureRequest) ProtoMessage()

func (*FixtureRequest) Reset Uses

func (m *FixtureRequest) Reset()

func (*FixtureRequest) String Uses

func (m *FixtureRequest) String() string

type FixtureServer Uses

type FixtureServer interface {
    Ping(context.Context, *FixtureRequest) (*FixtureReply, error)
}

type InterceptorOption Uses

type InterceptorOption func(*interceptorConfig)

InterceptorOption represents an option that can be passed to the grpc unary client and server interceptors.

func WithAnalytics Uses

func WithAnalytics(on bool) InterceptorOption

WithAnalytics enables Trace Analytics for all started spans.

func WithAnalyticsRate Uses

func WithAnalyticsRate(rate float64) InterceptorOption

WithAnalyticsRate sets the sampling rate for Trace Analytics events correlated to started spans.

func WithServiceName Uses

func WithServiceName(name string) InterceptorOption

WithServiceName sets the given service name for the intercepted client.

Package grpc imports 14 packages (graph) and is imported by 1 packages. Updated 2020-08-05. Refresh now. Tools for package owners.