-
Notifications
You must be signed in to change notification settings - Fork 706
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
Strip letters #877
Conversation
ext/opentelemetry-exporter-cloud-trace/tests/test_cloud_trace_exporter.py
Outdated
Show resolved
Hide resolved
There was a problem hiding this 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)) |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice
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.