Skip to content

Commit 04f3633

Browse files
committed
get span kind CLIENT
1 parent 2787ca2 commit 04f3633

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

swagger_zipkin/otel_decorator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ def inject_zipkin_headers(
123123

124124

125125
class OtelClientDecorator:
126-
"""A wrapper to swagger client (swagger-py or bravado) to pass on zipkin
127-
headers to the service call.
126+
"""A wrapper to swagger client (swagger-py or bravado) to pass on otel and zipkin
127+
headers to the service call. It will also generate a CLIENT span for the outgoing call.
128128
129129
Even though client is initialised once, all the calls made will have
130130
independent spans.

tests/otel_decorator_test.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import pytest
44
from opentelemetry import trace
5+
from opentelemetry.trace import SpanKind
56
from opentelemetry.sdk.trace import TracerProvider
67
from opentelemetry.sdk.trace.export import SimpleSpanProcessor
78
from opentelemetry.sdk.trace.export.in_memory_span_exporter import InMemorySpanExporter
@@ -80,6 +81,7 @@ def test_client_request(mock_request, get_request, setup):
8081
_request_options=create_request_options(parent_span, exported_span)
8182
)
8283

84+
assert exported_span.kind == SpanKind.CLIENT
8385
assert exported_span.name == f"{get_request.method} {get_request.matched_route}"
8486
assert exported_span.attributes["url.path"] == get_request.path
8587
assert exported_span.attributes["http.request.method"] == get_request.method
@@ -136,6 +138,7 @@ def test_client_request_no_parent_span(mock_request, get_request, setup):
136138
_request_options=create_request_options(None, exported_span)
137139
)
138140

141+
assert exported_span.kind == SpanKind.CLIENT
139142
assert exported_span.name == f"{get_request.method} {get_request.matched_route}"
140143
assert exported_span.attributes["url.path"] == get_request.path
141144
assert exported_span.attributes["http.request.method"] == get_request.method
@@ -174,6 +177,7 @@ def test_with_headers_exception(mock_request, get_request, setup):
174177
actual_headers = create_request_options(None, exported_span)['headers']
175178
assert expected_headers == actual_headers
176179

180+
assert exported_span.kind == SpanKind.CLIENT
177181
assert exported_span.name == f"{get_request.method} {get_request.matched_route}"
178182
assert exported_span.attributes["url.path"] == get_request.path
179183
assert exported_span.attributes["http.request.method"] == get_request.method

0 commit comments

Comments
 (0)