|
1 | 1 | name: Build, Test, and Publish ADOT OTLP UDP Exporter |
2 | 2 |
|
3 | 3 | on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - "udp-*" |
4 | 7 | workflow_dispatch: |
5 | 8 | inputs: |
6 | 9 | version: |
@@ -90,81 +93,11 @@ jobs: |
90 | 93 |
|
91 | 94 | - name: Setup validation app |
92 | 95 | run: | |
93 | | - mkdir -p validation_app |
94 | | - cd validation_app |
95 | 96 | pip install ../exporters/aws-otel-otlp-udp-exporter/dist/*.whl |
96 | 97 |
|
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 | 98 | - name: Run validation test |
166 | | - working-directory: validation_app |
167 | | - run: python test_exporter.py |
| 99 | + working-directory: exporters/aws-otel-otlp-udp-exporter/validation_app |
| 100 | + run: python app.py |
168 | 101 |
|
169 | 102 | - name: Verify X-Ray daemon received traces |
170 | 103 | run: | |
|
0 commit comments