GoogleCloudPlatform / opentelemetry-operations-python

OpenTelemetry Python exporters for Google Cloud Monitoring and Trace
https://google-cloud-opentelemetry.readthedocs.io/en/stable/
Apache License 2.0
64 stars 45 forks source link

Define the Cloud Monitoring category for custom metrics #296

Closed aaaaahaaaaa closed 11 months ago

aaaaahaaaaa commented 1 year ago

Based on the example here, the name of the counter (request_counter) ends up being both used for the name of the metric (workload.googleapis.com/request_counter) and the name of the Active metric category under Cloud Monitoring. The result is:

Generic Task > Request_counter > Request_counter

Is there a way a define the category in such a way that the results would:

Generic Task > My Category > Request_counter

And therefore group multiple custom metrics under the same category?

aabmass commented 1 year ago

Iirc, if the metric has the form workload.googleapis.com/foo/bar, the UI will render foo as the category. Can you try that?

aaaaahaaaaa commented 1 year ago

So the name of the metric would include the /?

That doesn't work, OpenTelemetry raises the following exception:

Exception: Expected ASCII string of maximum length 63 characters but got foo/bar.
aabmass commented 12 months ago

That was fixed in https://github.com/open-telemetry/opentelemetry-python/pull/3442. Can you try a newer version of OpenTelemetry API/SDK?

aabmass commented 11 months ago

@aaaaahaaaaa is this still an issue for you?

aaaaahaaaaa commented 11 months ago

@aabmass Sorry for the late feedback, this one slipped through the cracks.

It works, the prefix before the / appears as the category. Thank you :)

For the record, the name of metric in the UI still appears as the full string with the prefix. So category -> category/metric.