-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add jaeger docker image with HANA trace information (#1008)
- Loading branch information
Showing
8 changed files
with
192 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
service: | ||
extensions: [jaeger_storage, jaeger_query] | ||
pipelines: | ||
traces: | ||
receivers: [otlp] | ||
processors: [batch] | ||
exporters: [jaeger_storage_exporter, spanmetrics] | ||
metrics/spanmetrics: | ||
receivers: [spanmetrics] | ||
exporters: [prometheus] | ||
telemetry: | ||
resource: | ||
service.name: jaeger | ||
metrics: | ||
level: detailed | ||
address: 0.0.0.0:8888 | ||
logs: | ||
level: DEBUG | ||
|
||
extensions: | ||
jaeger_query: | ||
max_clock_skew_adjust: 30s | ||
storage: | ||
traces: some_storage | ||
metrics: some_metrics_storage | ||
jaeger_storage: | ||
backends: | ||
some_storage: | ||
memory: | ||
max_traces: 100000 | ||
metric_backends: | ||
some_metrics_storage: | ||
prometheus: | ||
endpoint: http://prometheus:9090 | ||
normalize_calls: true | ||
normalize_duration: true | ||
|
||
connectors: | ||
spanmetrics: | ||
|
||
receivers: | ||
otlp: | ||
protocols: | ||
grpc: | ||
http: | ||
endpoint: "0.0.0.0:4318" | ||
|
||
processors: | ||
batch: | ||
|
||
exporters: | ||
jaeger_storage_exporter: | ||
trace_storage: some_storage | ||
prometheus: | ||
endpoint: "0.0.0.0:8889" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#!/bin/bash | ||
|
||
# Directory containing the trace files | ||
TRACE_DIR="/hana/mounts/trace/hana/DB_H00" | ||
|
||
# OpenTelemetry endpoint | ||
OTEL_ENDPOINT="http://jaeger:4318/v1/traces" | ||
|
||
# Function to process a trace file | ||
process_trace_file() { | ||
local trace_file="$1" | ||
tail -F "$trace_file" | awk -v RS='\n\n' 'function generate_span_id() { | ||
cmd = "cat /proc/sys/kernel/random/uuid | tr -d \"-\" | cut -c1-16 | tr -d \"\n\"" | ||
cmd | getline span_id | ||
close(cmd) | ||
return span_id | ||
} | ||
{ | ||
split($0, fields, ";"); | ||
traceId=fields[22]; | ||
spanId=generate_span_id(); | ||
parentSpanId=substr(fields[24], 17); | ||
startTime=fields[6] "000"; # Convert to nanoseconds | ||
duration=fields[7] "000"; # Convert to nanoseconds | ||
endTime=startTime + duration; | ||
operation=fields[9]; | ||
statementString=fields[54]; | ||
memSize=fields[19]; | ||
cpuTime=fields[21]; | ||
gsub(/^#/, "", statementString); | ||
gsub(/\n/, " ", statementString); | ||
gsub(/"/, "\\\"", statementString); | ||
# Prepare the JSON payload according to OpenTelemetry API structure | ||
print sprintf("{\"resourceSpans\":[{\"resource\":{\"attributes\":[{\"key\":\"service.name\",\"value\":{\"stringValue\":\"@sap/hana-cloud\"}}]},\"scopeSpans\":[{\"spans\":[{\"traceId\":\"%s\",\"spanId\":\"%s\",\"parentSpanId\":\"%s\",\"name\":\"%s\",\"kind\":2,\"startTimeUnixNano\":\"%s\",\"endTimeUnixNano\":\"%s\",\"attributes\":[{\"key\":\"db.statement\",\"value\":{\"stringValue\":\"%s\"}},{\"key\":\"db.operation\",\"value\":{\"stringValue\":\"%s\"}},{\"key\":\"db.mem_size\",\"value\":{\"intValue\":%s}},{\"key\":\"db.cpu_time\",\"value\":{\"intValue\":%s}}]}]}]}]}", traceId, spanId, parentSpanId, operation, startTime, endTime, statementString, operation, memSize, cpuTime); | ||
}' | while read -r json_payload; do | ||
echo "$json_payload" | ||
echo "$json_payload" | curl -X POST "$OTEL_ENDPOINT" -H "Content-Type: application/json" -d @- | ||
done | ||
} | ||
|
||
# Function to handle script termination | ||
cleanup() { | ||
echo "Cleaning up..." | ||
pkill -P $$ | ||
exit 0 | ||
} | ||
|
||
# Trap signals to ensure cleanup | ||
trap cleanup SIGINT SIGTERM | ||
|
||
# Monitor the directory for new trace files and changes | ||
declare -A processed_files | ||
|
||
while true; do | ||
for trace_file in "$TRACE_DIR"/*.expensive_statements.*.trc; do | ||
if [ -f "$trace_file" ] && [ -z "${processed_files[$trace_file]}" ]; then | ||
echo "Listening to $trace_file..." | ||
process_trace_file "$trace_file" & | ||
processed_files["$trace_file"]=1 | ||
fi | ||
done | ||
sleep 10 | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
global: | ||
scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute. | ||
evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute. | ||
# scrape_timeout is set to the global default (10s). | ||
|
||
scrape_configs: | ||
- job_name: aggregated-trace-metrics | ||
static_configs: | ||
- targets: ['spm_metrics_source:8889'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,18 @@ | ||
docker exec hce-hana-1 /bin/bash -c "while ! ./check_hana_health ; do sleep 10 ; done;" | ||
until docker cp ./otel.sh hce-hana-1:/otel.sh | ||
do | ||
sleep 1 | ||
done | ||
|
||
docker exec hce-hana-1 /bin/bash -c "while ! ./check_hana_health ; do sleep 10 ; done;/otel.sh &;" | ||
docker exec -it hce-hana-1 /bin/bash -c "\ | ||
cd /usr/sap/H00/HDB00;\ | ||
. ./hdbenv.sh;\ | ||
hdbuserstore -i SET SYSDBKEY localhost:30013@SYSTEMDB SYSTEM Manager1;\ | ||
hdbsql -U \"SYSDBKEY\" -e -ssltrustcert \"SELECT COUNT(ACTIVE_STATUS) FROM SYS_DATABASES.M_SERVICES WHERE ACTIVE_STATUS='YES'\";\ | ||
hdbsql -U \"SYSDBKEY\" -e -ssltrustcert \"ALTER SYSTEM ALTER CONFIGURATION ('indexserver.ini', 'DATABASE', 'H00') SET ('session', 'enable_proxy_protocol') = 'false' WITH RECONFIGURE;\";\ | ||
hdbsql -U \"SYSDBKEY\" -e -ssltrustcert \"ALTER SYSTEM ALTER CONFIGURATION ('global.ini', 'System') SET ('public_hostname_resolution', 'use_default_route') = 'name' WITH RECONFIGURE;\";\ | ||
hdbsql -U \"SYSDBKEY\" -e -ssltrustcert \"ALTER SYSTEM ALTER CONFIGURATION ('global.ini', 'System') SET ('expensive_statement', 'enable') = 'TRUE' WITH RECONFIGURE;\";\ | ||
hdbsql -U \"SYSDBKEY\" -e -ssltrustcert \"ALTER SYSTEM ALTER CONFIGURATION ('global.ini', 'System') SET ('expensive_statement', 'threshold_duration') = '0' WITH RECONFIGURE;\";\ | ||
hdbsql -U \"SYSDBKEY\" -e -ssltrustcert \"ALTER SYSTEM ALTER CONFIGURATION ('global.ini', 'System') SET ('expensive_statement', 'trace_parameter_values') = 'FALSE' WITH RECONFIGURE;\";\ | ||
hdbsql -U \"SYSDBKEY\" -e -ssltrustcert \"ALTER SYSTEM ALTER CONFIGURATION ('global.ini', 'System') SET ('expensive_statement', 'use_in_memory_tracing') = 'FALSE' WITH RECONFIGURE;\";\ | ||
" |