You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This will then start using OkHttp instead of HttpURLConnection to send metrics.
322
322
323
+
## Impact metrics
324
+
325
+
Impact metrics are lightweight, application-level time-series metrics stored and visualized directly inside Unleash. They allow you to connect specific application data, such as request counts, error rates, or memory usage, to your feature flags and release plans.
326
+
327
+
Use impact metrics to validate feature impact and automate your release process. For example, you can monitor usage patterns or performance to see if a feature is meeting its goals. By combining impact metrics with release templates, you can reduce manual release operations and automate milestone progression based on metric thresholds.
328
+
329
+
The SDK automatically attaches the following context labels to your metrics: `appName`, `environment`, and `origin` (for example, `origin=sdk` or `origin=Edge`).
330
+
331
+
### Counters
332
+
333
+
Use counters for cumulative values that only increase, such as the total number of requests or errors.
334
+
335
+
```java
336
+
UnleashConfig config =
337
+
UnleashConfig.builder()
338
+
.appName("my-java-app")
339
+
.instanceId("instance-1")
340
+
.unleashAPI("https://YOUR-API-URL")
341
+
.apiKey("<YOUR_API_TOKEN>")
342
+
.build();
343
+
344
+
Unleash unleash = new DefaultUnleash(config);
345
+
346
+
unleash.getImpactMetrics()
347
+
.defineCounter("request_count", "Total number of HTTP requests processed");
Use histograms to measure the distribution of values, such as request duration or response size. Unleash automatically calculates percentiles (p50, p95, p99).
368
+
369
+
```java
370
+
unleash.getImpactMetrics()
371
+
.defineHistogram("request_time_ms", "Time taken to process a request in milliseconds");
372
+
373
+
long start = System.currentTimeMillis();
374
+
// handleRequest();
375
+
long duration = System.currentTimeMillis() - start;
0 commit comments