Skip to content

Commit

Permalink
add experiment setup for otel-kieker setup
Browse files Browse the repository at this point in the history
  • Loading branch information
silvergl committed Nov 25, 2024
1 parent fb68935 commit 8862212
Show file tree
Hide file tree
Showing 21 changed files with 805 additions and 0 deletions.
9 changes: 9 additions & 0 deletions frameworks/Otel-Kieker-Python/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
__pycache__/**
config.ini
monitoring.ini
data/**
kieker-lang-pack-python/**
receiver/**
record-map.log
results-python/**

8 changes: 8 additions & 0 deletions frameworks/Otel-Kieker-Python/.idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions frameworks/Otel-Kieker-Python/.idea/Otel-Kieker-Python.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions frameworks/Otel-Kieker-Python/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions frameworks/Otel-Kieker-Python/.idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions frameworks/Otel-Kieker-Python/.idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

82 changes: 82 additions & 0 deletions frameworks/Otel-Kieker-Python/benchmark.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# -*- coding: utf-8 -*-
# standard import
import sys
import time
import configparser
import re
# instrumentation
from opentelemetry import trace
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import BatchSpanProcessor, SimpleSpanProcessor

from emptyexporter import EmptyExporter
from kiekerexporter import KiekerTcpExporter
from kiekerprocessor import IncrementAttributeSpanProcessor
# read argumetns
if len(sys.argv) < 2:
print('Path to the benchmark configuration file was not provided.')

parser = configparser.ConfigParser()
parser.read(sys.argv[1])

total_calls =int(parser.get('Benchmark','total_calls'))
recursion_depth = int(parser.get('Benchmark','recursion_depth'))
method_time = int(parser.get('Benchmark','method_time'))
ini_path = parser.get('Benchmark','config_path')
inactive = parser.getboolean('Benchmark', 'inactive')
instrumentation_on = parser.getboolean('Benchmark', 'instrumentation_on')
approach = parser.getint('Benchmark', 'approach')
output_filename = parser.get('Benchmark', 'output_filename')
empty_exporter = parser.getboolean('Benchmark', 'empty_exporter')
simple_processor = parser.getboolean('Benchmark', 'simple_processor')
# debug

trace.set_tracer_provider(TracerProvider())
otlp_exporter = KiekerTcpExporter()
empty_exporter = EmptyExporter()
kieker_exporter = KiekerTcpExporter()
# instrument


if empty_exporter:
if simple_processor:
span_processor = SimpleSpanProcessor(empty_exporter)
trace.get_tracer_provider().add_span_processor(span_processor)
else:
span_processor = BatchSpanProcessor(empty_exporter)
trace.get_tracer_provider().add_span_processor(span_processor)
else:
if simple_processor:
span_processor = SimpleSpanProcessor(kieker_exporter)
trace.get_tracer_provider().add_span_processor(span_processor)
else:
span_processor = BatchSpanProcessor(kieker_exporter)
trace.get_tracer_provider().add_span_processor(span_processor)



import monitored_application

# setup
output_file = open(output_filename, "w")

thread_id = 0

start_ns = 0
stop_ns = 0
timings = []

# run experiment
for i in range(total_calls):
start_ns = time.time_ns()
monitored_application.monitored_method(method_time, recursion_depth)
stop_ns = time.time_ns()
timings.append(stop_ns-start_ns)
if i%100000 == 0:
print(timings[-1])

output_file.write(f"{thread_id};{timings[-1]}\n")

output_file.close()

# end
169 changes: 169 additions & 0 deletions frameworks/Otel-Kieker-Python/benchmark.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
#!/bin/bash

#
# Kieker python benchmark script
#
# Usage: benchmark.sh

VENV_DIR="${HOME}/venv/moobench"
python3 -m venv ${VENV_DIR}
source ${VENV_DIR}/bin/activate

# configure base dir
BASE_DIR=$(cd "$(dirname "$0")"; pwd)

#
# source functionality
#

if [ ! -d "${BASE_DIR}" ] ; then
echo "Base directory ${BASE_DIR} does not exist."
exit 1
fi

MAIN_DIR="${BASE_DIR}/../.."

if [ -f "${MAIN_DIR}/common-functions.sh" ] ; then
source "${MAIN_DIR}/common-functions.sh"
else
echo "Missing library: ${MAIN_DIR}/common-functions.sh"
exit 1
fi

# load configuration and common functions
if [ -f "${BASE_DIR}/config.rc" ] ; then
source "${BASE_DIR}/config.rc"
else
echo "Missing configuration: ${BASE_DIR}/config.rc"
exit 1
fi

if [ -f "${BASE_DIR}/functions.sh" ] ; then
source "${BASE_DIR}/functions.sh"
else
echo "Missing functions: ${BASE_DIR}/functions.sh"
exit 1
fi
if [ -f "${BASE_DIR}/labels.sh" ] ; then
source "${BASE_DIR}/labels.sh"
else
echo "Missing file: ${BASE_DIR}/labels.sh"
exit 1
fi

if [ -z "$MOOBENCH_CONFIGURATIONS" ]
then
MOOBENCH_CONFIGURATIONS="0 1 2 3 4 5 6 7 8"
echo "Setting default configuration $MOOBENCH_CONFIGURATIONS (everything)"
fi
echo "Running configurations: $MOOBENCH_CONFIGURATIONS"

#
# Setup
#

info "----------------------------------"
info "Setup..."
info "----------------------------------"

cd "${BASE_DIR}"

# load agent
getAgent

checkFile log "${DATA_DIR}/kieker.log" clean
checkDirectory results-directory "${RESULTS_DIR}" recreate
PARENT=`dirname "${RESULTS_DIR}"`
checkDirectory result-base "${PARENT}"
checkDirectory data-dir "${DATA_DIR}" create

# Find receiver and extract it
checkFile receiver "${RECEIVER_ARCHIVE}"
tar -xpf "${RECEIVER_ARCHIVE}"
RECEIVER_BIN="${BASE_DIR}/receiver/bin/receiver"
checkExecutable receiver "${RECEIVER_BIN}"

checkFile R-script "${RSCRIPT_PATH}"

showParameter

TIME=`expr ${METHOD_TIME} \* ${TOTAL_NUM_OF_CALLS} / 1000000000 \* 4 \* ${RECURSION_DEPTH} \* ${NUM_OF_LOOPS} + ${SLEEP_TIME} \* 4 \* ${NUM_OF_LOOPS} \* ${RECURSION_DEPTH} + 50 \* ${TOTAL_NUM_OF_CALLS} / 1000000000 \* 4 \* ${RECURSION_DEPTH} \* ${NUM_OF_LOOPS} `
info "Experiment will take circa ${TIME} seconds."

# Receiver setup if necessary
declare -a RECEIVER
# Title
declare -a TITLE

RECEIVER[5]="${RECEIVER_BIN} 2345"

#
# Write configuration
#

uname -a > "${RESULTS_DIR}/configuration.txt"
cat << EOF >> "${RESULTS_DIR}/configuration.txt"
Runtime: circa ${TIME} seconds
SLEEP_TIME=${SLEEP_TIME}
NUM_OF_LOOPS=${NUM_OF_LOOPS}
TOTAL_NUM_OF_CALLS=${TOTAL_NUM_OF_CALLS}
METHOD_TIME=${METHOD_TIME}
RECURSION_DEPTH=${RECURSION_DEPTH}
EOF

sync

info "Ok"

#
# Run benchmark
#

info "----------------------------------"
info "Running benchmark..."
info "----------------------------------"


## Execute Benchmark
for ((i=1;i<=${NUM_OF_LOOPS};i+=1)); do

info "## Starting iteration ${i}/${NUM_OF_LOOPS}"
echo "## Starting iteration ${i}/${NUM_OF_LOOPS}" >> "${DATA_DIR}/kieker.log"

noInstrumentation 0 $i

deactivatedProbe 1 $i 1
deactivatedProbe 2 $i 2

noLogging 3 $i 1
noLogging 4 $i 2

textLogging 5 $i 1
textLogging 6 $i 2

tcpLogging 7 $i 1
tcpLogging 8 $i 2

printIntermediaryResults "${i}"
done

# Create R labels
LABELS=$(createRLabels)
runStatistics
cleanupResults

mv "${DATA_DIR}/kieker.log" "${RESULTS_DIR}/kieker.log"
rm "${DATA_DIR}/kieker"
[ -f "${DATA_DIR}/errorlog.txt" ] && mv "${DATA_DIR}/errorlog.txt" "${RESULTS_DIR}"

checkFile results.yaml "${RESULTS_DIR}/results.yaml"
checkFile results.yaml "${RESULTS_DIR}/results.zip"

info "Done."

deactivate
rm -rf ${VENV_DIR}

exit 0
# end
9 changes: 9 additions & 0 deletions frameworks/Otel-Kieker-Python/config.ini.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[Benchmark]
total_calls = 100000
recursion_depth = 10
method_time = 500000
config_path = /home/serafim/Desktop/kieker-experiment/monitoring.ini
inactive = False
instrumentation_on = True
approach = 1

25 changes: 25 additions & 0 deletions frameworks/Otel-Kieker-Python/config.rc
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# benchmark setup script

source ${MAIN_DIR}/config.rc

PYTHON=`which python3`

PIP=`which pip`
if [ ! -f "$PIP" ] ; then
PIP=`which pip3`
fi

GIT=`which git`

RSCRIPT_PATH="${BASE_DIR}/../statistics.r"

DATA_DIR="${BASE_DIR}/data"

KIEKER_4_PYTHON_REPO_URL="https://github.com/rju/kieker-lang-pack-python.git"
KIEKER_4_PYTHON_DIR="${BASE_DIR}/kieker-lang-pack-python"
KIEKER_4_PYTHON_BRANCH="ast_import_hook"

RECEIVER_ARCHIVE="${MAIN_DIR}/tools/receiver/build/distributions/receiver.tar"



8 changes: 8 additions & 0 deletions frameworks/Otel-Kieker-Python/config.rc.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# benchmark setup script

PYTHON=`which python3`
PIP=`which pip`
GIT=`which git`



9 changes: 9 additions & 0 deletions frameworks/Otel-Kieker-Python/emptyexporter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from opentelemetry.sdk.trace.export import SpanExporter, SpanExportResult

class EmptyExporter (SpanExporter):

def __init__(self):
pass

def export(self, spans):
return SpanExportResult.SUCCESS
Loading

0 comments on commit 8862212

Please sign in to comment.