Documentation ¶
Overview ¶
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.
Example (Client) ¶
package main import ( "log" grpctrace "gopkg.in/DataDog/dd-trace-go.v1/contrib/google.golang.org/grpc" "google.golang.org/grpc" ) func main() { // Create the client interceptor using the grpc trace package. si := grpctrace.StreamClientInterceptor(grpctrace.WithServiceName("my-grpc-client")) ui := grpctrace.UnaryClientInterceptor(grpctrace.WithServiceName("my-grpc-client")) // Dial in using the created interceptor... conn, err := grpc.Dial("localhost:50051", grpc.WithInsecure(), grpc.WithStreamInterceptor(si), grpc.WithUnaryInterceptor(ui)) if err != nil { log.Fatal(err) } defer conn.Close() // And continue using the connection as normal. }
Output:
Example (Server) ¶
package main import ( "log" "net" grpctrace "gopkg.in/DataDog/dd-trace-go.v1/contrib/google.golang.org/grpc" "google.golang.org/grpc" ) func main() { // Create a listener for the server. ln, err := net.Listen("tcp", ":50051") if err != nil { log.Fatal(err) } // Create the server interceptor using the grpc trace package. si := grpctrace.StreamServerInterceptor(grpctrace.WithServiceName("my-grpc-client")) ui := grpctrace.UnaryServerInterceptor(grpctrace.WithServiceName("my-grpc-client")) // Initialize the grpc server as normal, using the tracing interceptor. s := grpc.NewServer(grpc.StreamInterceptor(si), grpc.UnaryInterceptor(ui)) // ... register your services // Start serving incoming connections. if err := s.Serve(ln); err != nil { log.Fatalf("failed to serve: %v", err) } }
Output:
Index ¶
- func NewClientStatsHandler(opts ...Option) stats.Handler
- func NewServerStatsHandler(opts ...Option) stats.Handler
- func RegisterFixtureServer(s *grpc1.Server, srv FixtureServer)
- func StreamClientInterceptor(opts ...Option) grpc.StreamClientInterceptor
- func StreamServerInterceptor(opts ...Option) grpc.StreamServerInterceptor
- func UnaryClientInterceptor(opts ...Option) grpc.UnaryClientInterceptor
- func UnaryServerInterceptor(opts ...Option) grpc.UnaryServerInterceptor
- type FixtureClient
- type FixtureReply
- type FixtureRequest
- type FixtureServer
- type Fixture_StreamPingClient
- type Fixture_StreamPingServer
- type InterceptorOption
- type Option
- func NoDebugStack() Option
- func WithAnalytics(on bool) Option
- func WithAnalyticsRate(rate float64) Option
- func WithIgnoredMetadata(ms ...string) Option
- func WithIgnoredMethods(ms ...string) Option
- func WithMetadataTags() Option
- func WithRequestTags() Option
- func WithServiceName(name string) Option
- func WithStreamCalls(enabled bool) Option
- func WithStreamMessages(enabled bool) Option
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewClientStatsHandler ¶ added in v1.11.0
NewClientStatsHandler returns a gRPC client stats.Handler to trace RPC calls.
func NewServerStatsHandler ¶ added in v1.11.0
NewServerStatsHandler returns a gRPC server stats.Handler to trace RPC calls.
func RegisterFixtureServer ¶ added in v1.0.0
func RegisterFixtureServer(s *grpc1.Server, srv FixtureServer)
func StreamClientInterceptor ¶ added in v1.1.0
func StreamClientInterceptor(opts ...Option) grpc.StreamClientInterceptor
StreamClientInterceptor returns a grpc.StreamClientInterceptor which will trace client streams using the given set of options.
func StreamServerInterceptor ¶ added in v1.1.0
func StreamServerInterceptor(opts ...Option) grpc.StreamServerInterceptor
StreamServerInterceptor will trace streaming requests to the given gRPC server.
func UnaryClientInterceptor ¶
func UnaryClientInterceptor(opts ...Option) grpc.UnaryClientInterceptor
UnaryClientInterceptor returns a grpc.UnaryClientInterceptor which will trace requests using the given set of options.
func UnaryServerInterceptor ¶
func UnaryServerInterceptor(opts ...Option) grpc.UnaryServerInterceptor
UnaryServerInterceptor will trace requests to the given grpc server.
Types ¶
type FixtureClient ¶ added in v1.0.0
type FixtureClient interface { Ping(ctx context.Context, in *FixtureRequest, opts ...grpc1.CallOption) (*FixtureReply, error) StreamPing(ctx context.Context, opts ...grpc1.CallOption) (Fixture_StreamPingClient, error) }
func NewFixtureClient ¶ added in v1.0.0
func NewFixtureClient(cc *grpc1.ClientConn) FixtureClient
type FixtureReply ¶ added in v1.0.0
type FixtureReply struct {
Message string `protobuf:"bytes,1,opt,name=message" json:"message,omitempty"`
}
The response message containing the greetings
func (*FixtureReply) Descriptor ¶ added in v1.0.0
func (*FixtureReply) Descriptor() ([]byte, []int)
func (*FixtureReply) GetMessage ¶ added in v1.0.0
func (m *FixtureReply) GetMessage() string
func (*FixtureReply) ProtoMessage ¶ added in v1.0.0
func (*FixtureReply) ProtoMessage()
func (*FixtureReply) Reset ¶ added in v1.0.0
func (m *FixtureReply) Reset()
func (*FixtureReply) String ¶ added in v1.0.0
func (m *FixtureReply) String() string
type FixtureRequest ¶ added in v1.0.0
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 ¶ added in v1.0.0
func (*FixtureRequest) Descriptor() ([]byte, []int)
func (*FixtureRequest) GetName ¶ added in v1.0.0
func (m *FixtureRequest) GetName() string
func (*FixtureRequest) ProtoMessage ¶ added in v1.0.0
func (*FixtureRequest) ProtoMessage()
func (*FixtureRequest) Reset ¶ added in v1.0.0
func (m *FixtureRequest) Reset()
func (*FixtureRequest) String ¶ added in v1.0.0
func (m *FixtureRequest) String() string
type FixtureServer ¶ added in v1.0.0
type FixtureServer interface { Ping(context.Context, *FixtureRequest) (*FixtureReply, error) StreamPing(Fixture_StreamPingServer) error }
type Fixture_StreamPingClient ¶ added in v1.1.0
type Fixture_StreamPingClient interface { Send(*FixtureRequest) error Recv() (*FixtureReply, error) grpc1.ClientStream }
type Fixture_StreamPingServer ¶ added in v1.1.0
type Fixture_StreamPingServer interface { Send(*FixtureReply) error Recv() (*FixtureRequest, error) grpc1.ServerStream }
type InterceptorOption ¶ added in v1.0.0
type InterceptorOption = Option
InterceptorOption represents an option that can be passed to the grpc unary client and server interceptors. InterceptorOption is deprecated in favor of Option.
func NonErrorCodes ¶ added in v1.12.0
func NonErrorCodes(cs ...codes.Code) InterceptorOption
NonErrorCodes determines the list of codes which will not be considered errors in instrumentation. This call overrides the default handling of codes.Canceled as a non-error.
type Option ¶ added in v1.11.0
type Option func(*config)
Option specifies a configuration option for the grpc package. Not all options apply to all instrumented structures.
func NoDebugStack ¶ added in v1.5.0
func NoDebugStack() Option
NoDebugStack disables debug stacks for traces with errors. This is useful in situations where errors are frequent and the overhead of calling debug.Stack may affect performance.
func WithAnalytics ¶ added in v1.11.0
WithAnalytics enables Trace Analytics for all started spans.
func WithAnalyticsRate ¶ added in v1.11.0
WithAnalyticsRate sets the sampling rate for Trace Analytics events correlated to started spans.
func WithIgnoredMetadata ¶ added in v1.31.0
WithIgnoredMetadata specifies keys to be ignored while tracing the metadata. Must be used in conjunction with WithMetadataTags.
func WithIgnoredMethods ¶ added in v1.24.0
WithIgnoredMethods specifies full methods to be ignored by the server side interceptor. When an incoming request's full method is in ms, no spans will be created.
func WithMetadataTags ¶ added in v1.31.0
func WithMetadataTags() Option
WithMetadataTags specifies whether gRPC metadata should be added to spans as tags.
func WithRequestTags ¶ added in v1.31.0
func WithRequestTags() Option
WithRequestTags specifies whether gRPC requests should be added to spans as tags.
func WithServiceName ¶ added in v1.0.0
WithServiceName sets the given service name for the intercepted client.
func WithStreamCalls ¶ added in v1.1.0
WithStreamCalls enables or disables tracing of streaming calls. This option does not apply to the stats handler.
func WithStreamMessages ¶ added in v1.1.0
WithStreamMessages enables or disables tracing of streaming messages. This option does not apply to the stats handler.