You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by GitBox <gi...@apache.org> on 2020/06/19 15:26:08 UTC

[GitHub] [skywalking] wu-sheng commented on a change in pull request #4816: Provide agent-side meter api

wu-sheng commented on a change in pull request #4816:
URL: https://github.com/apache/skywalking/pull/4816#discussion_r442904242



##########
File path: docs/en/setup/service-agent/java-agent/Application-toolkit-meter.md
##########
@@ -0,0 +1,51 @@
+* Dependency the toolkit, such as using maven or gradle
+```xml
+   <dependency>
+      <groupId>org.apache.skywalking</groupId>
+      <artifactId>apm-toolkit-meter</artifactId>
+      <version>${skywalking.version}</version>
+   </dependency>
+```
+
+* `Counter` API represents a single monotonically increasing counter, automatic collect data and report to backend.
+```java
+Counter counter = Counter.create(meterName).tag("tagKey", "tagValue").build();
+counter.increment(1d);
+```
+1. `Counter.create` Create a new counter builder with the meter name.
+1. `Counter.Builder.tag(String key, String value)` Mark a tag key/value pair.
+1. `Counter.Builder.build()` To build a new `Counter` and it will register to the agent, automatically collect data and report to the backend.
+1. `Counter.increment(double count)` Increment count to the `Counter`, It could be a positive/negative value.
+
+* `Gauge` API represents a single numerical value.
+```java
+ThreadPoolExecutor threadPool = ...;
+Gauge gauge = Gauge.create(meterName, () -> threadPool.getActiveCount()).tag("tagKey", "tagValue").build();
+```
+1. `Gauge.create(String name, Supplier<Double> getter)` Create a new gauge builder with the meter name and supplier function, this function need to return a `double` value.
+1. `Gauge.Builder.tag(String key, String value)` Mark a tag key/value pair.
+1. `Gauge.Builder.build()` To build a new `Gauge` and it will register to the agent, automatically collect data and report to the backend.
+
+* `Histogram` API represents a summary sample observations with customize buckets.
+```java
+Histogram histogram = Histogram.create("test").tag("tagKey", "tagValue").steps(Arrays.asList(1, 5, 10)).exceptMinValue(0).build();

Review comment:
       `exceptMinValue`? What do you mean? `Exclude`? But still a little confusing.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org