-
Notifications
You must be signed in to change notification settings - Fork 564
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow config to set camel (default) or snake case for built-in meter …
…names (#9429) * Allow config to set camel (default) or snake case for built-in meter names Signed-off-by: Tim Quinn <[email protected]> * Add an MP test for when the SNAKE choice is selected --------- Signed-off-by: Tim Quinn <[email protected]>
- Loading branch information
Showing
10 changed files
with
440 additions
and
67 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
metrics/api/src/main/java/io/helidon/metrics/api/BuiltInMeterNameFormat.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Copyright (c) 2024 Oracle and/or its affiliates. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.helidon.metrics.api; | ||
|
||
/** | ||
* Choices for the output format for built-in meter names. | ||
*/ | ||
public enum BuiltInMeterNameFormat { | ||
/** | ||
* Snake-case. | ||
*/ | ||
SNAKE, | ||
|
||
/** | ||
* Camel-case (which is compatible with the MicroProfile Metrics spec). | ||
*/ | ||
CAMEL; | ||
|
||
static final String DEFAULT = "CAMEL"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
metrics/system-meters/src/test/java/io/helidon/metrics/systemmeters/MeterBuilderMatcher.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* Copyright (c) 2024 Oracle and/or its affiliates. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.helidon.metrics.systemmeters; | ||
|
||
import io.helidon.metrics.api.Meter; | ||
|
||
import org.hamcrest.Description; | ||
import org.hamcrest.Matcher; | ||
import org.hamcrest.TypeSafeMatcher; | ||
|
||
/** | ||
* Hamcrest matcher for unit tests involving {@link Meter.Builder} objects. | ||
*/ | ||
class MeterBuilderMatcher { | ||
|
||
/** | ||
* A matcher that checks the meter builder's name using the supplied string matcher. | ||
* | ||
* @param matcher string matcher to apply to the meter builder's name | ||
* @return matcher applicable to a meter builder for checking the name | ||
*/ | ||
static Matcher<Meter.Builder<?, ?>> withName(Matcher<String> matcher) { | ||
return new WithName(matcher); | ||
} | ||
|
||
private static class WithName extends TypeSafeMatcher<Meter.Builder<?, ?>> { | ||
|
||
private final Matcher<? super String> matcher; | ||
|
||
private WithName(Matcher<? super String> matcher) { | ||
this.matcher = matcher; | ||
} | ||
|
||
@Override | ||
protected boolean matchesSafely(Meter.Builder<?, ?> item) { | ||
return matcher.matches(item.name()); | ||
} | ||
|
||
@Override | ||
public void describeTo(Description description) { | ||
description.appendText("with name "); | ||
description.appendDescriptionOf(matcher); | ||
} | ||
} | ||
} |
Oops, something went wrong.