@@ -643,7 +643,7 @@ def is_api_gateway_invocation_async(event):
643
643
644
644
645
645
def insert_upstream_authorizer_span (
646
- kwargs_to_start_span , other_tags_for_span , start_time_s , finish_time_s = None
646
+ kwargs_to_start_span , other_tags_for_span , start_time_ns , finish_time_s = None
647
647
):
648
648
"""Insert the authorizer span.
649
649
Without this: parent span --child-> inferred span
@@ -652,7 +652,7 @@ def insert_upstream_authorizer_span(
652
652
Args:
653
653
kwargs_to_start_span (Dict): the same keyword arguments used for the inferred span
654
654
other_tags_for_span (Dict): the same tag keyword arguments used for the inferred span
655
- start_time_s (int): the start time of the span in seconds
655
+ start_time_ns (int): the start time of the span in nanoseconds
656
656
finish_time_s (int): the finish time of the sapn in seconds
657
657
"""
658
658
@@ -663,7 +663,7 @@ def insert_upstream_authorizer_span(
663
663
upstream_authorizer_span .set_tag ("operation_name" , "aws.apigateway.authorizer" )
664
664
# always sync for the authorizer invocation
665
665
InferredSpanInfo .set_tags_to_span (upstream_authorizer_span , synchronicity = "sync" )
666
- upstream_authorizer_span .start = start_time_s
666
+ upstream_authorizer_span .start_ns = start_time_ns
667
667
upstream_authorizer_span .finish (finish_time = finish_time_s )
668
668
return upstream_authorizer_span
669
669
@@ -704,9 +704,8 @@ def create_inferred_span_from_api_gateway_websocket_event(event, context):
704
704
)
705
705
if injected_authorizer_data :
706
706
try :
707
- start_time_s = (
708
- int (injected_authorizer_data .get (Headers .Parent_Span_Finish_Time ))
709
- / 1000
707
+ start_time_ns = int (
708
+ injected_authorizer_data .get (Headers .Parent_Span_Finish_Time )
710
709
)
711
710
finish_time_s = (
712
711
request_time_epoch_s
@@ -720,7 +719,7 @@ def create_inferred_span_from_api_gateway_websocket_event(event, context):
720
719
/ 1000
721
720
)
722
721
upstream_authorizer_span = insert_upstream_authorizer_span (
723
- args , tags , start_time_s , finish_time_s
722
+ args , tags , start_time_ns , finish_time_s
724
723
)
725
724
# trace context needs to be set again as it is reset by upstream_authorizer_span.finish
726
725
tracer .context_provider .activate (trace_ctx )
@@ -781,9 +780,8 @@ def create_inferred_span_from_api_gateway_event(event, context):
781
780
)
782
781
if injected_authorizer_data :
783
782
try :
784
- start_time_s = (
785
- int (injected_authorizer_data .get (Headers .Parent_Span_Finish_Time ))
786
- / 1000
783
+ start_time_ns = int (
784
+ injected_authorizer_data .get (Headers .Parent_Span_Finish_Time )
787
785
)
788
786
finish_time_s = (
789
787
request_time_epoch_s
@@ -797,7 +795,7 @@ def create_inferred_span_from_api_gateway_event(event, context):
797
795
/ 1000
798
796
)
799
797
upstream_authorizer_span = insert_upstream_authorizer_span (
800
- args , tags , start_time_s , finish_time_s
798
+ args , tags , start_time_ns , finish_time_s
801
799
)
802
800
# trace context needs to be set again as it is reset by upstream_authorizer_span.finish
803
801
tracer .context_provider .activate (trace_ctx )
@@ -861,13 +859,14 @@ def create_inferred_span_from_http_api_event(event, context):
861
859
)
862
860
if injected_authorizer_data :
863
861
try :
864
- start_time_s = (
865
- int (injected_authorizer_data .get (Headers .Parent_Span_Finish_Time ))
866
- / 1000
862
+ start_time_ns = int (
863
+ injected_authorizer_data .get (Headers .Parent_Span_Finish_Time )
867
864
)
868
- finish_time_s = start_time_s # no integrationLatency info in this case
865
+ finish_time_s = (
866
+ start_time_ns / 1000
867
+ ) # no integrationLatency info in this case
869
868
upstream_authorizer_span = insert_upstream_authorizer_span (
870
- args , tags , start_time_s , finish_time_s
869
+ args , tags , start_time_ns , finish_time_s
871
870
)
872
871
# trace context needs to be set again as it is reset by upstream_authorizer_span.finish
873
872
tracer .context_provider .activate (trace_ctx )
0 commit comments