-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
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 help resolve the conflicts, thanks!
This PR was marked stale due to lack of activity. It will be closed in 14 days. |
Before I get back to this PR, is the desired outcome clear to everyone? Or do we want to go back to the drawing board? @dashpole @bertysentry |
I don't think the open comments are blocking, as they are mostly orthogonal to this change. |
@ArthurSens The outcome is clear to me, but I'm wondering whether we should align our configuration variables with the way Prometheus implemented the various "translation" methods for OTLP-to-Prom conversion. If we're all onboard for the combination of flags instead of a single |
This PR was marked stale due to lack of activity. It will be closed in 14 days. |
We need this feature, it's not stale. |
Hey, just an update to interested folks here. Before continuing here, I'm waiting to see how the code will look in Prometheus. I've opened a few PRs over there, but we're still working on how the code will look. Once we have an agreement, I'll propose something here to keep both codebases similar. We've also discussed removing both libraries from Prometheus and the Collector and moving them to a separate repository during the OTel-Prometheus SIG meetings. Still, it's WIP, and we'll require a design document before committing to the move. |
…-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
This PR was marked stale due to lack of activity. It will be closed in 14 days. |
@ArthurSens any updates post-holidays? |
I think prometheus/prometheus#15664 is the last big PR to Prometheus' OTLP translation code. After that, we should be able to progress here. My preference is still to create a separate library for the metric name translations. I assume you haven't had time to look at this separate library, right? We should probably sync about this! |
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