Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4.x json metadata fix #7858

Merged
merged 2 commits into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions docs/includes/guides/metrics.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -377,12 +377,12 @@ endif::se-flavor[]
Each {metric} has associated metadata that includes:

1. name: The name of the {metric}.
2. units: The unit of the {metric} such as time (seconds, millisecond), size (bytes, megabytes), etc.
2. units: The unit of the {metric} such as time (seconds, milliseconds), size (bytes, megabytes), etc.
3. a description of the {metric}.

You can get the metadata for any scope, such as `/metrics/base`, as shown below:
You can get the metadata for any scope, such as `{metrics-endpoint}?scope=base`, as shown below:

[source,bash]
[source,bash, subs="attributes+"]
.Get the metrics metadata using HTTP OPTIONS method:
----
curl -X OPTIONS -H "Accept: application/json" 'http://localhost:8080{metrics-endpoint}?scope=base'
Expand Down
1 change: 1 addition & 0 deletions docs/mp/guides/metrics.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ Note that the applications you generate using the full Helidon archetype _do_ en
generated config file.
You can see the results in the sample output shown in earlier example runs.

include::{rootdir}/includes/guides/metrics.adoc[tag=metrics-metadata]

=== Application-Specific Metrics Data

Expand Down
2 changes: 2 additions & 0 deletions docs/se/guides/metrics.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ Your Helidon SE application can also control the KPI settings programmatically.

// end of Controlling Metrics section

include::{rootdir}/includes/guides/metrics.adoc[tag=metrics-metadata]

=== Application-Specific Metrics Data

This section demonstrates how to use application-specific {metrics} and integrate them with Helidon, starting from a Helidon SE QuickStart application.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,20 @@ Optional<?> output(MediaType mediaType,
return formatter.format();
}

Optional<?> outputMetadata(MediaType mediaType,
Iterable<String> scopeSelection,
Iterable<String> nameSelection) {
MeterRegistryFormatter formatter = chooseFormatter(meterRegistry,
mediaType,
SystemTagsManager.instance().scopeTagName(),
scopeSelection,
nameSelection);

return formatter.formatMetadata();
}



private static MediaType bestAccepted(ServerRequest req) {
return req.headers()
.bestAccepted(MediaTypes.TEXT_PLAIN,
Expand Down Expand Up @@ -261,9 +275,9 @@ private void optionsMatching(ServerRequest req,
res.send();
}

getOrOptionsMatching(mediaType, res, () -> output(mediaType,
scopeSelection,
nameSelection));
getOrOptionsMatching(mediaType, res, () -> outputMetadata(mediaType,
scopeSelection,
nameSelection));
}

private void setUpDisabledEndpoints(HttpRules rules) {
Expand Down