grpc / grpc/grpc-java

Unable to activate real-time metrics to OpenCensus

Aperta
#5,624 15 commenti 0 reazioni 1 assegnatario Assegnata a @zhangkun83 Vedi su GitHub
enhancement
Lingua principale
Java
Stelle
12.1k
Fork
4k
Merge medio
2g 17h
PR unite (30g)
37

Descrizione

#5099 implemented a way to record real-time metrics. Cool! Now I'd like to activate it, as it's disabled by default. I'm not successful in enabling this, however.

Tried with a NettyServerBuilder for example, but the `setStatsRecordRealTimeMetrics` method is protected.

I don't see any other way to set the private attribute `recordRealTimeMetrics` in the `AbstractServerImplBuilder` class from the sources.

The work-around I'm using now is ugly in bypassing the protected attribute (Kotlin, but you get my point).

```kotlin
val serverBuilder = NettyServerBuilder.forPort(1234)
val setStatsRecordRealTimeMetricsMethod = NettyServerBuilder::class.java
.getDeclaredMethod("setStatsRecordRealTimeMetrics", Boolean::class.java)
setStatsRecordRealTimeMetricsMethod.setAccessible(true)
setStatsRecordRealTimeMetricsMethod.invoke(serverBuilder, true)
```

after which it starts to work, except from the method name not being exported (but that's #5593).

### What version of gRPC are you using?

1.20.0

### What did you expect to see?

A public function on the Builder to call `setStatsRecordRealTimeMetrics(true)`.

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.