grpc-ecosystem / grpc-ecosystem/java-grpc-prometheus
Collecting metrics
- Dominant language
- Java
- Stars
- 236
- Forks
- 80
- PR merge metrics
- No merged PRs in 30d
Description
Hey everyone,
I'm having difficulties to get the library working.
Right below I set a register and bind it to a pushgateway. In addition, I define a `gauge` and set it to the previous defined register, as well as pass this register as a parameter to `MonitoringServerInterceptor` . Whenever e check the metrics on pushgateway I only see the gauge I defined. No Grpc metrics are found there.
Am I doing anything wrong?
Thanks in advance!
```
public class UserApiServer {
private static final int APP_DEFAULT_PORT = 50020;
private static final Logger logger = Logger.getLogger(UserApiServer.class.getName());
private Server server;
static final CollectorRegistry pushRegistry = new CollectorRegistry();
static final Gauge g = (Gauge) Gauge.build().name("userapi").help("blah").register(pushRegistry);
void start(final int port) throws IOException {
final MonitoringServerInterceptor monitoringInterceptor =
MonitoringServerInterceptor.create(Configuration.cheapMetricsOnly().withCollectorRegistry(pushRegistry));
server = ServerBuilder.forPort(port)
.addService(ServerInterceptors.intercept(new UserApiService().bindService(), monitoringInterceptor))
.build()
.start();
logger.info("Server started, listening on " + port);
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
logger.warning("*** shutting down gRPC server since JVM is shutting down");
try {
UserApiServer.this.stop();
} catch (IOException ignore) {}
logger.warning("*** server shut down");
}));
}
...
public static void main(String[] args) throws IOException, InterruptedException {
Thread.setDefaultUncaughtExceptionHandler(RaygunExceptionHandler.getInstance());
PushGateway pg = new PushGateway("localhost:9091" );
g.set(42);
pg.push(pushRegistry, "grpc");
final UserApiServer server = new UserApiServer();
server.start(APP_DEFAULT_PORT);
server.blockUntilShutdown();
}
}
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.