You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by da...@apache.org on 2021/10/04 09:00:20 UTC

[skywalking] branch dmsolr-patch-1 created (now dc70fff)

This is an automated email from the ASF dual-hosted git repository.

daming pushed a change to branch dmsolr-patch-1
in repository https://gitbox.apache.org/repos/asf/skywalking.git.


      at dc70fff  Update SampleBuilder.java

This branch includes the following new commits:

     new dc70fff  Update SampleBuilder.java

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


[skywalking] 01/01: Update SampleBuilder.java

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

daming pushed a commit to branch dmsolr-patch-1
in repository https://gitbox.apache.org/repos/asf/skywalking.git

commit dc70fffcc083ae3ea30272b744ea2a585f18fb07
Author: Daming <zt...@foxmail.com>
AuthorDate: Mon Oct 4 17:00:01 2021 +0800

    Update SampleBuilder.java
---
 .../provider/meter/process/SampleBuilder.java      | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/oap-server/analyzer/agent-analyzer/src/main/java/org/apache/skywalking/oap/server/analyzer/provider/meter/process/SampleBuilder.java b/oap-server/analyzer/agent-analyzer/src/main/java/org/apache/skywalking/oap/server/analyzer/provider/meter/process/SampleBuilder.java
index ed656e2..9a44c57 100644
--- a/oap-server/analyzer/agent-analyzer/src/main/java/org/apache/skywalking/oap/server/analyzer/provider/meter/process/SampleBuilder.java
+++ b/oap-server/analyzer/agent-analyzer/src/main/java/org/apache/skywalking/oap/server/analyzer/provider/meter/process/SampleBuilder.java
@@ -31,16 +31,36 @@ public class SampleBuilder {
     final String name;
     final ImmutableMap<String, String> labels;
     final double value;
+    final String serviceLabel;
+    final String instanceLabel;
+
+    public SampleBuilder(final String name, final ImmutableMap<String, String> labels, final double value) {
+        this.name = name;
+        this.labels = labels;
+        this.value = value;
+        if (labels.containsKey("instance")) {
+            instanceLabel = "__instance__";
+        } else {
+            instanceLabel = "instance";
+        }
+        if (labels.containsKey("service")) {
+            serviceLabel = "__service__";
+        } else {
+            serviceLabel = "service";
+        }
+    }
 
     public Sample build(String service, String instance, long timestamp) {
+        ImmutableMap.Builder<Object, Object> builder = ImmutableMap.builder().putAll(labels);
         return Sample.builder()
             .name(name)
             .labels(ImmutableMap.<String, String>builder()
                 // Put original labels
                 .putAll(labels)
                 // Put report service and instance to labels
+                .put(serviceLabel, service)
+                .put(instanceLabel, instance)
                 .put("service", service)
-                .put("instance", instance)
                 .build())
             .value(value)
             .timestamp(timestamp).build();