New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add MetricRecorder implementation #11128
Conversation
// Measures may need updating in two cases: | ||
// 1. When the sink is initially created with an empty list of measures. | ||
// 2. When new metric instruments are registered, requiring the sink to accommodate them. | ||
sink.updateMeasures(registry.getMetricInstruments()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When you implement the sink, you'll need to check whether there are actually any new elements. With this threading, later calls to updateMeasures() can show fewer entries. That can be okay. The sink just needs to ignore the cases when there's no new entries.
core/src/test/java/io/grpc/internal/MetricRecorderImplTest.java
Outdated
Show resolved
Hide resolved
core/src/test/java/io/grpc/internal/MetricRecorderImplTest.java
Outdated
Show resolved
Hide resolved
core/src/test/java/io/grpc/internal/MetricRecorderImplTest.java
Outdated
Show resolved
Hide resolved
…addressed review comments
* @param requiredLabelValues A list of required label values for the metric. | ||
* @param optionalLabelValues A list of additional, optional label values for the metric. | ||
*/ | ||
default void recordDoubleCounter(DoubleCounterMetricInstrument metricInstrument, double value, | ||
default void addDoubleCounter(DoubleCounterMetricInstrument metricInstrument, double value, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@temawi updated counter APIs. Can you PTAL?
this(new ArrayList<>(DEFAULT_INSTRUMENT_LIST_CAPACITY), new HashSet<>()); | ||
} | ||
private volatile MetricInstrument[] metricInstruments; | ||
private volatile int instrumentListCapacity = INITIAL_INSTRUMENT_CAPACITY; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use metricInstruments.length
instead
private final List<MetricInstrument> metricInstruments; | ||
private final Set<String> registeredMetricNames; | ||
private final Object lock = new Object(); | ||
private final Set<String> registeredMetricNames = new HashSet<>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@GuardedBy("lock")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
This PR adds an internal implementation for
MetricRecorder
interface. And adds unit tests forMetricInstrumentRegistry
.