From 77b218b556bf59eef98cb94729152e5f7ae0388c Mon Sep 17 00:00:00 2001
From: David Georg Reichelt <davidgeorg_reichelt@dagere.de>
Date: Thu, 19 Aug 2021 01:28:04 +0200
Subject: [PATCH] Add prometheus configuration

---
 frameworks/inspectIT/benchmark.sh             | 32 +++++++++++++++++--
 .../config/onlyInstrument/onlyInstrument.yml  | 19 +++++++++++
 .../inspectIT/config/prometheus/zipkin.yml    | 15 +++++++++
 3 files changed, 63 insertions(+), 3 deletions(-)
 create mode 100644 frameworks/inspectIT/config/onlyInstrument/onlyInstrument.yml
 create mode 100644 frameworks/inspectIT/config/prometheus/zipkin.yml

diff --git a/frameworks/inspectIT/benchmark.sh b/frameworks/inspectIT/benchmark.sh
index 6725681..c021126 100755
--- a/frameworks/inspectIT/benchmark.sh
+++ b/frameworks/inspectIT/benchmark.sh
@@ -38,7 +38,26 @@ function runInspectITZipkin {
     echo " # ${i}.$RECURSION_DEPTH.${k} InspectIT (Zipkin)" >>${BASEDIR}inspectit.log
     startZipkin
     sleep $SLEEP_TIME
-    ${JAVABIN}java ${JAVAARGS_INSPECTIT_MINIMAL} ${JAR} \
+    ${JAVABIN}java ${JAVAARGS_INSPECTIT_ZIPKIN} ${JAR} \
+        --output-filename ${RAWFN}-${i}-$RECURSION_DEPTH-${k}.csv \
+        --total-calls ${TOTAL_NUM_OF_CALLS} \
+        --method-time ${METHOD_TIME} \
+        --total-threads ${THREADS} \
+        --recursion-depth ${RECURSION_DEPTH} \
+        --force-terminate \
+        ${MOREPARAMS} &> ${RESULTSDIR}output_"$i"_"$RECURSION_DEPTH"_inspectit.txt
+    sleep $SLEEP_TIME
+    stopBackgroundProcess
+}
+
+function runInspectITPrometheus {
+    # InspectIT (minimal)
+    k=`expr ${k} + 1`
+    echo " # ${i}.$RECURSION_DEPTH.${k} InspectIT (Prometheus)"
+    echo " # ${i}.$RECURSION_DEPTH.${k} InspectIT (Prometheus)" >>${BASEDIR}inspectit.log
+    startPrometheus
+    sleep $SLEEP_TIME
+    ${JAVABIN}java ${JAVAARGS_INSPECTIT_PROMETHEUS} ${JAR} \
         --output-filename ${RAWFN}-${i}-$RECURSION_DEPTH-${k}.csv \
         --total-calls ${TOTAL_NUM_OF_CALLS} \
         --method-time ${METHOD_TIME} \
@@ -71,6 +90,9 @@ function printIntermediaryResults {
     
     echo -n "Intermediary results inspectIT Zipkin "
     cat results-inspectit/raw-*-"$RECURSION_DEPTH"-2.csv | awk -F';' '{print $2}' | getSum
+    
+    echo -n "Intermediary results inspectIT Prometheus "
+    cat results-inspectit/raw-*-"$RECURSION_DEPTH"-3.csv | awk -F';' '{print $2}' | getSum
 }
 
 JAVABIN=""
@@ -108,8 +130,9 @@ JAR="-jar MooBench.jar --application moobench.application.MonitoredClassSimple"
 JAVAARGS_NOINSTR="${JAVAARGS}"
 JAVAARGS_LTW="${JAVAARGS} -javaagent:${BASEDIR}agent/inspectit-ocelot-agent-1.11.1.jar -Djava.util.logging.config.file=${BASEDIR}config/logging.properties"
 JAVAARGS_INSPECTIT_DEACTIVATED="${JAVAARGS_LTW} -Dinspectit.service-name=moobench-inspectit -Dinspectit.exporters.metrics.prometheus.enabled=false -Dinspectit.exporters.tracing.zipkin.enabled=false -Dinspectit.config.file-based.path=${BASEDIR}config/onlyInstrument/"
-JAVAARGS_INSPECTIT_MINIMAL="${JAVAARGS_LTW} -Dinspectit.service-name=moobench-inspectit -Dinspectit.exporters.metrics.prometheus.enabled=false -Dinspectit.exporters.tracing.zipkin.url=http://127.0.0.1:9411/api/v2/spans -Dinspectit.config.file-based.path=${BASEDIR}config/zipkin/"
-JAVAARGS_INSPECTIT_FULL="${JAVAARGS_LTW} -Dinspectit.config=${BASEDIR}config/timer/"
+JAVAARGS_INSPECTIT_ZIPKIN="${JAVAARGS_LTW} -Dinspectit.service-name=moobench-inspectit -Dinspectit.exporters.metrics.prometheus.enabled=false -Dinspectit.exporters.tracing.zipkin.url=http://127.0.0.1:9411/api/v2/spans -Dinspectit.config.file-based.path=${BASEDIR}config/zipkin/"
+JAVAARGS_INSPECTIT_PROMETHEUS="${JAVAARGS_LTW} -Dinspectit.service-name=moobench-inspectit -Dinspectit.exporters.metrics.zipkin.enabled=false -Dinspectit.exporters.metrics.prometheus.enabled=true -Dinspectit.config.file-based.path=${BASEDIR}config/prometheus/"
+
 
 writeConfiguration
 
@@ -128,6 +151,9 @@ for ((i=1;i<=${NUM_OF_LOOPS};i+=1)); do
     runInspectITZipkin
     cleanup
     
+    runInspectITPrometheus
+    cleanup
+    
     printIntermediaryResults
 done
 mv ${BASEDIR}inspectit.log ${RESULTSDIR}inspectit.log
diff --git a/frameworks/inspectIT/config/onlyInstrument/onlyInstrument.yml b/frameworks/inspectIT/config/onlyInstrument/onlyInstrument.yml
new file mode 100644
index 0000000..a226459
--- /dev/null
+++ b/frameworks/inspectIT/config/onlyInstrument/onlyInstrument.yml
@@ -0,0 +1,19 @@
+inspectit:
+  instrumentation:
+    scopes:
+      's_moobench':
+        type:
+          name: 'MonitoredClass'
+          matcher-mode: 'CONTAINS'
+    rules:
+      'r_moobench':
+        enabled: true
+        include:
+          'r_trace_method': false # do not save anything
+          'r_capture_method_duration': false # do not save anything
+        scopes:
+          's_moobench': true 
+    actions: 
+      'a_do_nothing':
+        value-body: |
+          'if (true) {}'
diff --git a/frameworks/inspectIT/config/prometheus/zipkin.yml b/frameworks/inspectIT/config/prometheus/zipkin.yml
new file mode 100644
index 0000000..340bcca
--- /dev/null
+++ b/frameworks/inspectIT/config/prometheus/zipkin.yml
@@ -0,0 +1,15 @@
+inspectit:
+  instrumentation:
+    scopes:
+      's_moobench':
+        type:
+          name: 'MonitoredClass'
+          matcher-mode: 'CONTAINS'
+    rules:
+      'r_moobench':
+        enabled: true
+        include:
+          'r_trace_method': true # records spans
+          'r_capture_method_duration': true # records metrics
+        scopes:
+          's_moobench': true 
-- 
GitLab