grpc-ecosystem / grpc-ecosystem/java-grpc-prometheus

Question on how to use the library

Open
#56 7 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
236
Forks
80
PR merge metrics
No merged PRs in 30d

Description

Hi,
Our service is a GRPC service, and I am trying to use this library with prometheus to manage the metrics, I have tried to setup my code following the usage example, though it doesn't work, could you give me some suggestions on this?
My grpc server looks like:

var server: Server = null
var httpServer: HTTPServer = null
val pushRegistry = new CollectorRegistry()

def start(): Unit = {
val serverBuilder = if (config.auth.enableTls) {
val certPath = Paths.get(config.auth.serverCertFolder, config.auth.serverCertFilename).toString
val keyPath = Paths.get(config.auth.serverCertFolder, config.auth.serverCertKeyFilename).toString
if (config.auth.enableClientAuth) getSecureServerWithClientAuthBuilder(MuFnServer.port, certPath, keyPath, config.auth.trustStorePath)
else getSecureServerBuilder(MuFnServer.port, certPath, keyPath, config.auth.trustStorePath)
} else getInsecureServerBuilder(MuFnServer.port)

httpServer = new HTTPServer(9090)
server = serverBuilder
.addService(MuFnServiceGrpc.bindService(new MuFnImpl(config, openTelemetry), executionContext))
.addService(ProtoReflectionService.newInstance())
.intercept(MonitoringServerInterceptor.create(Configuration.cheapMetricsOnly()
.withCollectorRegistry(pushRegistry)))
.build
.start
sys.addShutdownHook {
logger.error("*** shutting down gRPC server since JVM is shutting down")
self.stop()
logger.error("*** server shut down")
}

And my prometheus setup in pod-spec is as below:

template:
metadata:
annotations:
"prometheus.io/scrape": "true"
"prometheus.io/port": "8888"
"prometheus.io/path": "/metrics"
labels:
app.kubernetes.io/name: mufn-service
ginku.opentelemetry.onboard: "true"

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.