帮酷LOGO
0 0 评论
文章标签:监视器  监视  grpc  Server  Monit  
Prometheus monitoring for your gRPC Go servers.

  • 源代码名称:go-grpc-prometheus
  • 源代码网址:http://www.github.com/grpc-ecosystem/go-grpc-prometheus
  • go-grpc-prometheus源代码文档
  • go-grpc-prometheus源代码下载
  • Git URL:
    git://www.github.com/grpc-ecosystem/go-grpc-prometheus.git
  • Git Clone代码到本地:
    git clone http://www.github.com/grpc-ecosystem/go-grpc-prometheus
  • Subversion代码到本地:
    $ svn co --depth empty http://www.github.com/grpc-ecosystem/go-grpc-prometheus
    Checked out revision 1.
    $ cd repo
    $ svn up trunk
    
  • Travis BuildGo Report CardGoDocSourceGraphcodecovApache 2.0 License

    你的grpC Go服务器和客户端的Prometheus监视。

    拦截器

    gRPC Go最近获得了对拦截器的支持,这是实现通用模式的完美方法: 认证,日志记录和..监测。

    要在chain中使用拦截器,请用go-grpc-middleware 。

    用法

    有两种类型的拦截器: 客户端和服务器端,此软件包为两个。

    服务器端

    import"github.com/grpc-ecosystem/go-grpc-prometheus"...
     // Initialize your gRPC server's interceptor.myServer:= grpc.NewServer(
     grpc.StreamInterceptor(grpc_prometheus.StreamServerInterceptor),
     grpc.UnaryInterceptor(grpc_prometheus.UnaryServerInterceptor),
     )
     // Register your gRPC service implementations. myservice.RegisterMyServiceServer(s.server, &myServiceImpl{})
     // After all your registrations, make sure all of the Prometheus metrics are initialized. grpc_prometheus.Register(myServer)
     // Register Prometheus metrics handler.  http.Handle("/metrics", promhttp.Handler())
    ...

    客户端

    import"github.com/grpc-ecosystem/go-grpc-prometheus"...
     clientConn, err = grpc.Dial(
     address,
     grpc.WithUnaryInterceptor(grpc_prometheus.UnaryClientInterceptor),
     grpc.WithStreamInterceptor(grpc_prometheus.StreamClientInterceptor)
     )
     client = pb_testproto.NewTestServiceClient(clientConn)
     resp, err:= client.PingEmpty(s.ctx, &myservice.Request{Msg: "hello"})
    ...


    文章标签:Server  监视器  Monit  监视  grpc  

    Copyright © 2011 HelpLib All rights reserved.    知识分享协议 京ICP备05059198号-3  |  如果智培  |  酷兔英语