-
Notifications
You must be signed in to change notification settings - Fork 463
chore(tracing): simplify Span tag/metric API typing #14943
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
base: 4.0-breaking-changes
Are you sure you want to change the base?
Conversation
|
Bootstrap import analysisComparison of import times between this PR and base. SummaryThe average import time from this PR is: 209 ± 2 ms. The average import time from base is: 205 ± 2 ms. The import time difference between this PR and base is: 4.44 ± 0.08 ms. Import time breakdownThe following import paths have appeared:
|
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.
With this change encoding spans might fail if set_tag is called on an unsupported type. Should we update span encoding to make sure that we don't drop the full span when encoding fails for a particular tag?
return self._meta_struct.get(key, None) | ||
|
||
def set_tag_str(self, key: _TagNameType, value: Text) -> None: | ||
def set_tag_str(self, key: str, value: str) -> None: |
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.
Should we deprecate/internalize this method? Ideally we should expose one public API for setting tags. If the overhead of handling sampling and service naming logic is significant we can move this logic out of set tags in v5.0
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 have another PR to deprecate and internalize it. With the changes to set_tag
we might be able to just get rid of it entirely.
# Ensure we do not have the same key in both meta and metrics | ||
self._metrics.pop(key, None) | ||
|
||
def set_struct_tag(self, key: str, value: Dict[str, Any]) -> None: |
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.
Should this method be public or is this functionality internal to the ddtrace library
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.
there is another PR to deprecate and internalize this
return | ||
elif key == SERVICE_KEY: | ||
self.service = value | ||
elif key == SERVICE_VERSION_KEY: |
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.
Can we handle these tags in a trace processor or in Logs backend? It seems unnecessary to do this check every time set_tag is called.
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.
good question... probably, but this change is started to get bloated a bit anyways, so maybe better to handle as a follow up.
it is an internal implementation detail, so... 🤷🏻
@mabdinur yeah, this is one of the bigger hidden issues with this change, since if someone doesn't notice the type changes and was doing the other approach we could take is to get rid of then splitting into meta/metrics for v0.4/v0.5 is an internal implementation detail only. |
Description
4.0
This updates all tag and metric methods to explicitly be
dict[str, str]
anddict[str, int float]
only.This removes the
value: Any
fromset_tag
which allows us to remove a lot of checks for things like if it is a numeric type or not.Testing
Risks
Additional Notes