open-telemetry / opentelemetry-go-build-tools

Build tools for use by the Go API/SDK, the collector, and their associated contrib repositories
https://opentelemetry.io
Apache License 2.0
32 stars 35 forks source link

semconvgen: Add a flag for a path to a custom capitalizations file #528

Closed carrbs closed 5 months ago

carrbs commented 6 months ago

The capitalizations slice in the semconvgen generator.go file does not include some of the keywords we would like capitalized for the generated metrics in semconv, namely:

Adding a new optional flag (e.g. capitalizations-path) and appending the strings from the capitalizations file (file type to be determined) to the existing capitalizations slice would provide the flexibility to add these strings (and others, as necessary) without modifying the code in the generator file.

A usage example:

metric-capitalizations.txt

ASPNETCore
JVM

Invoking semconvgen with the new flag:

semconvgen -i "/path/to/semconv/yaml" \
--only=metric  \
-f metric.go \
-t "/path/to/jinja/template" \
--capitalizations-path="/path/to/metric-capitalizations.txt" \
-s "someVersion"