Skip to content

Commit

Permalink
ext/jaeger: Fixing the serialization of a tuple element by coercing i…
Browse files Browse the repository at this point in the history
…t into a string (#865)

Could not serialize attribute aws.region to tag when exporting via jaeger
Serialize tuple type values by coercing them into a string, since Jaeger does not
support tuple types.
  • Loading branch information
bitspradp authored Jul 13, 2020
1 parent b085f37 commit e31c4bb
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
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
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

0 comments on commit e31c4bb

Please sign in to comment.