Skip to content

Commit f42ac0e

Browse files
committed
clean up validation app
1 parent 94cf9ce commit f42ac0e

File tree

3 files changed

+89
-129
lines changed

3 files changed

+89
-129
lines changed
Lines changed: 38 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
name: Build, Test, and Publish ADOT OTLP UDP Exporter
22

33
on:
4+
push:
5+
branches:
6+
- "udp-*"
47
workflow_dispatch:
58
inputs:
69
version:
@@ -28,87 +31,58 @@ jobs:
2831
working-directory: exporters/aws-otel-otlp-udp-exporter
2932
run: hatch build
3033

31-
- name: Setup X-Ray daemon
34+
# TODO: Add unit tests step
35+
36+
- name: Download and run X-Ray Daemon
3237
run: |
33-
# Download X-Ray daemon
34-
wget https://s3.us-east-2.amazonaws.com/aws-xray-assets.us-east-2/xray-daemon/aws-xray-daemon-linux-3.x.zip
35-
unzip -o aws-xray-daemon-linux-3.x.zip
36-
37-
# Create config file
38-
echo '{
39-
"Version": 2,
40-
"TotalBufferSizeMB": 10,
41-
"Logging": {
42-
"LogLevel": "debug"
43-
},
44-
}' > xray-daemon-config.json
38+
mkdir xray-daemon
39+
cd xray-daemon
40+
wget https://s3.us-west-2.amazonaws.com/aws-xray-assets.us-west-2/xray-daemon/aws-xray-daemon-linux-3.x.zip
41+
unzip aws-xray-daemon-linux-3.x.zip
42+
./xray -o -n us-west-2 -f ./daemon-logs.log --log-level debug &
4543
46-
# Make sure xray is executable
47-
chmod +x ./xray
48-
49-
# Create logs directory
50-
mkdir -p daemon-logs
51-
52-
# Start X-Ray daemon
53-
./xray -o -n us-west-2 -c xray-daemon-config.json > daemon-logs/xray-daemon.log 2>&1 &
54-
XRAY_PID=$!
55-
echo "X-Ray daemon started with PID $XRAY_PID"
56-
57-
# Wait for daemon to be ready
58-
echo "Waiting for X-Ray daemon to start..."
44+
- name: Install UDP Exporter
45+
run: |
46+
pip install ./exporters/aws-otel-otlp-udp-exporter/dist/*.whl
47+
48+
- name: Install Flask
49+
run: |
50+
pip install flask
51+
52+
- name: Run Sample App in Background
53+
working-directory: sample-applications/integ-test-app
54+
run: |
55+
# Start validation app
56+
python udp_exporter_validation_app.py &
57+
# Wait for validation app to initialize
5958
sleep 5
60-
61-
# Check if process is still running
62-
if ps -p $XRAY_PID > /dev/null; then
63-
echo "✅ X-Ray daemon process is running"
64-
else
65-
echo "❌ X-Ray daemon process is not running"
66-
echo "Log contents:"
67-
cat daemon-logs/xray-daemon.log
68-
exit 1
69-
fi
70-
71-
# Try to connect to the daemon
72-
if nc -zv 127.0.0.1 2000 2>&1; then
73-
echo "✅ Successfully connected to X-Ray daemon on port 2000"
74-
else
75-
echo "❌ Cannot connect to X-Ray daemon on port 2000"
76-
echo "Log contents:"
77-
cat daemon-logs/xray-daemon.log
78-
exit 1
79-
fi
80-
81-
# Extra verification with curl (might not work depending on daemon setup)
82-
if curl -s http://localhost:2000/GetDaemonVersion; then
83-
echo "✅ X-Ray daemon API responded"
84-
else
85-
echo "ℹ️ X-Ray daemon doesn't support API or not ready yet"
86-
# Don't exit with error as this might not be reliable
87-
fi
88-
89-
echo "X-Ray daemon setup completed"
9059
91-
- name: Setup validation app
60+
- name: Call Sample App Endpoint
9261
run: |
93-
pip install ./exporters/aws-otel-otlp-udp-exporter/dist/*.whl
62+
# Trigger trace generation
63+
echo "traceId=$(curl localhost:8080/test)" >> $GITHUB_OUTPUT
64+
echo $traceId
9465
95-
- name: Run validation test
96-
working-directory: exporters/aws-otel-otlp-udp-exporter/validation-app
97-
run: python app.py
66+
- name: Print Daemon Logs
67+
run: |
68+
sleep 20
69+
cat xray-daemon/daemon-logs.log
9870
9971
- name: Verify X-Ray daemon received traces
10072
run: |
10173
echo "X-Ray daemon logs:"
102-
cat daemon-logs/xray-daemon.log
74+
cat xray-daemon/daemon-logs.log
10375
10476
# Check if the daemon received and processed some data
105-
if grep -q "sending.*batch" daemon-logs/xray-daemon.log; then
77+
if grep -q "sending.*batch" xray-daemon/daemon-logs.log; then
10678
echo "✅ X-Ray daemon processed trace data (AWS upload errors are expected)"
10779
exit 0
108-
elif grep -q "processor:.*segment" daemon-logs/xray-daemon.log; then
80+
elif grep -q "processor:.*segment" xray-daemon/daemon-logs.log; then
10981
echo "✅ X-Ray daemon processed segment data (AWS upload errors are expected)"
11082
exit 0
11183
else
11284
echo "❌ No evidence of traces being received by X-Ray daemon"
11385
exit 1
11486
fi
87+
88+
# TODO: Steps to publish to PyPI

exporters/aws-otel-otlp-udp-exporter/validation-app/app.py

Lines changed: 0 additions & 65 deletions
This file was deleted.
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import socket
2+
import threading
3+
import time
4+
from flask import Flask, jsonify
5+
6+
from amazon.opentelemetry.exporters.otlp.udp import OTLPUdpSpanExporter
7+
from opentelemetry import trace
8+
from opentelemetry.sdk.trace import TracerProvider
9+
from opentelemetry.sdk.trace.export import BatchSpanProcessor
10+
11+
app = Flask(__name__)
12+
13+
# Set up tracer provider
14+
tracer_provider = TracerProvider()
15+
trace.set_tracer_provider(tracer_provider)
16+
17+
# Set up UDP exporter with batch processor
18+
exporter = OTLPUdpSpanExporter(endpoint="127.0.0.1:2000")
19+
span_processor = BatchSpanProcessor(exporter)
20+
tracer_provider.add_span_processor(span_processor)
21+
22+
# Get tracer
23+
tracer = trace.get_tracer(__name__)
24+
25+
@app.route('/test', methods=['GET'])
26+
def create_trace():
27+
# Create a span for testing with various attributes
28+
tracer = trace.get_tracer(__name__)
29+
with tracer.start_as_current_span("test_parent_span") as parent:
30+
parent.set_attribute("service.name", "validation-app")
31+
parent.set_attribute("test.attribute", "test_value")
32+
parent.add_event("test-event", {"event.data": "some data"})
33+
34+
# Get the trace ID
35+
trace_id = format(parent.get_span_context().trace_id, '032x')
36+
37+
# Add a child span
38+
with tracer.start_as_current_span("test_child_span") as child:
39+
child.set_attribute("child.attribute", "child_value")
40+
print("Created spans with attributes and events")
41+
42+
# Force flush to ensure spans are exported immediately
43+
success = tracer_provider.force_flush()
44+
print(f"Force flush {'succeeded' if success else 'failed'}")
45+
46+
return jsonify({
47+
"trace_id": trace_id
48+
})
49+
50+
if __name__ == '__main__':
51+
app.run(port=8080)

0 commit comments

Comments
 (0)