gRPC service utilities providing health checking, server reflection, channelz observability, and binary logging capabilities
npx @tessl/cli install tessl/maven-io-grpc--grpc-services@1.73.0gRPC Services is a comprehensive Java library that provides essential service utilities and implementations for gRPC applications. It includes health checking, server reflection, channelz observability, binary logging, and metrics recording capabilities for building production-ready gRPC servers.
pom.xml or build.gradleMaven:
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-services</artifactId>
<version>1.73.0</version>
</dependency>Gradle:
implementation 'io.grpc:grpc-services:1.73.0'import io.grpc.protobuf.services.HealthStatusManager;
import io.grpc.protobuf.services.ProtoReflectionServiceV1;
import io.grpc.protobuf.services.ChannelzService;
import io.grpc.protobuf.services.BinaryLogs;
import io.grpc.services.CallMetricRecorder;
import io.grpc.services.MetricRecorder;
import io.grpc.services.AdminInterface;import io.grpc.Server;
import io.grpc.ServerBuilder;
import io.grpc.protobuf.services.HealthStatusManager;
import io.grpc.protobuf.services.ProtoReflectionServiceV1;
import io.grpc.services.AdminInterface;
// Create a gRPC server with health checking and reflection
HealthStatusManager healthManager = new HealthStatusManager();
Server server = ServerBuilder.forPort(8080)
.addService(healthManager.getHealthService())
.addService(ProtoReflectionServiceV1.newInstance())
.addServices(AdminInterface.getStandardServices())
.build();
// Set service health status
healthManager.setStatus("my.service", ServingStatus.SERVING);
// Start server
server.start();gRPC Services is organized around several key service areas:
Most APIs are marked as @ExperimentalApi indicating they are still evolving.
Server health status management for load balancer health checks and service monitoring. Provides both individual service status and overall server health reporting.
public final class HealthStatusManager {
public static final String SERVICE_NAME_ALL_SERVICES = "";
public HealthStatusManager();
public BindableService getHealthService();
public void setStatus(String service, ServingStatus status);
public void clearStatus(String service);
public void enterTerminalState();
}Protocol buffer service reflection enabling dynamic service discovery and debugging tools. Supports both v1alpha (deprecated) and v1 reflection protocols.
public final class ProtoReflectionServiceV1 {
public static BindableService newInstance();
public StreamObserver<ServerReflectionRequest> serverReflectionInfo(
StreamObserver<ServerReflectionResponse> responseObserver
);
}Runtime introspection service providing detailed information about gRPC channels, servers, and connections for debugging and monitoring.
public final class ChannelzService {
public static ChannelzService newInstance(int maxPageSize);
public void getTopChannels(GetTopChannelsRequest request,
StreamObserver<GetTopChannelsResponse> responseObserver);
public void getServers(GetServersRequest request,
StreamObserver<GetServersResponse> responseObserver);
}Request and response logging system for debugging, auditing, and compliance. Supports configurable logging sinks and filtering.
public final class BinaryLogs {
public static BinaryLog createBinaryLog() throws IOException;
public static BinaryLog createBinaryLog(BinaryLogSink sink, String configStr)
throws IOException;
}
public interface BinaryLogSink extends Closeable {
void write(MessageLite message);
}ORCA metrics collection for load balancing and performance monitoring. Includes both per-call and out-of-band metrics reporting.
public final class CallMetricRecorder {
public static CallMetricRecorder getCurrent();
public CallMetricRecorder recordUtilizationMetric(String name, double value);
public CallMetricRecorder recordRequestCostMetric(String name, double value);
public CallMetricRecorder recordCpuUtilizationMetric(double value);
}
public final class MetricRecorder {
public static MetricRecorder newInstance();
public void putUtilizationMetric(String key, double value);
public void setCpuUtilizationMetric(double value);
}Client-side health checking utilities for load balancers and connection management.
public final class HealthCheckingLoadBalancerUtil {
public static LoadBalancer newHealthCheckingLoadBalancer(
LoadBalancer.Factory factory, Helper helper);
}Collection of standard administrative services for gRPC servers including all built-in observability and management services.
public final class AdminInterface {
public static List<ServerServiceDefinition> getStandardServices();
}public enum ServingStatus {
SERVING,
NOT_SERVING,
SERVICE_UNKNOWN
}
public class MetricReport {
public double getCpuUtilization();
public double getApplicationUtilization();
public double getMemoryUtilization();
public Map<String, Double> getRequestCostMetrics();
public Map<String, Double> getUtilizationMetrics();
}