generated from amazon-archives/__template_Apache-2.0
-
Notifications
You must be signed in to change notification settings - Fork 27
Set up UDP Release Workflow #333
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
yiyuan-he
merged 6 commits into
aws-observability:main
from
yiyuan-he:udp-release-workflow
Mar 5, 2025
Merged
Changes from 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
1b13ee7
set up release udp exporter gh workflow
yiyuan-he ab18595
remove on push dispatch for udp validation workflow
yiyuan-he 94cf9ce
apply black formatting
yiyuan-he bf11d7f
clean up validation app workflow and move lambda env check
yiyuan-he bbb2498
some small updates
yiyuan-he d0ea21d
rename udp release workflow
yiyuan-he File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,114 @@ | ||
| name: Build, Test, and Publish ADOT OTLP UDP Exporter | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| version: | ||
| description: 'Version number for deployment e.g. 0.1.0' | ||
| required: true | ||
| type: string | ||
|
|
||
| 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 '{ | ||
| "Version": 2, | ||
| "TotalBufferSizeMB": 10, | ||
| "Logging": { | ||
| "LogLevel": "debug" | ||
| }, | ||
| }' > xray-daemon-config.json | ||
|
|
||
| # Make sure xray is executable | ||
| chmod +x ./xray | ||
|
|
||
| # Create logs directory | ||
| mkdir -p daemon-logs | ||
|
|
||
| # Start X-Ray daemon | ||
| ./xray -o -n us-west-2 -c xray-daemon-config.json > daemon-logs/xray-daemon.log 2>&1 & | ||
jj22ee marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| XRAY_PID=$! | ||
| echo "X-Ray daemon started with PID $XRAY_PID" | ||
|
|
||
| # Wait for daemon to be ready | ||
| echo "Waiting for X-Ray daemon to start..." | ||
| sleep 5 | ||
|
|
||
| # Check if process is still running | ||
| if ps -p $XRAY_PID > /dev/null; then | ||
| echo "✅ X-Ray daemon process is running" | ||
| else | ||
| echo "❌ X-Ray daemon process is not running" | ||
| echo "Log contents:" | ||
| cat daemon-logs/xray-daemon.log | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Try to connect to the daemon | ||
| if nc -zv 127.0.0.1 2000 2>&1; then | ||
| echo "✅ Successfully connected to X-Ray daemon on port 2000" | ||
| else | ||
| echo "❌ Cannot connect to X-Ray daemon on port 2000" | ||
| echo "Log contents:" | ||
| cat daemon-logs/xray-daemon.log | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Extra verification with curl (might not work depending on daemon setup) | ||
| if curl -s http://localhost:2000/GetDaemonVersion; then | ||
| echo "✅ X-Ray daemon API responded" | ||
| else | ||
| echo "ℹ️ X-Ray daemon doesn't support API or not ready yet" | ||
| # Don't exit with error as this might not be reliable | ||
| fi | ||
jj22ee marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| echo "X-Ray daemon setup completed" | ||
|
|
||
| - name: Setup validation app | ||
| run: | | ||
| pip install ./exporters/aws-otel-otlp-udp-exporter/dist/*.whl | ||
|
|
||
| - name: Run validation test | ||
| working-directory: exporters/aws-otel-otlp-udp-exporter/validation-app | ||
| run: python app.py | ||
|
|
||
| - name: Verify X-Ray daemon received traces | ||
| run: | | ||
| echo "X-Ray daemon logs:" | ||
| cat daemon-logs/xray-daemon.log | ||
|
|
||
| # Check if the daemon received and processed some data | ||
| if grep -q "sending.*batch" daemon-logs/xray-daemon.log; then | ||
| echo "✅ X-Ray daemon processed trace data (AWS upload errors are expected)" | ||
| exit 0 | ||
| elif grep -q "processor:.*segment" daemon-logs/xray-daemon.log; then | ||
| echo "✅ X-Ray daemon processed segment data (AWS upload errors are expected)" | ||
| exit 0 | ||
| else | ||
| echo "❌ No evidence of traces being received by X-Ray daemon" | ||
| exit 1 | ||
| fi | ||
jj22ee marked this conversation as resolved.
Show resolved
Hide resolved
|
||
65 changes: 65 additions & 0 deletions
65
exporters/aws-otel-otlp-udp-exporter/validation-app/app.py
jj22ee marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| import socket | ||
| import threading | ||
| import time | ||
|
|
||
| from amazon.opentelemetry.exporters.otlp.udp import OTLPUdpSpanExporter | ||
| from opentelemetry import trace | ||
| from opentelemetry.sdk.trace import TracerProvider | ||
| from opentelemetry.sdk.trace.export import BatchSpanProcessor | ||
|
|
||
|
|
||
| # Set up a UDP server to verify data is sent | ||
| def udp_server(): | ||
jj22ee marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| 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") | ||
jj22ee marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.