Skip to content

Commit 1b13ee7

Browse files
committed
set up release udp exporter gh workflow
1 parent 5d41039 commit 1b13ee7

File tree

2 files changed

+179
-0
lines changed

2 files changed

+179
-0
lines changed
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
name: Build, Test, and Publish ADOT OTLP UDP Exporter
2+
3+
on:
4+
push:
5+
branches:
6+
- "udp-*"
7+
workflow_dispatch:
8+
inputs:
9+
version:
10+
description: 'Version number for deployment e.g. 0.1.0'
11+
required: true
12+
type: string
13+
14+
jobs:
15+
build-test-publish:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v3
19+
20+
- name: Set up Python
21+
uses: actions/setup-python@v4
22+
with:
23+
python-version: '3.10'
24+
25+
- name: Install dependencies
26+
run: |
27+
python -m pip install --upgrade pip
28+
pip install hatch pytest
29+
30+
- name: Build package
31+
working-directory: exporters/aws-otel-otlp-udp-exporter
32+
run: hatch build
33+
34+
- name: Setup X-Ray daemon
35+
run: |
36+
# Download X-Ray daemon
37+
wget https://s3.us-east-2.amazonaws.com/aws-xray-assets.us-east-2/xray-daemon/aws-xray-daemon-linux-3.x.zip
38+
unzip -o aws-xray-daemon-linux-3.x.zip
39+
40+
# Create config file
41+
echo '{
42+
"Version": 2,
43+
"TotalBufferSizeMB": 10,
44+
"Logging": {
45+
"LogLevel": "debug"
46+
},
47+
}' > xray-daemon-config.json
48+
49+
# Make sure xray is executable
50+
chmod +x ./xray
51+
52+
# Create logs directory
53+
mkdir -p daemon-logs
54+
55+
# Start X-Ray daemon
56+
./xray -o -n us-west-2 -c xray-daemon-config.json > daemon-logs/xray-daemon.log 2>&1 &
57+
XRAY_PID=$!
58+
echo "X-Ray daemon started with PID $XRAY_PID"
59+
60+
# Wait for daemon to be ready
61+
echo "Waiting for X-Ray daemon to start..."
62+
sleep 5
63+
64+
# Check if process is still running
65+
if ps -p $XRAY_PID > /dev/null; then
66+
echo "✅ X-Ray daemon process is running"
67+
else
68+
echo "❌ X-Ray daemon process is not running"
69+
echo "Log contents:"
70+
cat daemon-logs/xray-daemon.log
71+
exit 1
72+
fi
73+
74+
# Try to connect to the daemon
75+
if nc -zv 127.0.0.1 2000 2>&1; then
76+
echo "✅ Successfully connected to X-Ray daemon on port 2000"
77+
else
78+
echo "❌ Cannot connect to X-Ray daemon on port 2000"
79+
echo "Log contents:"
80+
cat daemon-logs/xray-daemon.log
81+
exit 1
82+
fi
83+
84+
# Extra verification with curl (might not work depending on daemon setup)
85+
if curl -s http://localhost:2000/GetDaemonVersion; then
86+
echo "✅ X-Ray daemon API responded"
87+
else
88+
echo "ℹ️ X-Ray daemon doesn't support API or not ready yet"
89+
# Don't exit with error as this might not be reliable
90+
fi
91+
92+
echo "X-Ray daemon setup completed"
93+
94+
- name: Setup validation app
95+
run: |
96+
pip install ./exporters/aws-otel-otlp-udp-exporter/dist/*.whl
97+
98+
- name: Run validation test
99+
working-directory: exporters/aws-otel-otlp-udp-exporter/validation-app
100+
run: python app.py
101+
102+
- name: Verify X-Ray daemon received traces
103+
run: |
104+
echo "X-Ray daemon logs:"
105+
cat daemon-logs/xray-daemon.log
106+
107+
# Check if the daemon received and processed some data
108+
if grep -q "sending.*batch" daemon-logs/xray-daemon.log; then
109+
echo "✅ X-Ray daemon processed trace data (AWS upload errors are expected)"
110+
exit 0
111+
elif grep -q "processor:.*segment" daemon-logs/xray-daemon.log; then
112+
echo "✅ X-Ray daemon processed segment data (AWS upload errors are expected)"
113+
exit 0
114+
else
115+
echo "❌ No evidence of traces being received by X-Ray daemon"
116+
exit 1
117+
fi
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import socket
2+
import threading
3+
import time
4+
from opentelemetry import trace
5+
from opentelemetry.sdk.trace import TracerProvider
6+
from opentelemetry.sdk.trace.export import BatchSpanProcessor
7+
from amazon.opentelemetry.exporters.otlp.udp import OTLPUdpSpanExporter
8+
9+
# Set up a UDP server to verify data is sent
10+
def udp_server():
11+
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
12+
sock.bind(('127.0.0.1', 2000))
13+
sock.settimeout(5)
14+
print("UDP server listening on 127.0.0.1:2000")
15+
try:
16+
data, addr = sock.recvfrom(4096)
17+
print(f"Received data from {addr}")
18+
if data:
19+
print("✅ Successfully received exported span data")
20+
return True
21+
except socket.timeout:
22+
print("❌ No data received within timeout period")
23+
return False
24+
finally:
25+
sock.close()
26+
27+
# Start UDP server in a separate thread
28+
server_thread = threading.Thread(target=udp_server)
29+
server_thread.daemon = True
30+
server_thread.start()
31+
32+
# Set up tracer provider
33+
tracer_provider = TracerProvider()
34+
trace.set_tracer_provider(tracer_provider)
35+
36+
# Set up UDP exporter with batch processor (more realistic usage)
37+
exporter = OTLPUdpSpanExporter(endpoint="127.0.0.1:2000")
38+
span_processor = BatchSpanProcessor(exporter)
39+
tracer_provider.add_span_processor(span_processor)
40+
41+
# Create a span for testing with various attributes
42+
tracer = trace.get_tracer(__name__)
43+
with tracer.start_as_current_span("test_parent_span") as parent:
44+
parent.set_attribute("service.name", "validation-app")
45+
parent.set_attribute("test.attribute", "test_value")
46+
parent.add_event("test-event", {"event.data": "some data"})
47+
48+
# Add a child span
49+
with tracer.start_as_current_span("test_child_span") as child:
50+
child.set_attribute("child.attribute", "child_value")
51+
print("Created spans with attributes and events")
52+
53+
# Force flush to ensure spans are exported immediately
54+
success = tracer_provider.force_flush()
55+
print(f"Force flush {'succeeded' if success else 'failed'}")
56+
57+
# Give some time for the UDP packet to be processed
58+
time.sleep(2)
59+
60+
# Shutdown
61+
tracer_provider.shutdown()
62+
print("Test completed")

0 commit comments

Comments
 (0)