Skip to content

Commit

Permalink
doc fixes + add custom scope test to MetricRegistryTest
Browse files Browse the repository at this point in the history
  • Loading branch information
Channyboy committed Aug 5, 2022
1 parent e42db80 commit 2a3cb1a
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
Expand Up @@ -719,9 +719,9 @@ static String name(Class<?> klass, String... names) {
Map<String, Metadata> getMetadata();

/**
* Returns the type of this metric registry.
* Returns the scope of this metric registry.
*
* @return Type of this registry (VENDOR, BASE, APPLICATION)
* @return Scope of this registry (VENDOR, BASE, APPLICATION)
*/
String getScope();

Expand Down
Expand Up @@ -116,9 +116,9 @@
String unit() default MetricUnits.NONE;

/**
* The scope that this counter belongs to.
* The scope that this metric belongs to.
*
* @return The scope this counter belongs to. By default, the value is {@link MetricRegistry.APPLICATION_SCOPE}.
* @return The scope this metric belongs to. By default, the value is {@link MetricRegistry.APPLICATION_SCOPE}.
*
*/
@Nonbinding
Expand Down
Expand Up @@ -30,7 +30,7 @@
import org.eclipse.microprofile.metrics.MetricRegistry;

/**
* The scope of Metric Registry to inject.
* Specifies the scope of Metric Registry to inject.
* <p>
* This can be used to obtain the respective scoped {@link MetricRegistry}:
* </p>
Expand Down
Expand Up @@ -47,6 +47,8 @@
@RunWith(Arquillian.class)
public class MetricRegistryTest {

private static final String CUSTOM_SCOPE = "customScope";

@Inject
@Metric(name = "nameTest", absolute = true)
private Counter nameTest;
Expand All @@ -62,6 +64,10 @@ public class MetricRegistryTest {
@RegistryType(scope = MetricRegistry.VENDOR_SCOPE)
private MetricRegistry vendorMetrics;

@Inject
@RegistryType(scope = CUSTOM_SCOPE)
private MetricRegistry customScope;

@Deployment
public static WebArchive createDeployment() {
return ShrinkWrap.create(WebArchive.class).addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml");
Expand Down Expand Up @@ -109,6 +115,7 @@ public void testMetricRegistryType() {
Assert.assertEquals(MetricRegistry.APPLICATION_SCOPE, metrics.getScope());
Assert.assertEquals(MetricRegistry.BASE_SCOPE, baseMetrics.getScope());
Assert.assertEquals(MetricRegistry.VENDOR_SCOPE, vendorMetrics.getScope());
Assert.assertEquals(CUSTOM_SCOPE, customScope.getScope());
}

private void assertExists(Class<? extends org.eclipse.microprofile.metrics.Metric> expected, MetricID metricID) {
Expand Down

0 comments on commit 2a3cb1a

Please sign in to comment.