Skip to content

Implement Unit Test for AWS Metric Attributes Span Exporter #30

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

Merged
merged 42 commits into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
f1b3e1c
init
Jan 23, 2024
ab97f26
init
Jan 23, 2024
aa746cc
Merge branch 'main' into unittest_test_aws_metric_attributes_span_exp…
Jan 23, 2024
add532c
init
Jan 24, 2024
040269f
checkstyle fix
XinRanZhAWS Jan 24, 2024
a86e56d
init
XinRanZhAWS Jan 24, 2024
5c59670
init
Jan 25, 2024
7a42e36
Merge branch 'main' into unittest_test_aws_metric_attributes_span_exp…
Jan 25, 2024
5d3fb88
Functional Complete
Jan 25, 2024
11ee693
CheckStyle Fix
Jan 25, 2024
c506377
CheckStyle Fix
Jan 25, 2024
242f8f1
CheckStyle Fix
Jan 25, 2024
8c65ed6
CheckStyle Fix
XinRanZhAWS Jan 26, 2024
8fb3304
CHKSTYLE fix
XinRanZhAWS Jan 27, 2024
b2b9b9b
Fill some unsufficient test
XinRanZhAWS Jan 27, 2024
b5317a5
Fill some unsufficient test
XinRanZhAWS Jan 27, 2024
9d6e948
Fix
XinRanZhAWS Jan 27, 2024
2faf113
CheckStyle Fix
XinRanZhAWS Jan 27, 2024
582cfd0
CheckStyle Fix
XinRanZhAWS Jan 27, 2024
938a3f3
CheckStyle Fix
XinRanZhAWS Jan 27, 2024
581c718
CheckStyle Fix
XinRanZhAWS Jan 27, 2024
aa32323
Fix a reference related issue
XinRanZhAWS Jan 27, 2024
fa9e523
CheckStyle Fix
XinRanZhAWS Jan 27, 2024
85078d0
CheckStyle Fix
XinRanZhAWS Jan 27, 2024
95f3a65
CheckStyle Fix && Code Style Fix
XinRanZhAWS Jan 27, 2024
5a225fa
checkstyle fix
XinRanZhAWS Jan 27, 2024
02f1479
Revert "checkstyle fix"
XinRanZhAWS Jan 27, 2024
c52a3d2
Code Style Fix
XinRanZhAWS Jan 27, 2024
dfa6c47
Code Style Fix
XinRanZhAWS Jan 27, 2024
30276e6
Code Style Fix
XinRanZhAWS Jan 27, 2024
038459d
Code Style Fix
XinRanZhAWS Jan 27, 2024
8f50eb1
Code Style Fix
XinRanZhAWS Jan 27, 2024
fa718b3
Code Style Fix
XinRanZhAWS Jan 27, 2024
d2bff41
Code Style Fix
XinRanZhAWS Jan 27, 2024
778774b
Code Style Fix
XinRanZhAWS Jan 27, 2024
a863778
Merge branch 'main' into unittest_test_aws_metric_attributes_span_exp…
XinRanZhAWS Jan 29, 2024
b22892c
update based on comment
XinRanZhAWS Jan 29, 2024
f57f95c
Merge remote-tracking branch 'origin/unittest_test_aws_metric_attribu…
XinRanZhAWS Jan 29, 2024
3926997
checkstyle fix
Jan 29, 2024
3cdc84c
Override checkstyle for no-self-use, will be better to keep them insi…
Jan 29, 2024
3b27927
CheckStyle Fix
Jan 29, 2024
26d1c55
Merge branch 'main' into unittest_test_aws_metric_attributes_span_exp…
XinRanZhAWS Jan 30, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0
import copy
from typing import List, Sequence, TypeVar

from typing_extensions import override
Expand Down Expand Up @@ -102,12 +103,11 @@ def copy_attributes_with_local_root(attributes: BoundedAttributes) -> BoundedAtt
)


# TODO: AwsMetricAttributesSpanExporter depends on internal ReadableSpan method _attributes.
# This is a bit risky but is required for our implementation.
# The risk is that the implementation of _attributes changes in the future.
# We need tests that thoroughly test this behaviour to make sure it does not change upstream.
def wrap_span_with_attributes(span: ReadableSpan, attributes: BoundedAttributes) -> ReadableSpan:
original_attributes: AttributesT = span.attributes
# To make sure we create a new span without influence original span's Attributes
# We have to create a deepcopy for it
new_span = copy.deepcopy(span)
original_attributes: AttributesT = new_span.attributes
update_attributes: types.Attributes = {}
# Copy all attribute in span into update_attributes
for key, value in original_attributes.items():
Expand All @@ -117,12 +117,12 @@ def wrap_span_with_attributes(span: ReadableSpan, attributes: BoundedAttributes)
update_attributes[key] = value

if isinstance(original_attributes, BoundedAttributes):
span._attributes = BoundedAttributes(
new_span._attributes = BoundedAttributes(
maxlen=original_attributes.maxlen,
attributes=update_attributes,
immutable=original_attributes._immutable,
max_value_len=original_attributes.max_value_len,
)
else:
span._attributes = update_attributes
return span
new_span._attributes = update_attributes
return new_span
Loading