diff --git a/sdk-extension/opentelemetry-sdk-extension-aws/setup.cfg b/sdk-extension/opentelemetry-sdk-extension-aws/setup.cfg index c50d15a377..4aa890ca53 100644 --- a/sdk-extension/opentelemetry-sdk-extension-aws/setup.cfg +++ b/sdk-extension/opentelemetry-sdk-extension-aws/setup.cfg @@ -39,7 +39,7 @@ package_dir= =src packages=find_namespace: install_requires = - opentelemetry-api == 0.15.dev0 + opentelemetry-api == 0.15.b0 [options.entry_points] opentelemetry_propagator = @@ -47,7 +47,7 @@ opentelemetry_propagator = [options.extras_require] test = - opentelemetry-test == 0.14.b0 + opentelemetry-test == 0.15.b0 [options.packages.find] where = src diff --git a/sdk-extension/opentelemetry-sdk-extension-aws/tests/trace/propagation/test_aws_xray_format.py b/sdk-extension/opentelemetry-sdk-extension-aws/tests/trace/propagation/test_aws_xray_format.py index 11c205666c..1b108f44b5 100644 --- a/sdk-extension/opentelemetry-sdk-extension-aws/tests/trace/propagation/test_aws_xray_format.py +++ b/sdk-extension/opentelemetry-sdk-extension-aws/tests/trace/propagation/test_aws_xray_format.py @@ -24,12 +24,12 @@ ) import opentelemetry.trace as trace_api from opentelemetry.trace import ( - DEFAULT_TRACE_OPTIONS, - DEFAULT_TRACE_STATE, - INVALID_SPAN_CONTEXT, - SpanContext, - TraceFlags, - set_span_in_context, + DEFAULT_TRACE_OPTIONS, + DEFAULT_TRACE_STATE, + INVALID_SPAN_CONTEXT, + SpanContext, + TraceFlags, + set_span_in_context, TraceState ) from opentelemetry.trace.propagation.textmap import ( @@ -71,16 +71,36 @@ def build_test_context( ) def build_dict_with_xray_trace_header( - trace_id=f"{AwsXRayFormat.TRACE_ID_VERSION}{AwsXRayFormat.TRACE_ID_DELIMITER}{TRACE_ID_BASE16[:AwsXRayFormat.TRACE_ID_FIRST_PART_LENGTH]}{AwsXRayFormat.TRACE_ID_DELIMITER}{TRACE_ID_BASE16[AwsXRayFormat.TRACE_ID_FIRST_PART_LENGTH:]}", + trace_id="{}{}{}{}{}".format( + AwsXRayFormat.TRACE_ID_VERSION, + AwsXRayFormat.TRACE_ID_DELIMITER, + TRACE_ID_BASE16[:AwsXRayFormat.TRACE_ID_FIRST_PART_LENGTH], + AwsXRayFormat.TRACE_ID_DELIMITER, + TRACE_ID_BASE16[AwsXRayFormat.TRACE_ID_FIRST_PART_LENGTH:], + ), span_id=SPAN_ID_BASE16, sampled="0", ): carrier = CaseInsensitiveDict() - + carrier[AwsXRayFormat.TRACE_HEADER_KEY] = ( - f"{AwsXRayFormat.TRACE_ID_KEY}{AwsXRayFormat.KEY_AND_VALUE_DELIMITER}{trace_id}{AwsXRayFormat.KV_PAIR_DELIMITER}" - f"{AwsXRayFormat.PARENT_ID_KEY}{AwsXRayFormat.KEY_AND_VALUE_DELIMITER}{span_id}{AwsXRayFormat.KV_PAIR_DELIMITER}" - f"{AwsXRayFormat.SAMPLED_FLAG_KEY}{AwsXRayFormat.KEY_AND_VALUE_DELIMITER}{sampled}" + "{}{}{}{}".format( + AwsXRayFormat.TRACE_ID_KEY, + AwsXRayFormat.KEY_AND_VALUE_DELIMITER, + trace_id, + AwsXRayFormat.KV_PAIR_DELIMITER, + ), + "{}{}{}{}".format( + AwsXRayFormat.PARENT_ID_KEY, + AwsXRayFormat.KEY_AND_VALUE_DELIMITER, + span_id, + AwsXRayFormat.KV_PAIR_DELIMITER, + ), + "{}{}{}".format( + AwsXRayFormat.SAMPLED_FLAG_KEY, + AwsXRayFormat.KEY_AND_VALUE_DELIMITER, + sampled, + ) ) return carrier @@ -96,12 +116,12 @@ class AwsXRayPropagatorTest(unittest.TestCase): carrier_setter: Setter[TextMapPropagatorT] = CaseInsensitiveDict.__setitem__ carrier_getter: Getter[TextMapPropagatorT] = get_as_list XRAY_PROPAGATOR = AwsXRayFormat() - + # Inject Tests def test_inject_into_non_sampled_context(self): carrier = CaseInsensitiveDict() - + AwsXRayPropagatorTest.XRAY_PROPAGATOR.inject( AwsXRayPropagatorTest.carrier_setter, carrier, @@ -121,13 +141,13 @@ def test_inject_into_non_sampled_context(self): def test_inject_into_sampled_context(self): carrier = CaseInsensitiveDict() - + AwsXRayPropagatorTest.XRAY_PROPAGATOR.inject( AwsXRayPropagatorTest.carrier_setter, carrier, build_test_context(trace_flags=TraceFlags(TraceFlags.SAMPLED)) ) - + self.assertTrue( set( carrier.items() @@ -138,16 +158,16 @@ def test_inject_into_sampled_context(self): ), 'Failed to inject into context that was already sampled' ) - + def test_inject_into_context_with_non_default_state(self): carrier = CaseInsensitiveDict() - + AwsXRayPropagatorTest.XRAY_PROPAGATOR.inject( AwsXRayPropagatorTest.carrier_setter, carrier, build_test_context(trace_state=TraceState({"foo" : "bar"})) ) - + # TODO: (NathanielRN) Assert trace state when the propagator supports it self.assertTrue( set( @@ -183,7 +203,7 @@ def test_extract_empty_carrier_from_invalid_context(self): get_extracted_span_context(actual_context_encompassing_extracted), INVALID_SPAN_CONTEXT ) - + def test_extract_sampled_context(self): actual_context_encompassing_extracted = AwsXRayPropagatorTest.XRAY_PROPAGATOR.extract( AwsXRayPropagatorTest.carrier_getter, @@ -223,7 +243,7 @@ def test_extract_different_order(self): get_extracted_span_context(actual_context_encompassing_extracted), get_extracted_span_context(build_test_context()) ) - + def test_extract_with_additional_fields(self): default_xray_trace_header_dict = build_dict_with_xray_trace_header() xray_trace_header_dict_with_extra_fields = CaseInsensitiveDict( @@ -240,7 +260,7 @@ def test_extract_with_additional_fields(self): get_extracted_span_context(actual_context_encompassing_extracted), get_extracted_span_context(build_test_context()) ) - + def test_extract_invalid_xray_trace_header(self): actual_context_encompassing_extracted = AwsXRayPropagatorTest.XRAY_PROPAGATOR.extract( AwsXRayPropagatorTest.carrier_getter, @@ -253,12 +273,12 @@ def test_extract_invalid_xray_trace_header(self): get_extracted_span_context(actual_context_encompassing_extracted), INVALID_SPAN_CONTEXT ) - + def test_extract_invalid_trace_id(self): actual_context_encompassing_extracted = AwsXRayPropagatorTest.XRAY_PROPAGATOR.extract( AwsXRayPropagatorTest.carrier_getter, build_dict_with_xray_trace_header( - trace_id="abcdefghijklmnopqrstuvwxyzabcdef" + trace_id="abcdefghijklmnopqrstuvwxyz123456" ), ) @@ -266,7 +286,7 @@ def test_extract_invalid_trace_id(self): get_extracted_span_context(actual_context_encompassing_extracted), INVALID_SPAN_CONTEXT ) - + def test_extract_invalid_trace_id_size(self): actual_context_encompassing_extracted = AwsXRayPropagatorTest.XRAY_PROPAGATOR.extract( AwsXRayPropagatorTest.carrier_getter, @@ -292,7 +312,7 @@ def test_extract_invalid_span_id(self): get_extracted_span_context(actual_context_encompassing_extracted), INVALID_SPAN_CONTEXT ) - + def test_extract_invalid_span_id_size(self): actual_context_encompassing_extracted = AwsXRayPropagatorTest.XRAY_PROPAGATOR.extract( AwsXRayPropagatorTest.carrier_getter, @@ -305,7 +325,7 @@ def test_extract_invalid_span_id_size(self): get_extracted_span_context(actual_context_encompassing_extracted), INVALID_SPAN_CONTEXT ) - + def test_extract_invalid_empty_sampled_flag(self): actual_context_encompassing_extracted = AwsXRayPropagatorTest.XRAY_PROPAGATOR.extract( AwsXRayPropagatorTest.carrier_getter, @@ -318,7 +338,7 @@ def test_extract_invalid_empty_sampled_flag(self): get_extracted_span_context(actual_context_encompassing_extracted), INVALID_SPAN_CONTEXT ) - + def test_extract_invalid_sampled_flag_size(self): actual_context_encompassing_extracted = AwsXRayPropagatorTest.XRAY_PROPAGATOR.extract( AwsXRayPropagatorTest.carrier_getter, @@ -331,7 +351,7 @@ def test_extract_invalid_sampled_flag_size(self): get_extracted_span_context(actual_context_encompassing_extracted), INVALID_SPAN_CONTEXT ) - + def test_extract_invalid_non_numeric_sampled_flag(self): actual_context_encompassing_extracted = AwsXRayPropagatorTest.XRAY_PROPAGATOR.extract( AwsXRayPropagatorTest.carrier_getter, diff --git a/sdk-extension/opentelemetry-sdk-extension-aws/tests/trace/test_aws_xray_ids_generator.py b/sdk-extension/opentelemetry-sdk-extension-aws/tests/trace/test_aws_xray_ids_generator.py index 5077f44add..4082942af6 100644 --- a/sdk-extension/opentelemetry-sdk-extension-aws/tests/trace/test_aws_xray_ids_generator.py +++ b/sdk-extension/opentelemetry-sdk-extension-aws/tests/trace/test_aws_xray_ids_generator.py @@ -25,7 +25,7 @@ class AwsXRayIdsGeneratorTest(unittest.TestCase): def test_ids_are_valid(self): ids_generator = AwsXRayIdsGenerator() - for _ in range(1_000): + for _ in range(1000): trace_id = ids_generator.generate_trace_id() self.assertTrue(trace_id != INVALID_TRACE_ID) span_id = ids_generator.generate_span_id() @@ -33,7 +33,7 @@ def test_ids_are_valid(self): def test_id_timestamps_are_acceptable_for_xray(self): ids_generator = AwsXRayIdsGenerator() - for _ in range(1_000): + for _ in range(1000): trace_id = ids_generator.generate_trace_id() trace_id_time = trace_id >> 96 current_time = int(datetime.datetime.utcnow().timestamp())