Skip to content
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

Fixing the serialization of a tuple element by coercing it into a string #865

Merged
merged 4 commits into from
Jul 13, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
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
4 changes: 4 additions & 0 deletions ext/opentelemetry-ext-jaeger/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ Released 2020-05-27

- Transform resource to tags when exporting
([#645](https://github.com/open-telemetry/opentelemetry-python/pull/645))
- ext/boto: Could not serialize attribute aws.region to tag when exporting via jaeger
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you mind changing this to be more descriptive of the change? I think the "why" is good too, but knowing precisely what the fix or behavioral change was will apply more broadly to those reading the changelog.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ack

Serialize tuple type values by coercing them into a string, since Jaeger does not
support tuple types.
([#865](https://github.com/open-telemetry/opentelemetry-python/pull/865))

## 0.6b0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,8 @@ def _convert_attribute_to_tag(key, attr):
return jaeger.Tag(key=key, vLong=attr, vType=jaeger.TagType.LONG)
if isinstance(attr, float):
return jaeger.Tag(key=key, vDouble=attr, vType=jaeger.TagType.DOUBLE)
if isinstance(attr, tuple):
return jaeger.Tag(key=key, vStr=str(attr), vType=jaeger.TagType.STRING)
logger.warning("Could not serialize attribute %s:%r to tag", key, attr)
return None

Expand Down
6 changes: 6 additions & 0 deletions ext/opentelemetry-ext-jaeger/tests/test_jaeger_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ def test_translate_to_jaeger(self):
otel_spans[0].set_attribute("key_bool", False)
otel_spans[0].set_attribute("key_string", "hello_world")
otel_spans[0].set_attribute("key_float", 111.22)
otel_spans[0].set_attribute("key_tuple", ("tuple_element",))
otel_spans[0].resource = Resource(
labels={"key_resource": "some_resource"}
)
Expand Down Expand Up @@ -241,6 +242,11 @@ def test_translate_to_jaeger(self):
vType=jaeger.TagType.DOUBLE,
vDouble=111.22,
),
jaeger.Tag(
key="key_tuple",
vType=jaeger.TagType.STRING,
vStr="('tuple_element',)",
),
jaeger.Tag(
key="key_resource",
vType=jaeger.TagType.STRING,
Expand Down