Skip to content

Commit bef27d4

Browse files
committed
Address review notices.
1 parent 348c6ae commit bef27d4

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

tests/test_otel.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
}
2929
3030
otel_trace on;
31-
{{ service_name }}
3231
{{ res_attrs }}
3332
3433
server {
@@ -272,22 +271,19 @@ def test_batches(client, trace_service, batch_count):
272271
"nginx_config",
273272
[
274273
{
275-
"service_name": 'otel_service_name "test_service";',
276-
"res_attrs": 'otel_resource_attr my.name "my name";\n'
277-
+ 'otel_resource_attr my.service "my service";',
274+
"res_attrs": """
275+
otel_service_name "test_service";
276+
otel_resource_attr my.name "my name";
277+
otel_resource_attr my.service "my service";
278+
""",
278279
}
279280
],
280281
indirect=True,
281282
)
282283
def test_custom_resource_attributes(client, trace_service):
283284
assert client.get("http://127.0.0.1:18080/ok").status_code == 200
284285

285-
for _ in range(10):
286-
if len(trace_service.batches):
287-
break
288-
time.sleep(0.001)
289-
290-
assert len(trace_service.batches) == 1
286+
trace_service.wait_batch()
291287

292288
for batch in trace_service.batches:
293289
assert get_attr(batch[0].resource, "service.name") == "test_service"

tests/trace_service.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,15 @@ def Export(self, request, context):
1414
self.batches.append(request.resource_spans)
1515
return trace_service_pb2.ExportTracePartialSuccess()
1616

17-
def get_span(self):
17+
def wait_batch(self):
1818
for _ in range(10):
1919
if len(self.batches):
2020
break
2121
time.sleep(0.001)
22-
2322
assert len(self.batches) == 1, "No spans received"
23+
24+
def get_span(self):
25+
self.wait_batch()
2426
span = self.batches[0][0].scope_spans[0].spans.pop()
2527
self.batches.clear()
2628
return span

0 commit comments

Comments
 (0)