11# (c) Copyright IBM Corp. 2024
22
33from typing import Generator , Tuple
4-
54import pytest
5+ from opentelemetry .trace import SpanKind
66
77from instana .recorder import StanRecorder
88from instana .span .sdk_span import SDKSpan
@@ -24,12 +24,11 @@ def test_sdkspan(
2424 span_name = "test-sdk-span"
2525 service_name = "test-sdk"
2626 attributes = {
27- "span.kind" : "entry" ,
2827 "arguments" : "--quiet" ,
2928 "return" : "True" ,
3029 }
3130 self .span = InstanaSpan (
32- span_name , span_context , span_processor , attributes = attributes
31+ span_name , span_context , span_processor , attributes = attributes , kind = SpanKind . SERVER
3332 )
3433 sdk_span = SDKSpan (self .span , None , service_name )
3534
@@ -40,9 +39,9 @@ def test_sdkspan(
4039 "service" : service_name ,
4140 "sdk" : {
4241 "name" : span_name ,
43- "type" : attributes [ "span.kind" ] ,
42+ "type" : "entry" ,
4443 "custom" : {
45- "attributes " : attributes ,
44+ "tags " : attributes ,
4645 },
4746 "arguments" : attributes ["arguments" ],
4847 "return" : attributes ["return" ],
@@ -66,12 +65,15 @@ def test_sdkspan(
6665 "span_kind, expected_result" ,
6766 [
6867 (None , ("intermediate" , 3 )),
68+ (SpanKind .INTERNAL , ("intermediate" , 3 )),
6969 ("entry" , ("entry" , 1 )),
7070 ("server" , ("entry" , 1 )),
7171 ("consumer" , ("entry" , 1 )),
72+ (SpanKind .SERVER , ("entry" , 1 )),
7273 ("exit" , ("exit" , 2 )),
7374 ("client" , ("exit" , 2 )),
7475 ("producer" , ("exit" , 2 )),
76+ (SpanKind .CLIENT , ("exit" , 2 )),
7577 ],
7678 )
7779 def test_sdkspan_get_span_kind (
@@ -81,19 +83,16 @@ def test_sdkspan_get_span_kind(
8183 span_kind : str ,
8284 expected_result : Tuple [str , int ],
8385 ) -> None :
84- attributes = {
85- "span.kind" : span_kind ,
86- }
8786 self .span = InstanaSpan (
88- "test-sdk-span" , span_context , span_processor , attributes = attributes
87+ "test-sdk-span" , span_context , span_processor , kind = span_kind
8988 )
9089 sdk_span = SDKSpan (self .span , None , "test" )
9190
9291 kind = sdk_span .get_span_kind (self .span )
9392
9493 assert expected_result == kind
9594
96- def test_sdkspan_get_span_kind_with_no_attributes (
95+ def test_sdkspan_get_span_kind_default (
9796 self ,
9897 span : InstanaSpan ,
9998 ) -> None :
0 commit comments