Skip to content

Commit

Permalink
Address review notices.
Browse files Browse the repository at this point in the history
  • Loading branch information
jimf5 committed Dec 19, 2024
1 parent e625db7 commit 023ea79
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
13 changes: 6 additions & 7 deletions tests/test_otel.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
}
otel_trace on;
{{ res_attrs }}
{{ resource_attrs }}
server {
listen 127.0.0.1:18443 ssl;
Expand Down Expand Up @@ -271,7 +271,7 @@ def test_batches(client, trace_service, batch_count):
"nginx_config",
[
{
"res_attrs": """
"resource_attrs": """
otel_service_name "test_service";
otel_resource_attr my.name "my name";
otel_resource_attr my.service "my service";
Expand All @@ -283,11 +283,10 @@ def test_batches(client, trace_service, batch_count):
def test_custom_resource_attributes(client, trace_service):
assert client.get("http://127.0.0.1:18080/ok").status_code == 200

trace_service.wait_one_batch()
batch = trace_service.get_batch()

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

trace_service.batches.clear()
10 changes: 4 additions & 6 deletions tests/trace_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,16 @@ def Export(self, request, context):
self.batches.append(request.resource_spans)
return trace_service_pb2.ExportTracePartialSuccess()

def wait_one_batch(self):
def get_batch(self):
for _ in range(10):
if len(self.batches):
break
time.sleep(0.001)
assert len(self.batches) == 1, "No spans received"
assert len(self.batches) == 1
return self.batches.pop()

def get_span(self):
self.wait_one_batch()
span = self.batches[0][0].scope_spans[0].spans.pop()
self.batches.clear()
return span
return self.get_batch()[0].scope_spans[0].spans.pop()


@pytest.fixture(scope="module")
Expand Down

0 comments on commit 023ea79

Please sign in to comment.