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

OpenCensus kind mapping and EH update #7624

Merged
merged 15 commits into from
Jan 2, 2020
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ def kind(self, value):
"""Set the span kind of this span."""
kind = (
OpenCensusSpanKind.CLIENT if value == SpanKind.CLIENT else
OpenCensusSpanKind.CLIENT if value == SpanKind.PRODUCER else # No producer in opencensus
OpenCensusSpanKind.SERVER if value == SpanKind.SERVER else
OpenCensusSpanKind.SERVER if value == SpanKind.CONSUMER else # No consumer in opencensus
OpenCensusSpanKind.UNSPECIFIED if value == SpanKind.UNSPECIFIED else
None
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,16 @@ def test_span_kind(self):
assert wrapped_class.span_instance.span_kind == OpenCensusSpanKind.CLIENT
assert wrapped_class.kind == SpanKind.CLIENT

# not supported
with pytest.raises(ValueError):
wrapped_class.kind = SpanKind.PRODUCER
# opencensus doesn't support producer, put client instead
wrapped_class.kind = SpanKind.PRODUCER
assert wrapped_class.span_instance.span_kind == OpenCensusSpanKind.CLIENT
assert wrapped_class.kind == SpanKind.CLIENT

with pytest.raises(ValueError):
wrapped_class.kind = SpanKind.CONSUMER
# opencensus doesn't support consumer, put server instead
wrapped_class.kind = SpanKind.CONSUMER
assert wrapped_class.span_instance.span_kind == OpenCensusSpanKind.SERVER
assert wrapped_class.kind == SpanKind.SERVER

# not supported
with pytest.raises(ValueError):
wrapped_class.kind = SpanKind.INTERNAL
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ async def send(
child = None
if span_impl_type is not None:
child = span_impl_type(name="Azure.EventHubs.send")
child.kind = SpanKind.CLIENT # Should be PRODUCER
child.kind = SpanKind.PRODUCER

self._check_closed()
if isinstance(event_data, EventData):
Expand Down
2 changes: 1 addition & 1 deletion sdk/eventhub/azure-eventhubs/azure/eventhub/producer.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ def send(self, event_data, partition_key=None, timeout=None):
child = None
if span_impl_type is not None:
child = span_impl_type(name="Azure.EventHubs.send")
child.kind = SpanKind.CLIENT # Should be PRODUCER
child.kind = SpanKind.PRODUCER

self._check_closed()
if isinstance(event_data, EventData):
Expand Down