-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
[pkg/translator/prometheus] Add option to keep UTF-8 characters #35904
base: main
Are you sure you want to change the base?
[pkg/translator/prometheus] Add option to keep UTF-8 characters #35904
Conversation
690750f
to
6a6b470
Compare
@dashpole, I'm not sure what to do with the googlemanagedprometheusexporter 🤔, at least I don't understand how I can solve the problem in this PR. Google's managed prometheus is doing some weird go mod replaces somewhere? |
Yikes. Previously, we've had to deprecate and replace functions that are changed. I might be able to refactor the GMP code to move usage of the translator package back into contrib. |
I could change the implementation into a new function |
working to unblock you: GoogleCloudPlatform/opentelemetry-operations-go#908 |
…-go to the latest release (#36132) #### Description Update github.com/GoogleCloudPlatform/opentelemetry-operations-go to https://github.com/GoogleCloudPlatform/opentelemetry-operations-go/releases/tag/v0.49.0. This unblocks #35904 by moving the prometheus sanitization into contrib. @ArthurSens
6a6b470
to
dd96ad5
Compare
Thanks for unblocking this @dashpole ❤️, it should be ready for review |
dd96ad5
to
9a1f936
Compare
Signed-off-by: Arthur Silva Sens <arthursens2005@gmail.com>
9a1f936
to
e5719ea
Compare
require.Equal(t, "unsupported_metric_redundant_test_per_C", normalizeName(createGauge("unsupported.metric.redundant", "__test $/°C"), "")) | ||
|
||
func TestAllowUTF8(t *testing.T) { | ||
for _, allowUTF8 := range []bool{true, false} { |
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.
Please remove the for
followed by if
/else
. Unnecessary complexity.
// Don't allow UTF-8 (default)
require.Equal(t, "unsupported_metric_temperature_F", normalizeName(createGauge("unsupported.metric.temperature", "°F"), "", false))
require.Equal(t, "unsupported_metric_weird", normalizeName(createGauge("unsupported.metric.weird", "+=.:,!* & #"), "", false))
require.Equal(t, "unsupported_metric_redundant_test_per_C", normalizeName(createGauge("unsupported.metric.redundant", "__test $/°C"), "", false))
// Allow UTF-8
require.Equal(t, "unsupported.metric.temperature_°F", normalizeName(createGauge("unsupported.metric.temperature", "°F"), "", true))
require.Equal(t, "unsupported.metric.weird_+=.:,!* & #", normalizeName(createGauge("unsupported.metric.weird", "+=.:,!* & #"), "", true))
require.Equal(t, "unsupported.metric.redundant___test $_per_°C", normalizeName(createGauge("unsupported.metric.redundant", "__test $/°C"), "", true))
require.Equal(t, "system_cpu_utilization_ratio", normalizeName(createGauge("system.cpu.utilization", "1"), "", false)) | ||
require.Equal(t, "system_disk_operation_time_seconds_total", normalizeName(createCounter("system.disk.operation_time", "s"), "", false)) | ||
require.Equal(t, "system_cpu_load_average_15m_ratio", normalizeName(createGauge("system.cpu.load_average.15m", "1"), "", false)) | ||
require.Equal(t, "memcached_operation_hit_ratio_percent", normalizeName(createGauge("memcached.operation_hit_ratio", "%"), "", false)) |
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.
Edge case: what's the expected result if allowedUTF8 == true
?
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.
It's still translated to percent
require.Equal(t, "mongodbatlas_process_journaling_data_files_mebibytes", normalizeName(createGauge("mongodbatlas.process.journaling.data_files", "MiBy"), "", false)) | ||
require.Equal(t, "mongodbatlas_process_network_io_bytes_per_second", normalizeName(createGauge("mongodbatlas.process.network.io", "By/s"), "", false)) | ||
require.Equal(t, "mongodbatlas_process_oplog_rate_gibibytes_per_hour", normalizeName(createGauge("mongodbatlas.process.oplog.rate", "GiBy/h"), "", false)) | ||
require.Equal(t, "mongodbatlas_process_db_query_targeting_scanned_per_returned", normalizeName(createGauge("mongodbatlas.process.db.query_targeting.scanned_per_returned", "{scanned}/{returned}"), "", false)) |
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.
Edge case: what's the expected result if allowedUTF8 == true
?
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.
It's translated to scanned_per_returned
require.Equal(t, "hello_you_2", CleanUpString("hello you 2")) | ||
require.Equal(t, "1000", CleanUpString("$1000")) | ||
require.Equal(t, "", CleanUpString("*+$^=)")) | ||
for _, allowUTF8 := range []bool{true, false} { |
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.
Please remove the for
/if
/else
: unnecessary complexity
@bertysentry the questions around unit translation are really good ones, I haven't thought about it. This is something that wasn't questioned in the user survey and I don't know what should be the answer here. Maybe we start by keeping the current behavior, and if needed change this in the future? |
…-go to the latest release (open-telemetry#36132) #### Description Update github.com/GoogleCloudPlatform/opentelemetry-operations-go to https://github.com/GoogleCloudPlatform/opentelemetry-operations-go/releases/tag/v0.49.0. This unblocks open-telemetry#35904 by moving the prometheus sanitization into contrib. @ArthurSens
Description
Updates the translator package to allow keeping UTF-8 characters. The intended usage of this is that components that use this package would add new configuration options to allow users to keep UTF-8 characters in metric and label names.
For the components that are using this package, I'm adding
false
as the argument to keep the current behavior. Follow-up PRs will be opened to allow configurability.Link to tracking issue
Related to #35459