Skip to content

kazegusuri/grpcinstrument

 
 

Repository files navigation

grpcinstrument

This is a golang package that helps instrumenting gRPC servers. It includes a Protocol Buffer compiler plugin for generating code that wraps and instruments gRPC servers and an implementation of the Instrumentator interface that logs requests to any of the backends supported by protolog and exposes metrics about RPC calls via Prometheus.

Read the documentation online or install this package and read it locally:

$ go get github.com/sr/grpcinstrument/...
$ godoc github.com/sr/grpcinstrument

Assuming your proto files are located under src/, invoke the protoc command like so:

$ protoc --grpcinstrument_out=src/ src/*.proto
$ ls src/*-gen.go
src/instrumented_buildkite-gen.go

Then update your main package to use the generated instrumented code:

--- a.go        2015-12-15 13:01:03.307634424 +0000
+++ b.go        2015-12-15 13:00:40.386861334 +0000
@@ -1,3 +1,5 @@
 server := grpc.NewServer()
+instrumentator := myapp.NewInstrumentator()
 buildkiteServer, := buildkite.NewAPIServer()
-buildkite.RegisterBuildkiteServiceServer(server, buildkiteServer)
+instrumented := buildkite.NewInstrumentedBuildkiteServiceServer(instrumentator, buildkiteServer)
+buildkite.RegisterBuildkiteServiceServer(server, instrumented)

Checkout the example directory to see what the generated code looks like.

About

Golang package for instrumenting gRPC servers

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 86.7%
  • Makefile 11.6%
  • Protocol Buffer 1.7%