Socket
Book a DemoInstallSign in
Socket

grpc_interceptors

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

grpc_interceptors

0.1.5
bundlerRubygems
Version published
Maintainers
1
Created
Source

ruby-grpc-interceptors

A collection of Ruby interceptors (middlewares) for gRPC servers and clients.

Heavily inspired by grpc-ecosystem/go-grpc-middleware. The motivation is to have a unified behavior of gRPC services and integrated telemetry data (logging, tracing and metrics) regardless of the used language.

Contents

Server

The order of interceptors matters. Considering all server interceptors, the correct way of installation is:

Error handling

WIP

Logging

When the LOG_LEVEL env variable is set to INFO then the server logs out.

When the LOG_LEVEL env variable is set to DEBUG then the server additionally adds the request to the log message. (Note, adding the response is currently blocked by this gRPC issue.)

StatsD metrics

GRPC::RpcServer.new(
  interceptors: [
    GrpcInterceptors::Server::StatsDMetrics.new
  ]
)

The server emits a histogram metric called grpc_latency_seconds with the following tags:

  • grpc_method representing the called method
  • grpc_service representing the service
  • grpc_type representing the gRPC kind of method

[Experimental] A gauge metric of the server jobs queue

# https://github.com/grpc/grpc/blob/v1.62.0/src/ruby/lib/grpc/generic/rpc_server.rb#L43C9-L43C21
server.instance_variable_get(:@pool).jobs_waiting

OpenTelemetry tracing

GRPC::RpcServer.new(
  interceptors: [
    GrpcInterceptors::Server::OpenTelemetryTracingInstrument.new
  ]
)

Client

Logging

OpenTelemetry tracing

GRPC::RpcServer.new(
  interceptors: [
    GrpcInterceptors::Client::OpenTelemetryTracingInstrument.new
  ]
)

Development

Integration tests

Integration tests require some infrastructure to mimic gRPC client and server. For this purpose, there's a simple service definition in the test/integration/support/ping.proto. To re-generate *_pb.rb files run bundle exec rake proto:generate.

Releasing

bundle exec rake build
bundle exec rake release

FAQs

Package last updated on 07 Mar 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.