Skip to content

Commit

Permalink
Update readme for metrics collector (#121)
Browse files Browse the repository at this point in the history
## Type of Change

* Documentation update

## Checklist

- [x] My code follows the style guidelines of this project
- [x] I have performed a self-review of my own code
- [x] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings

---------

Signed-off-by: David Kornel <[email protected]>
  • Loading branch information
kornys authored Jul 3, 2024
1 parent f587b90 commit 58a99bc
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions test-frame-metrics-collector/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,25 +77,21 @@ To collect metrics from configured pods:
```java
try {
collector.collectMetricsFromPods(30000); // timeout in milliseconds
Map<String, String> metrics = collector.getCollectedData();
metrics.forEach((key, value) -> System.out.println(key + " : " + value));
Map<String, List<Metric>> metrics = collector.getCollectedData();
metrics.forEach((podName, metrics) -> {
System.out.println(podName);
metrics.forEach(metric -> System.out.println(metric.getName));
});
} catch (MetricsCollectionException e) {
System.err.println("Error collecting metrics: " + e.getMessage());
}
```

### Advanced Usage

For more specific metric collection, such as collecting metrics that match a certain pattern:
Return all metrics with specific label present
```java
Pattern pattern = Pattern.compile("http_requests_total\\{method=\"POST\"\\}");
ArrayList<Double> values = collector.collectSpecificMetric(pattern);
```

To wait for a specific metric and collect it:

```java
ArrayList<Double> awaitedValues = collector.waitForSpecificMetricAndCollect(pattern);
Map<String, List<Metric>> metrics = collector.collectMetricWithLabels("my-pod", "label");
```

This README provides a structured guide that helps users understand what the `MetricsCollector` does and how to implement it effectively in their projects.

0 comments on commit 58a99bc

Please sign in to comment.