Documentation
¶
Overview ¶
Package ocgrpc contains OpenCensus stats and trace integrations with gRPC.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewClientStatsHandler ¶
NewClientStatsHandler enables OpenCensus stats and trace for gRPC clients. If these features need to be indiviually turned on, see grpcstats and grpctrace packages.
Example ¶
package main
import (
"log"
"go.opencensus.io/plugin/ocgrpc"
"go.opencensus.io/plugin/ocgrpc/grpcstats"
"google.golang.org/grpc"
)
func main() {
// Subscribe to collect client request count.
if err := grpcstats.RPCClientRequestCountView.Subscribe(); 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.NewClientStatsHandler()))
if err != nil {
log.Fatalf("did not connect: %v", err)
}
defer conn.Close()
}
func NewServerStatsHandler ¶
NewServerStatsHandler enables OpenCensus stats and trace for gRPC servers. If these features need to be indiviually turned on, see grpcstats and grpctrace packages.
Example ¶
package main
import (
"log"
"go.opencensus.io/plugin/ocgrpc"
"go.opencensus.io/plugin/ocgrpc/grpcstats"
"google.golang.org/grpc"
)
func main() {
// Subscribe to collect server request count.
if err := grpcstats.RPCServerRequestCountView.Subscribe(); 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.NewServerStatsHandler()))
_ = s // use s
}
Types ¶
This section is empty.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package grpcstats provides OpenCensus stats support for gRPC clients and servers.
|
Package grpcstats provides OpenCensus stats support for gRPC clients and servers. |
|
Package grpctrace is a package to assist with tracing incoming and outgoing gRPC requests.
|
Package grpctrace is a package to assist with tracing incoming and outgoing gRPC requests. |
Click to show internal directories.
Click to hide internal directories.