Skip to content

Commit 62af6c7

Browse files
Aneurysm9MrAlias
andauthored
semconv-gen: fix capitalization at word boundaries, add stability/deprecation indicators (open-telemetry#2033)
Signed-off-by: Anthony J Mirabella <[email protected]> Co-authored-by: Tyler Yahn <[email protected]>
1 parent 0bceed7 commit 62af6c7

File tree

4 files changed

+207
-4
lines changed

4 files changed

+207
-4
lines changed

internal/tools/semconv-gen/generator.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,7 @@ var capitalizations = []string{
270270
"ARNs",
271271
"ASCII",
272272
"AWS",
273+
"CPP",
273274
"CPU",
274275
"CSS",
275276
"DB",
@@ -369,7 +370,7 @@ func fixIdentifiers(cfg config) error {
369370
// Match the title-cased capitalization target, asserting that its followed by
370371
// either a capital letter, whitespace, a digit, or the end of text.
371372
// This is to avoid, e.g., turning "Identifier" into "IDentifier".
372-
re := regexp.MustCompile(strings.Title(strings.ToLower(init)) + `([A-Z\s\d]|$)`)
373+
re := regexp.MustCompile(strings.Title(strings.ToLower(init)) + `([A-Z\s\d]|\b|$)`)
373374
// RE2 does not support zero-width lookahead assertions, so we have to replace
374375
// the last character that may have matched the first capture group in the
375376
// expression constructed above.

internal/tools/semconv-gen/template.j2

+4
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ Required: {{ attr.required_msg }}
2323
{%- else %}
2424
Required: No
2525
{%- endif %}
26+
{{ attr.stability | replace("Level.", ": ") | capitalize }}
27+
{%- if attr.deprecated != None %}
28+
Deprecated: {{ attr.deprecated }}
29+
{%- endif %}
2630
{%- if attr.examples is iterable %}
2731
Examples: {{ attr.examples | pprint | trim("[]") }}
2832
{%- endif %}

0 commit comments

Comments
 (0)