Skip to content

Conversation

JosephHobbs
Copy link

The SDK currently uses an Enum to map Metric Unit types. If an unrecognized Unit type is returned during a call (such as 1dt.metrics.list()1), the result is a ValueError. I initially documented this in issue #116 .

In reality, our Dynatrace tenant contains numerous metric unit types that are not in that list. They come from us (custom metrics), extensions, etc., and I would assume this is common across customers. In its current state, it's not possible to pull a list of metrics from Dynatrace due to this error without hacking the SDK locally.

This update adds Unrecognized to the metric Unit Enum. In addition, the logic for converting to a Metric from raw data was updated to use this option if a ValueError occurs. This avoids the exception/breakage and allows the function to return appropriately.

Ideally the SDK would pull the list of metric types via API versus relying on a static Enum. With this solution, custom units will not be present (and will instead be Unrecognized). However, I'd rather have that result than have no ability to pull the data at all.

In the future, if someone chooses to implement a call to get all metric types, this approach can/should be replaced.

Thank you!

Copy link

@JosephHobbs
Copy link
Author

no longer necessary due to #121

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.

1 participant