Skip to content
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

Update core pipeline to adapt to OT 1.0 #17785

Merged
merged 5 commits into from
Apr 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ def test_set_http_attributes(self):
setattr(request, "headers", {})
setattr(response, "status_code", 200)
wrapped_class.set_http_attributes(request)
assert wrapped_class.span_instance.span_kind == OpenCensusSpanKind.CLIENT
assert wrapped_class.span_instance.attributes.get("http.method") == request.method
assert wrapped_class.span_instance.attributes.get("component") == "http"
assert wrapped_class.span_instance.attributes.get("http.url") == request.url
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ def test_set_http_attributes(self, tracer):
setattr(request, "headers", {})
setattr(response, "status_code", 200)
wrapped_class.set_http_attributes(request)
assert wrapped_class.span_instance.kind == OpenTelemetrySpanKind.CLIENT
assert wrapped_class.span_instance.attributes.get("http.method") == request.method
assert wrapped_class.span_instance.attributes.get("component") == "http"
assert wrapped_class.span_instance.attributes.get("http.url") == request.url
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

from azure.core.pipeline.policies import SansIOHTTPPolicy
from azure.core.settings import settings
from azure.core.tracing import SpanKind

try:
from typing import TYPE_CHECKING
Expand Down Expand Up @@ -90,7 +91,7 @@ def on_request(self, request):
namer = ctxt.pop('network_span_namer', self._network_span_namer)
span_name = namer(request.http_request)

span = span_impl_type(name=span_name)
span = span_impl_type(name=span_name, kind=SpanKind.CLIENT)
for attr, value in self._tracing_attributes.items():
span.add_attribute(attr, value)
span.start()
Expand Down
1 change: 0 additions & 1 deletion sdk/core/azure-core/azure/core/tracing/_abstract_span.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,6 @@ def set_http_attributes(self, request, response=None):
:param response: The response received by the server. Is None if no response received.
:type response: ~azure.core.pipeline.transport.HttpResponse or ~azure.core.pipeline.transport.AsyncHttpResponse
"""
self.kind = SpanKind.CLIENT
self.add_attribute(self._SPAN_COMPONENT, "http")
self.add_attribute(self._HTTP_METHOD, request.method)
self.add_attribute(self._HTTP_URL, request.url)
Expand Down
4 changes: 2 additions & 2 deletions sdk/core/azure-core/tests/tracing_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class FakeSpan(HttpSpanMixin, object):
# Keep a fake context of the current one
CONTEXT = []

def __init__(self, span=None, name="span"):
def __init__(self, span=None, name="span", kind=None):
# type: (Optional[Span], Optional[str]) -> None
"""
If a span is not passed in, creates a new tracer. If the instrumentation key for Azure Exporter is given, will
Expand All @@ -35,7 +35,7 @@ def __init__(self, span=None, name="span"):
"""
self._span = span
self.name = name
self._kind = SpanKind.UNSPECIFIED
self._kind = kind or SpanKind.UNSPECIFIED
self.attributes = {}
self.children = []
if self.CONTEXT:
Expand Down