Skip to content
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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ArthurSens
Copy link
Member

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

@ArthurSens
Copy link
Member Author

@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?

@dashpole
Copy link
Contributor

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.

@ArthurSens
Copy link
Member Author

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 BuildUTF8Name if you prefer, but it's weird that user of the library blocks updates like this 🤔

@dashpole
Copy link
Contributor

working to unblock you: GoogleCloudPlatform/opentelemetry-operations-go#908

bogdandrutu pushed a commit that referenced this pull request Nov 2, 2024
…-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
@ArthurSens ArthurSens force-pushed the pkg-transl-prom-allowutf8 branch from 6a6b470 to dd96ad5 Compare November 2, 2024 22:59
@ArthurSens ArthurSens requested a review from jsuereth as a code owner November 2, 2024 22:59
@github-actions github-actions bot added the exporter/googlemanagedprometheus Google Managed Prometheus exporter label Nov 2, 2024
@github-actions github-actions bot requested review from aabmass, psx95 and punya November 2, 2024 22:59
@ArthurSens
Copy link
Member Author

Thanks for unblocking this @dashpole ❤️, it should be ready for review

@ArthurSens ArthurSens force-pushed the pkg-transl-prom-allowutf8 branch from dd96ad5 to 9a1f936 Compare November 3, 2024 17:56
Signed-off-by: Arthur Silva Sens <arthursens2005@gmail.com>
@ArthurSens ArthurSens force-pushed the pkg-transl-prom-allowutf8 branch from 9a1f936 to e5719ea Compare November 4, 2024 11:49
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} {
Copy link
Contributor

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))
Copy link
Contributor

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?

Copy link
Member Author

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))
Copy link
Contributor

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?

Copy link
Member Author

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} {
Copy link
Contributor

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

@ArthurSens
Copy link
Member Author

@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?

ArthurSens pushed a commit to ArthurSens/opentelemetry-collector-contrib that referenced this pull request Nov 4, 2024
…-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
Copy link
Contributor

@fatsheep9146 fatsheep9146 left a 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!

Copy link
Contributor

This PR was marked stale due to lack of activity. It will be closed in 14 days.

@github-actions github-actions bot added the Stale label Nov 29, 2024
@ArthurSens
Copy link
Member Author

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

@github-actions github-actions bot removed the Stale label Nov 30, 2024
@dashpole
Copy link
Contributor

dashpole commented Dec 2, 2024

I don't think the open comments are blocking, as they are mostly orthogonal to this change.

@bertysentry
Copy link
Contributor

@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 translation_strategy variables, I'm fine with it!

Copy link
Contributor

This PR was marked stale due to lack of activity. It will be closed in 14 days.

@github-actions github-actions bot added the Stale label Dec 17, 2024
@bertysentry
Copy link
Contributor

We need this feature, it's not stale.

@ArthurSens
Copy link
Member Author

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.

sbylica-splunk pushed a commit to sbylica-splunk/opentelemetry-collector-contrib that referenced this pull request Dec 17, 2024
…-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
@github-actions github-actions bot removed the Stale label Dec 18, 2024
Copy link
Contributor

github-actions bot commented Jan 1, 2025

This PR was marked stale due to lack of activity. It will be closed in 14 days.

@github-actions github-actions bot added the Stale label Jan 1, 2025
@ywwg
Copy link

ywwg commented Jan 2, 2025

@ArthurSens any updates post-holidays?

@github-actions github-actions bot removed the Stale label Jan 3, 2025
@ArthurSens
Copy link
Member Author

@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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants