|
| 1 | +name: Build, Test, and Publish ADOT OTLP UDP Exporter |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + version: |
| 7 | + description: 'Version number for deployment e.g. 0.1.0' |
| 8 | + required: true |
| 9 | + type: string |
| 10 | + |
| 11 | +jobs: |
| 12 | + build-test-publish: |
| 13 | + runs-on: ubuntu-latest |
| 14 | + steps: |
| 15 | + - uses: actions/checkout@v3 |
| 16 | + |
| 17 | + - name: Set up Python |
| 18 | + uses: actions/setup-python@v4 |
| 19 | + with: |
| 20 | + python-version: '3.10' |
| 21 | + |
| 22 | + - name: Install dependencies |
| 23 | + run: | |
| 24 | + python -m pip install --upgrade pip |
| 25 | + pip install hatch pytest |
| 26 | +
|
| 27 | + - name: Build package |
| 28 | + working-directory: exporters/aws-otel-otlp-udp-exporter |
| 29 | + run: hatch build |
| 30 | + |
| 31 | + - name: Setup X-Ray daemon |
| 32 | + 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 |
| 45 | +
|
| 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..." |
| 59 | + 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" |
| 90 | +
|
| 91 | + - name: Setup validation app |
| 92 | + run: | |
| 93 | + mkdir -p validation_app |
| 94 | + cd validation_app |
| 95 | + pip install ../exporters/aws-otel-otlp-udp-exporter/dist/*.whl |
| 96 | +
|
| 97 | + - name: Create test script |
| 98 | + working-directory: validation_app |
| 99 | + run: | |
| 100 | + cat > test_exporter.py << 'EOF' |
| 101 | + import socket |
| 102 | + import threading |
| 103 | + import time |
| 104 | + from opentelemetry import trace |
| 105 | + from opentelemetry.sdk.trace import TracerProvider |
| 106 | + from opentelemetry.sdk.trace.export import BatchSpanProcessor |
| 107 | + from amazon.opentelemetry.exporters.otlp.udp import OTLPUdpSpanExporter |
| 108 | + |
| 109 | + # Set up a UDP server to verify data is sent |
| 110 | + def udp_server(): |
| 111 | + sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) |
| 112 | + sock.bind(('127.0.0.1', 2000)) |
| 113 | + sock.settimeout(5) |
| 114 | + print("UDP server listening on 127.0.0.1:2000") |
| 115 | + try: |
| 116 | + data, addr = sock.recvfrom(4096) |
| 117 | + print(f"Received data from {addr}") |
| 118 | + if data: |
| 119 | + print("✅ Successfully received exported span data") |
| 120 | + return True |
| 121 | + except socket.timeout: |
| 122 | + print("❌ No data received within timeout period") |
| 123 | + return False |
| 124 | + finally: |
| 125 | + sock.close() |
| 126 | + |
| 127 | + # Start UDP server in a separate thread |
| 128 | + server_thread = threading.Thread(target=udp_server) |
| 129 | + server_thread.daemon = True |
| 130 | + server_thread.start() |
| 131 | + |
| 132 | + # Set up tracer provider |
| 133 | + tracer_provider = TracerProvider() |
| 134 | + trace.set_tracer_provider(tracer_provider) |
| 135 | + |
| 136 | + # Set up UDP exporter with batch processor (more realistic usage) |
| 137 | + exporter = OTLPUdpSpanExporter(endpoint="127.0.0.1:2000") |
| 138 | + span_processor = BatchSpanProcessor(exporter) |
| 139 | + tracer_provider.add_span_processor(span_processor) |
| 140 | + |
| 141 | + # Create a span for testing with various attributes |
| 142 | + tracer = trace.get_tracer(__name__) |
| 143 | + with tracer.start_as_current_span("test_parent_span") as parent: |
| 144 | + parent.set_attribute("service.name", "validation-app") |
| 145 | + parent.set_attribute("test.attribute", "test_value") |
| 146 | + parent.add_event("test-event", {"event.data": "some data"}) |
| 147 | + |
| 148 | + # Add a child span |
| 149 | + with tracer.start_as_current_span("test_child_span") as child: |
| 150 | + child.set_attribute("child.attribute", "child_value") |
| 151 | + print("Created spans with attributes and events") |
| 152 | + |
| 153 | + # Force flush to ensure spans are exported immediately |
| 154 | + success = tracer_provider.force_flush() |
| 155 | + print(f"Force flush {'succeeded' if success else 'failed'}") |
| 156 | + |
| 157 | + # Give some time for the UDP packet to be processed |
| 158 | + time.sleep(2) |
| 159 | + |
| 160 | + # Shutdown |
| 161 | + tracer_provider.shutdown() |
| 162 | + print("Test completed") |
| 163 | + EOF |
| 164 | +
|
| 165 | + - name: Run validation test |
| 166 | + working-directory: validation_app |
| 167 | + run: python test_exporter.py |
| 168 | + |
| 169 | + - name: Verify X-Ray daemon received traces |
| 170 | + run: | |
| 171 | + echo "X-Ray daemon logs:" |
| 172 | + cat daemon-logs/xray-daemon.log |
| 173 | +
|
| 174 | + # Check if the daemon received and processed some data |
| 175 | + if grep -q "sending.*batch" daemon-logs/xray-daemon.log; then |
| 176 | + echo "✅ X-Ray daemon processed trace data (AWS upload errors are expected)" |
| 177 | + exit 0 |
| 178 | + elif grep -q "processor:.*segment" daemon-logs/xray-daemon.log; then |
| 179 | + echo "✅ X-Ray daemon processed segment data (AWS upload errors are expected)" |
| 180 | + exit 0 |
| 181 | + else |
| 182 | + echo "❌ No evidence of traces being received by X-Ray daemon" |
| 183 | + exit 1 |
| 184 | + fi |
0 commit comments