package ocgrpc

Import Path
	go.opencensus.io/plugin/ocgrpc (on go.dev)

Dependency Relation
	imports 16 packages, and imported by 2 packages

Involved Source Files client.go client_metrics.go client_stats_handler.go Package ocgrpc contains OpenCensus stats and trace integrations for gRPC. Use ServerHandler for servers and ClientHandler for clients. server.go server_metrics.go server_stats_handler.go stats_common.go trace_common.go
Code Examples package main import ( "go.opencensus.io/plugin/ocgrpc" "go.opencensus.io/stats/view" "google.golang.org/grpc" "log" ) func main() { // Register views to collect data. if err := view.Register(ocgrpc.DefaultClientViews...); err != nil { log.Fatal(err) } // Set up a connection to the server with the OpenCensus // stats handler to enable stats and tracing. conn, err := grpc.Dial("address", grpc.WithStatsHandler(&ocgrpc.ClientHandler{})) if err != nil { log.Fatalf("did not connect: %v", err) } defer conn.Close() } package main import ( "go.opencensus.io/plugin/ocgrpc" "go.opencensus.io/stats/view" "google.golang.org/grpc" "log" ) func main() { // Register views to collect data. if err := view.Register(ocgrpc.DefaultServerViews...); err != nil { log.Fatal(err) } // Set up a new server with the OpenCensus // stats handler to enable stats and tracing. s := grpc.NewServer(grpc.StatsHandler(&ocgrpc.ServerHandler{})) _ = s // use s }
Package-Level Type Names (total 4, in which 2 are exported)
/* sort exporteds by: | */
ClientHandler implements a gRPC stats.Handler for recording OpenCensus stats and traces. Use with gRPC clients only. StartOptions allows configuring the StartOptions used to create new spans. StartOptions.SpanKind will always be set to trace.SpanKindClient for spans started by this handler. HandleConn exists to satisfy gRPC stats.Handler. HandleRPC implements per-RPC tracing and stats instrumentation. TagConn exists to satisfy gRPC stats.Handler. TagRPC implements per-RPC context management. *T : google.golang.org/grpc/stats.Handler
ServerHandler implements gRPC stats.Handler recording OpenCensus stats and traces. Use with gRPC servers. When installed (see Example), tracing metadata is read from inbound RPCs by default. If no tracing metadata is present, or if the tracing metadata is present but the SpanContext isn't sampled, then a new trace may be started (as determined by Sampler). IsPublicEndpoint may be set to true to always start a new trace around each RPC. Any SpanContext in the RPC metadata will be added as a linked span instead of making it the parent of the span created around the server RPC. Be aware that if you leave this false (the default) on a public-facing server, callers will be able to send tracing metadata in gRPC headers and trigger traces in your backend. StartOptions to use for to spans started around RPCs handled by this server. These will apply even if there is tracing metadata already present on the inbound RPC but the SpanContext is not sampled. This ensures that each service has some opportunity to be traced. If you would like to not add any additional traces for this gRPC service, set: StartOptions.Sampler = trace.ProbabilitySampler(0.0) StartOptions.SpanKind will always be set to trace.SpanKindServer for spans started by this handler. HandleConn exists to satisfy gRPC stats.Handler. HandleRPC implements per-RPC tracing and stats instrumentation. TagConn exists to satisfy gRPC stats.Handler. TagRPC implements per-RPC context management. *T : google.golang.org/grpc/stats.Handler
Package-Level Functions (total 8, none are exported)
Package-Level Variables (total 34, in which 33 are exported)
Predefined views may be registered to collect data for the above measures. As always, you may also define your own custom views over measures collected by this package. These are declared as a convenience only; none are registered by default.
The following variables are measures are recorded by ClientHandler:
Predefined views may be registered to collect data for the above measures. As always, you may also define your own custom views over measures collected by this package. These are declared as a convenience only; none are registered by default.
The following variables are measures are recorded by ClientHandler:
Predefined views may be registered to collect data for the above measures. As always, you may also define your own custom views over measures collected by this package. These are declared as a convenience only; none are registered by default.
The following variables are measures are recorded by ClientHandler:
Predefined views may be registered to collect data for the above measures. As always, you may also define your own custom views over measures collected by this package. These are declared as a convenience only; none are registered by default.
The following variables are measures are recorded by ClientHandler:
Predefined views may be registered to collect data for the above measures. As always, you may also define your own custom views over measures collected by this package. These are declared as a convenience only; none are registered by default.
The following variables are measures are recorded by ClientHandler:
Predefined views may be registered to collect data for the above measures. As always, you may also define your own custom views over measures collected by this package. These are declared as a convenience only; none are registered by default.
The following variables are measures are recorded by ClientHandler:
Predefined views may be registered to collect data for the above measures. As always, you may also define your own custom views over measures collected by this package. These are declared as a convenience only; none are registered by default.
The following variables define the default hard-coded auxiliary data used by both the default GRPC client and GRPC server metrics.
DefaultClientViews are the default client views provided by this package.
The following variables define the default hard-coded auxiliary data used by both the default GRPC client and GRPC server metrics.
The following variables define the default hard-coded auxiliary data used by both the default GRPC client and GRPC server metrics.
DefaultServerViews are the default server views provided by this package.
Client tags are applied to measures at the end of each RPC.
Client tags are applied to measures at the end of each RPC.
Server tags are applied to the context used to process each RPC, as well as the measures at the end of each RPC.
Server tags are applied to the context used to process each RPC, as well as the measures at the end of each RPC.
Predefined views may be registered to collect data for the above measures. As always, you may also define your own custom views over measures collected by this package. These are declared as a convenience only; none are registered by default.
The following variables are measures are recorded by ServerHandler:
Predefined views may be registered to collect data for the above measures. As always, you may also define your own custom views over measures collected by this package. These are declared as a convenience only; none are registered by default.
The following variables are measures are recorded by ServerHandler:
Predefined views may be registered to collect data for the above measures. As always, you may also define your own custom views over measures collected by this package. These are declared as a convenience only; none are registered by default.
The following variables are measures are recorded by ServerHandler:
Predefined views may be registered to collect data for the above measures. As always, you may also define your own custom views over measures collected by this package. These are declared as a convenience only; none are registered by default.
The following variables are measures are recorded by ServerHandler:
Predefined views may be registered to collect data for the above measures. As always, you may also define your own custom views over measures collected by this package. These are declared as a convenience only; none are registered by default.
The following variables are measures are recorded by ServerHandler:
Predefined views may be registered to collect data for the above measures. As always, you may also define your own custom views over measures collected by this package. These are declared as a convenience only; none are registered by default.
Package-Level Constants (only one, which is unexported)