Open MrAlias opened 1 month ago
Ah, thanks. I missed that. I'll give it a try.
It looks like that is already being used:
But it is still generating invalid names. For example:
Aws
instead of AWS
: https://github.com/open-telemetry/opentelemetry-go/pull/5793/files#diff-947b803ff8dbcd43bbbfd5c66bc4a0dd826b4754ec035b29f4ec867d42acc781R381Db
instead of DB
: https://github.com/open-telemetry/opentelemetry-go/pull/5793/files#diff-947b803ff8dbcd43bbbfd5c66bc4a0dd826b4754ec035b29f4ec867d42acc781R2055That’s strange. The latest links you added to your last comment aren’t working for me. Could you point me to the file and the line where you observed the issue for AWS? I’d like to determine if it’s a flaw in the acronym filter or a usage problem.
@lquerel thanks for the response.
Those files are from this PR: https://github.com/open-telemetry/opentelemetry-go/pull/5793
I'm working in that branch and able to reproduce the results generated there. I have updated to use v0.10.0 as well and still not able to remedy the naming.
FWIW, I have also tried moving the acronym
function earlier in the processing:
{%- macro to_go_name(fqn) -%}
{{ fqn | acronym | title_case | replace(" ", "") }}
{%- endmacro -%}
Still no change.
Removing the title_case
function resulted in things like the following to be produced:
AWS.DynamoDB.consistent_readKey
Which seems to show that the acronym
function is working but not interacting well with the title_case
.
Is there a way to have these work together?
Could you try the following macro
{%- macro to_go_name(fqn) -%}
{{ fqn | title_case | acronym | replace(" ", "") }}
{%- endmacro -%}
Applying the title_case
filter after the acronym
filter destroys the effect of the acronym
filter.
If that doesn't work please copy/paste the result of fqn | title_case
without anything else. Thanks
{%- macro to_go_name(fqn) -%}
{{ fqn | title_case | acronym | replace(" ", "") }}
{%- endmacro -%}
AwsDynamodbConsistentReadKey
{%- macro to_go_name(fqn) -%}
{{ fqn | title_case }}
{%- endmacro -%}
AwsDynamodbConsistentReadKey
Okay, I see. The acronym
filter works at the word boundary level, while the title_case
filter transforms, in this case, a dot notation (e.g., aws.dynamodb.consistent.readKey
) into a single word (e.g., AwsDynamodbConsistentReadKey
). I need to consider the best way to fix this issue. I’ll include a fix in the next release.
The Go team currently uses the following capitalization for known acronyms and initialisms:
The current build tooling ensures these capitalizations are used in any naming generated. How can we keep this behavior when using weaver?