package grpc
import "go.opencensus.io/plugin/grpc"
Package grpc contains OpenCensus stats and trace integrations with gRPC.
Index ¶
Examples ¶
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.
Code:play
Example¶
package main
import (
"log"
ocgrpc "go.opencensus.io/plugin/grpc"
"go.opencensus.io/plugin/grpc/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.
Code:play
Example¶
package main
import (
"log"
ocgrpc "go.opencensus.io/plugin/grpc"
"go.opencensus.io/plugin/grpc/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
}
Source Files ¶
grpc.go
Directories ¶
Path | Synopsis |
---|---|
plugin/grpc/grpcstats | Package grpcstats provides OpenCensus stats support for gRPC clients and servers. |
plugin/grpc/grpctrace | Package grpctrace is a package to assist with tracing incoming and outgoing gRPC requests. |
- Version
- v0.1.0
- Published
- Dec 15, 2017
- Platform
- js/wasm
- Imports
- 4 packages
- Last checked
- 44 minutes ago –
Tools for package owners.