Skip to content

Strip letters#877

Merged
lzchen merged 5 commits intoopen-telemetry:masterfrom
AndrewAXue:strip_letters
Jul 3, 2020
Merged

Strip letters#877
lzchen merged 5 commits intoopen-telemetry:masterfrom
AndrewAXue:strip_letters

Conversation

@AndrewAXue
Copy link
Copy Markdown
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
Copy Markdown
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 👍



def _strip_characters(ot_version):
return "".join(filter(lambda x: x.isdigit() or x == ".", ot_version))
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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