feat(api): support metric API Prometheus format & add statistic metric api #2286
feat(api): support metric API Prometheus format & add statistic metric api #2286JackyYangPassion merged 16 commits intoapache:masterfrom
Conversation
hugegraph-api/src/main/java/org/apache/hugegraph/api/filter/AccessLogFilter.java
Show resolved
Hide resolved
| MetricsUtil.registerMeter(API.class, "illegal-arg"); | ||
| private static final Meter EXPECTED_ERROR_METER = | ||
| MetricsUtil.registerMeter(API.class, "expected-error"); | ||
| MetricsUtil.registerMeter(API.class, "expected-error"); |
| MetricsUtil.registerMeter(API.class, "expected-error"); | ||
| private static final Meter UNKNOWN_ERROR_METER = | ||
| MetricsUtil.registerMeter(API.class, "unknown-error"); | ||
| MetricsUtil.registerMeter(API.class, "unknown-error"); |
| return result; | ||
| } catch (IllegalArgumentException | NotFoundException | | ||
| ForbiddenException e) { | ||
| ForbiddenException e) { |
| Assert.assertTrue(String.format( | ||
| "Expect map value for key %s but got %s", | ||
| key, value), | ||
| "Expect map value for key %s but got %s", |
There was a problem hiding this comment.
prefer to keep the origin alignment
There was a problem hiding this comment.
not addressed: prefer to keep the origin alignment
# Conflicts: # hugegraph-api/src/main/java/org/apache/hugegraph/api/API.java
|
@SunnyBoy-WYH seems CI failed? could check the CI status in your personal repo (submit a PR to your repo, u could check/test CI there) |
Nice idea! ( when i push this pr, the local test passed, and a few days before i am looking for the ci problem,but ci info not enough.) i will try it again. |
Codecov Report
@@ Coverage Diff @@
## master #2286 +/- ##
============================================
- Coverage 68.26% 65.04% -3.23%
Complexity 989 989
============================================
Files 500 503 +3
Lines 41516 41801 +285
Branches 5786 5804 +18
============================================
- Hits 28342 27189 -1153
- Misses 10415 11920 +1505
+ Partials 2759 2692 -67
... and 69 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
hugegraph-api/src/main/java/org/apache/hugegraph/metrics/MetricsUtil.java
Outdated
Show resolved
Hide resolved
hugegraph-api/src/main/java/org/apache/hugegraph/metrics/MetricsUtil.java
Outdated
Show resolved
Hide resolved
hugegraph-api/src/main/java/org/apache/hugegraph/metrics/MetricsUtil.java
Outdated
Show resolved
Hide resolved
hugegraph-api/src/main/java/org/apache/hugegraph/api/filter/AccessLogFilter.java
Outdated
Show resolved
Hide resolved
hugegraph-api/src/main/java/org/apache/hugegraph/api/filter/AccessLogFilter.java
Outdated
Show resolved
Hide resolved
hugegraph-api/src/main/java/org/apache/hugegraph/api/filter/PathFilter.java
Show resolved
Hide resolved
hugegraph-api/src/main/java/org/apache/hugegraph/api/filter/AccessLogFilter.java
Outdated
Show resolved
Hide resolved
hugegraph-api/src/main/java/org/apache/hugegraph/api/filter/AccessLogFilter.java
Outdated
Show resolved
Hide resolved
hugegraph-api/src/main/java/org/apache/hugegraph/api/filter/AccessLogFilter.java
Outdated
Show resolved
Hide resolved
hugegraph-api/src/main/java/org/apache/hugegraph/api/filter/PathFilter.java
Outdated
Show resolved
Hide resolved
hugegraph-api/src/main/java/org/apache/hugegraph/api/filter/PathFilter.java
Outdated
Show resolved
Hide resolved
hugegraph-api/src/main/java/org/apache/hugegraph/api/filter/PathFilter.java
Outdated
Show resolved
Hide resolved
hugegraph-api/src/main/java/org/apache/hugegraph/api/metrics/MetricsAPI.java
Outdated
Show resolved
Hide resolved
hugegraph-api/src/main/java/org/apache/hugegraph/api/metrics/MetricsAPI.java
Outdated
Show resolved
Hide resolved
hugegraph-api/src/main/java/org/apache/hugegraph/api/metrics/MetricsAPI.java
Outdated
Show resolved
Hide resolved
hugegraph-api/src/main/java/org/apache/hugegraph/api/metrics/MetricsAPI.java
Outdated
Show resolved
Hide resolved
hugegraph-api/src/main/java/org/apache/hugegraph/metrics/MetricsKeys.java
Outdated
Show resolved
Hide resolved
hugegraph-api/src/main/java/org/apache/hugegraph/metrics/MetricsUtil.java
Outdated
Show resolved
Hide resolved
hugegraph-test/src/main/java/org/apache/hugegraph/api/MetricsApiTest.java
Outdated
Show resolved
Hide resolved
javeme
left a comment
There was a problem hiding this comment.
there are still some comments to be addressed, thanks
hugegraph-api/src/main/java/org/apache/hugegraph/api/metrics/MetricsAPI.java
Outdated
Show resolved
Hide resolved
hugegraph-api/src/main/java/org/apache/hugegraph/api/metrics/MetricsAPI.java
Outdated
Show resolved
Hide resolved
hugegraph-api/src/main/java/org/apache/hugegraph/metrics/MetricsKeys.java
Outdated
Show resolved
Hide resolved
hugegraph-api/src/main/java/org/apache/hugegraph/metrics/MetricsUtil.java
Show resolved
Hide resolved
hugegraph-api/src/main/java/org/apache/hugegraph/metrics/MetricsUtil.java
Outdated
Show resolved
Hide resolved
hugegraph-api/src/main/java/org/apache/hugegraph/metrics/MetricsUtil.java
Outdated
Show resolved
Hide resolved
hugegraph-test/src/main/java/org/apache/hugegraph/api/MetricsApiTest.java
Outdated
Show resolved
Hide resolved
hugegraph-test/src/main/java/org/apache/hugegraph/api/MetricsApiTest.java
Outdated
Show resolved
Hide resolved
hugegraph-api/src/main/java/org/apache/hugegraph/api/metrics/MetricsAPI.java
Outdated
Show resolved
Hide resolved
hugegraph-api/src/main/java/org/apache/hugegraph/metrics/MetricsUtil.java
Outdated
Show resolved
Hide resolved
hugegraph-api/src/main/java/org/apache/hugegraph/api/filter/AccessLogFilter.java
Outdated
Show resolved
Hide resolved
hugegraph-api/src/main/java/org/apache/hugegraph/api/metrics/MetricsAPI.java
Outdated
Show resolved
Hide resolved
hugegraph-api/src/main/java/org/apache/hugegraph/api/metrics/MetricsAPI.java
Outdated
Show resolved
Hide resolved
hugegraph-api/src/main/java/org/apache/hugegraph/metrics/MetricsUtil.java
Outdated
Show resolved
Hide resolved
hugegraph-api/src/main/java/org/apache/hugegraph/metrics/MetricsUtil.java
Outdated
Show resolved
Hide resolved
| Assert.assertTrue(String.format( | ||
| "Expect map value for key %s but got %s", | ||
| key, value), | ||
| "Expect map value for key %s but got %s", |
There was a problem hiding this comment.
not addressed: prefer to keep the origin alignment
| return result; | ||
| } catch (IllegalArgumentException | NotFoundException | | ||
| ForbiddenException e) { | ||
| ForbiddenException e) { |
fix #1656 #1356 (will enhance it later)
术语:
统计指标:指【请求总数、成功数、失败数、平均响应时间、最大响应时间】五个指标
基础指标:指serverReporter中原有的gauges、counters、histograms等
思路:

1.增加原有Metric接口的prom格式返回:
2.增加statistics接口,返回【请求总数、成功数、失败数、平均响应时间、最大响应时间】五个指标,同时支持prop格式返回
json:
3.需要讨论一下 statistics接口的数据是否要合并在Metric接口中,目前没有合并是因为,原有指标结果JSON中只包含counter、summary等五种标准指标 ;
另外分开还有个好处是,如果后续想要按照图、接口查询统计指标,比较方便定制