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

[GitHub] [beam] kamilwu commented on a change in pull request #11956: [BEAM-8133] Publishing results of Nexmark tests to InfluxDB

kamilwu commented on a change in pull request #11956:
URL: https://github.com/apache/beam/pull/11956#discussion_r441364796



##########
File path: sdks/java/testing/test-utils/src/main/java/org/apache/beam/sdk/testutils/publishing/InfluxDBPublisher.java
##########
@@ -40,34 +43,72 @@
 
   private InfluxDBPublisher() {}
 
+  public static void publishNexmarkResults(
+      final Collection<Map<String, Object>> results, final InfluxDBSettings settings) {
+    publishWithCheck(settings, () -> publishNexmark(results, settings));
+  }
+
   public static void publishWithSettings(
       final Collection<NamedTestResult> results, final InfluxDBSettings settings) {
+    publishWithCheck(settings, () -> publishCommon(results, settings));
+  }
+
+  private static void publishWithCheck(
+      final InfluxDBSettings settings, final PublishFunction publishFunction) {
     requireNonNull(settings, "InfluxDB settings must not be null");
     if (isNoneBlank(settings.measurement, settings.database)) {
       try {
-        publish(results, settings);
-      } catch (final Exception exception) {
+        publishFunction.publish();
+      } catch (Exception exception) {
         LOG.warn("Unable to publish metrics due to error: {}", exception.getMessage(), exception);
       }
     } else {
       LOG.warn("Missing property -- measurement/database. Metrics won't be published.");
     }
   }
 
-  private static void publish(
-      final Collection<NamedTestResult> results, final InfluxDBSettings settings) throws Exception {
+  private static void publishNexmark(
+      final Collection<Map<String, Object>> results, final InfluxDBSettings settings)
+      throws Exception {
 
-    final HttpClientBuilder builder = HttpClientBuilder.create();
+    final HttpClientBuilder builder = provideHttpBuilder(settings);
+    final HttpPost postRequest = providePOSTRequest(settings);
+    final StringBuilder metricBuilder = new StringBuilder();
+    results.forEach(
+        map ->
+            metricBuilder
+                .append(map.get("measurement"))

Review comment:
       How about adding a method `getKV` that would return a String in this format:" <key>=<value>", e.g. "runner=DataflowRunner"? This would reduce the number of appends.




----------------------------------------------------------------
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