grpc / grpc/grpc-java

Unable to activate real-time metrics to OpenCensus

Open
#5,624 15 comments 0 reactions 1 assignee Assigned to @zhangkun83 View on GitHub
enhancement
Dominant language
Java
Stars
12.1k
Forks
4k
Avg merge
2d 17h
Merged PRs (30d)
37

Description

#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)`.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.