Fix missing unit in Gauge metrics snippet#47
Fix missing unit in Gauge metrics snippet#47angelozerr merged 1 commit intoeclipse-lsp4mp:masterfrom
Conversation
|
"Fix missing comma"? |
|
This PR adds the |
| "\tname = \"${1:name}\",", | ||
| "\tdescription = \"${2:description}\"", | ||
| "\tdescription = \"${2:description}\",", | ||
| "\tunit = $3", |
There was a problem hiding this comment.
unit is a string, so I think it should be
"\tunit = \"${3:unit}\"",
no?
There was a problem hiding this comment.
I think for the majority of use cases the MetricUnit constants are used. https://github.com/eclipse/microprofile-metrics/blob/master/api/src/main/java/org/eclipse/microprofile/metrics/MetricUnits.java#L34
Ex. from https://quarkus.io/guides/microprofile-metrics
@Gauge(name = "highestPrimeNumberSoFar", unit = MetricUnits.NONE, description = "Highest prime number so far.")
So i didn't want to wrap the placeholder in quotes if they would need to remove them to use the MetricUnit constants.
I would think we leave it as is, or maybe change it to something like: "\tunit = ${3:\"unit\"}",?
There was a problem hiding this comment.
Snippets should generate code without syntax error, that's why I wonder why it misses quote, but I understand your point of view. So I suggest that you use snippet choice https://microsoft.github.io/language-server-protocol/specification#choice which provides MetricUnits.NONE, and other value of MetricUnits and double quote.
There was a problem hiding this comment.
I think it's nice now because snippets generates annotation without syntax error. Thanks @rzgry !
299e866 to
e28a774
Compare

Adds unit to the
@Gaugesnippet since it is required https://github.com/eclipse/microprofile-metrics/blob/master/spec/src/main/asciidoc/app-programming-model.adoc#gaugeAll others provide a default value so it is not needed. https://github.com/eclipse/microprofile-metrics/blob/master/spec/src/main/asciidoc/app-programming-model.adoc#fields