def test_span_kind(self): with ContextHelper(): trace = tracer_module.Tracer(sampler=AlwaysOnSampler()) parent = trace.start_span() wrapped_class = OpenCensusSpan(span=parent) wrapped_class.kind = SpanKind.UNSPECIFIED assert wrapped_class.span_instance.span_kind == OpenCensusSpanKind.UNSPECIFIED assert wrapped_class.kind == SpanKind.UNSPECIFIED wrapped_class.kind = SpanKind.SERVER assert wrapped_class.span_instance.span_kind == OpenCensusSpanKind.SERVER assert wrapped_class.kind == SpanKind.SERVER wrapped_class.kind = SpanKind.CLIENT 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 with pytest.raises(ValueError): wrapped_class.kind = SpanKind.CONSUMER with pytest.raises(ValueError): wrapped_class.kind = SpanKind.INTERNAL
def test_span_kind(self): with ContextHelper(): trace = tracer_module.Tracer(sampler=AlwaysOnSampler()) parent = trace.start_span() wrapped_class = OpenCensusSpan(span=parent) wrapped_class.kind = SpanKind.UNSPECIFIED assert wrapped_class.span_instance.span_kind == OpenCensusSpanKind.UNSPECIFIED assert wrapped_class.kind == SpanKind.UNSPECIFIED wrapped_class.kind = SpanKind.SERVER assert wrapped_class.span_instance.span_kind == OpenCensusSpanKind.SERVER assert wrapped_class.kind == SpanKind.SERVER wrapped_class.kind = SpanKind.CLIENT assert wrapped_class.span_instance.span_kind == OpenCensusSpanKind.CLIENT assert wrapped_class.kind == SpanKind.CLIENT # 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 # opencensus doesn't support consumer, put client instead wrapped_class.kind = SpanKind.CONSUMER assert wrapped_class.span_instance.span_kind == OpenCensusSpanKind.CLIENT assert wrapped_class.kind == SpanKind.CLIENT # opencensus doesn't support consumer, put client instead wrapped_class.kind = SpanKind.INTERNAL assert wrapped_class.span_instance.span_kind == OpenCensusSpanKind.UNSPECIFIED assert wrapped_class.kind == SpanKind.UNSPECIFIED