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

Fix otlp exporter translating sequence types #1818

Merged
merged 8 commits into from
May 11, 2021

Conversation

lzchen
Copy link
Contributor

@lzchen lzchen commented May 5, 2021

Fixes #1755

As of today, span attributes cannot be a mapping type, so the logic for translating mapping types should never be hit.

Proto supports KeyValueList, which might be ahead of the tracing spec in terms of data types that it supports.

Thanks @LouisStAmour for the code snippet.

@lzchen lzchen requested a review from a team as a code owner May 5, 2021 19:31
@lzchen lzchen requested review from codeboten and hectorhdzg and removed request for a team May 5, 2021 19:31
Copy link
Contributor

@codeboten codeboten left a comment

Choose a reason for hiding this comment

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

Thanks for opening the PR and thanks to @LouisStAmour for the issue and code to address it. I'm requesting change until the discussion around what to do w/ Mapping types is resolved.

@@ -545,6 +550,55 @@ def test_span_status_translate(self):
Status.DEPRECATED_STATUS_CODE_UNKNOWN_ERROR,
)

# pylint:disable=no-member
Copy link
Contributor

Choose a reason for hiding this comment

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

this tests makes me think we should make use to pytest parametrization https://docs.pytest.org/en/6.2.x/parametrize.html

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It could be a possible improvement however it might be a bit complex due to the nested property checking that this specific test is doing. I can see it being useful for other tests that have code branches like this one though.


# Tracing specs currently does not support Mapping type attributes
elif isinstance(value, Mapping):
Copy link
Contributor

Choose a reason for hiding this comment

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

We should have an issue for this in the spec. Translating a map to a list of KeyValues should be defined in the spec, otherwise there's no guarantee of what other languages will do.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removing this logic branch since mapping types cannot be added as attributes currently, as defined in the tracing spec

Copy link
Contributor

@codeboten codeboten left a comment

Choose a reason for hiding this comment

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

👍

Copy link
Contributor

@owais owais left a comment

Choose a reason for hiding this comment

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

Looks good. Left a question around support of mapping types for attribute values.

# _translate_key_values(str(k), v) for k, v in value.items()
# ]
# )
# )
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this mean any spans containing a Mapping attribute will throw an exception below? I don't think we should do that if the API allows to create KV attributes (not sure if it does). May be we can warn and drop the attribute instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@codeboten codeboten merged commit 271f015 into open-telemetry:main May 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot set an attribute with array value
3 participants