[extension/googlecloudlogentryencoding] Fix incorrect snake_case conversion for numeronyms (e.g. k8s)#46588
Conversation
…ronyms like k8s Fixes open-telemetry#46571
|
Welcome, contributor! Thank you for your contribution to opentelemetry-collector-contrib. Important reminders:
A maintainer will review your pull request soon. Thank you for helping make OpenTelemetry better! |
Should i add this: so we skip the regex entirely if no numbers |
|
/workflow-approve |
previous component name used: extension/googlecloudlogentryencoding corrected component name: extension/googlecloudlogentry_encoding
|
/workflow-approve |
|
@paulojmdias It looks like the Checkout Repo step is hitting a GitHub 500 error across multiple jobs (11 failures). Could you please re-run the failed checks? |
|
/rerun |
|
Thank you for your contribution @57Ajay! 🎉 We would like to hear from you about your experience contributing to OpenTelemetry by taking a few minutes to fill out this survey. If you are getting started contributing, you can also join the CNCF Slack channel #opentelemetry-new-contributors to ask for guidance and get help. |
Description:
This PR fixes an issue where the googlecloudlogentryencoding extension incorrectly converted log field names containing numeronyms (abbreviations containing numbers, such as "k8s") into snake_case.
The Problem:
The previous implementation relied on strcase.ToSnakeWithIgnore, which treats a digit followed by a lowercase letter as a word boundary.
The Solution:
Introduced a shared.ToSnakeCase helper function that wraps the existing library call. It uses a regex replacement ((\d)_([a-z]) -> ${1}${2}) to post-process the string, re-merging digits and subsequent lowercase letters. This approach preserves standard numeronyms (e.g., k8s, v1beta) while maintaining snake_case for standard camelCase inputs.
Link to tracking Issue:
Fixes #46571
Testing:
Documentation: