fix x-ray daemon setup in workflow #7
Workflow file for this run
This file contains hidden or 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
| name: Build, Test, and Publish ADOT OTLP UDP Exporter | |
| on: | |
| push: | |
| branches: | |
| - "udp-*" | |
| workflow_dispatch: | |
| jobs: | |
| build-test-publish: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.10' | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install hatch pytest | |
| - name: Build package | |
| working-directory: exporters/aws-otel-otlp-udp-exporter | |
| run: hatch build | |
| - name: Setup X-Ray daemon | |
| run: | | |
| # Download X-Ray daemon | |
| wget https://s3.us-east-2.amazonaws.com/aws-xray-assets.us-east-2/xray-daemon/aws-xray-daemon-linux-3.x.zip | |
| unzip -o aws-xray-daemon-linux-3.x.zip | |
| # Create config file | |
| echo '{ | |
| "TotalBufferSizeMB": 10, | |
| "Logging": { | |
| "LogLevel": "debug" | |
| } | |
| }' > xray-daemon-config.json | |
| # Start X-Ray daemon with a unique log file | |
| mkdir -p daemon-logs | |
| ./xray -o -n us-west-2 -c xray-daemon-config.json > daemon-logs/xray-daemon.log 2>&1 & | |
| echo "X-Ray daemon started with PID $!" | |
| # Wait a bit for the daemon to start | |
| sleep 3 | |
| # Verify daemon is running | |
| ps aux | grep xray | |
| curl -s http://localhost:2000/GetDaemonVersion | |
| - name: Setup validation app | |
| run: | | |
| mkdir -p validation_app | |
| cd validation_app | |
| pip install ../exporters/aws-otel-otlp-udp-exporter/dist/*.whl | |
| - name: Create test script | |
| working-directory: validation_app | |
| run: | | |
| cat > test_exporter.py << 'EOF' | |
| import socket | |
| import threading | |
| import time | |
| from opentelemetry import trace | |
| from opentelemetry.sdk.trace import TracerProvider | |
| from opentelemetry.sdk.trace.export import BatchSpanProcessor | |
| from amazon.opentelemetry.exporters.otlp.udp import OTLPUdpSpanExporter | |
| # Set up a UDP server to verify data is sent | |
| def udp_server(): | |
| sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) | |
| sock.bind(('127.0.0.1', 2000)) | |
| sock.settimeout(5) | |
| print("UDP server listening on 127.0.0.1:2000") | |
| try: | |
| data, addr = sock.recvfrom(4096) | |
| print(f"Received data from {addr}") | |
| if data: | |
| print("✅ Successfully received exported span data") | |
| return True | |
| except socket.timeout: | |
| print("❌ No data received within timeout period") | |
| return False | |
| finally: | |
| sock.close() | |
| # Start UDP server in a separate thread | |
| server_thread = threading.Thread(target=udp_server) | |
| server_thread.daemon = True | |
| server_thread.start() | |
| # Set up tracer provider | |
| tracer_provider = TracerProvider() | |
| trace.set_tracer_provider(tracer_provider) | |
| # Set up UDP exporter with batch processor (more realistic usage) | |
| exporter = OTLPUdpSpanExporter(endpoint="127.0.0.1:2000") | |
| span_processor = BatchSpanProcessor(exporter) | |
| tracer_provider.add_span_processor(span_processor) | |
| # Create a span for testing with various attributes | |
| tracer = trace.get_tracer(__name__) | |
| with tracer.start_as_current_span("test_parent_span") as parent: | |
| parent.set_attribute("service.name", "validation-app") | |
| parent.set_attribute("test.attribute", "test_value") | |
| parent.add_event("test-event", {"event.data": "some data"}) | |
| # Add a child span | |
| with tracer.start_as_current_span("test_child_span") as child: | |
| child.set_attribute("child.attribute", "child_value") | |
| print("Created spans with attributes and events") | |
| # Force flush to ensure spans are exported immediately | |
| success = tracer_provider.force_flush() | |
| print(f"Force flush {'succeeded' if success else 'failed'}") | |
| # Give some time for the UDP packet to be processed | |
| time.sleep(2) | |
| # Shutdown | |
| tracer_provider.shutdown() | |
| print("Test completed") | |
| EOF | |
| - name: Run validation test | |
| working-directory: validation_app | |
| run: python test_exporter.py | |
| - name: Verify X-Ray daemon recieved traces | |
| run: | | |
| echo "X-Ray daemon logs:" | |
| cat daemon-logs/xray-daemon.log | |
| # Check if the daemon received segments | |
| if grep -q "Received segment" daemon-logs/xray-daemon.log; then | |
| echo "✅ X-Ray daemon successfully received trace segments" | |
| exit 0 | |
| else | |
| echo "❌ No trace segments received by X-Ray daemon" | |
| exit 1 | |
| fi |