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 07:48:51 UTC

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

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



##########
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:
       I'm wondering if it would make sense to extract the appends of keys and values to a method, but I can't find a nice and clean way of doing it. @kamilwu do you have any thoughts about it?




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