Skip to content

Strip letters #877

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 5 commits into from
Jul 3, 2020
Merged

Strip letters #877

merged 5 commits into from
Jul 3, 2020

Conversation

AndrewAXue
Copy link
Contributor

@AndrewAXue AndrewAXue commented Jul 3, 2020

Google cloud trace exporter exports an additional label with all spans of the form

g.co/agent: "opentelemetry-python <ot_version>; google-cloud-trace-exporter <exporter_version>"

Currently, <ot_version> and <exporter_version> can have values "0.10.0b". The "b" makes it difficult for internal metrics at Google, so this PR removes those non numeric characters.

@AndrewAXue AndrewAXue requested a review from a team July 3, 2020 14:39
Copy link
Contributor

@ocelotl ocelotl left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@@ -291,6 +291,10 @@ def _extract_events(events: Sequence[Event]) -> ProtoSpan.TimeEvents:
)


def _strip_characters(ot_version):
return "".join(filter(lambda x: x.isdigit() or x == ".", ot_version))
Copy link
Contributor

Choose a reason for hiding this comment

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

Could also be implemented as:

from re import sub

sub(r"[^\d.], "", ot_version)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I feel like the current way is a bit more readable, regex is a bit too compact.

Copy link
Contributor

@lzchen lzchen left a comment

Choose a reason for hiding this comment

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

Nice

@lzchen lzchen merged commit 112bade into open-telemetry:master Jul 3, 2020
@AndrewAXue AndrewAXue deleted the strip_letters branch July 3, 2020 16:58
codeboten pushed a commit that referenced this pull request Jul 7, 2020
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.

5 participants