From 1c6299da35e5de7201963be3d6b2d52380833924 Mon Sep 17 00:00:00 2001 From: David Chan Date: Tue, 21 Jun 2022 18:57:31 -0400 Subject: [PATCH 1/7] String val for getType --- .../java/org/eclipse/microprofile/metrics/MetricRegistry.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/src/main/java/org/eclipse/microprofile/metrics/MetricRegistry.java b/api/src/main/java/org/eclipse/microprofile/metrics/MetricRegistry.java index f9af6005..e3083e6b 100644 --- a/api/src/main/java/org/eclipse/microprofile/metrics/MetricRegistry.java +++ b/api/src/main/java/org/eclipse/microprofile/metrics/MetricRegistry.java @@ -755,6 +755,6 @@ static String name(Class klass, String... names) { * * @return Type of this registry (VENDOR, BASE, APPLICATION) */ - Type getType(); + String getType(); } From 1b9fb146d1402a0f448d4913cbae737dde73c03b Mon Sep 17 00:00:00 2001 From: David Chan Date: Mon, 27 Jun 2022 21:39:43 -0400 Subject: [PATCH 2/7] Introduce ability to have custom scopes - Remove MetricRegistry.Type and use String constants instead - Change MetricRegistry.getType() to getScope() - @RegistryType no longer qualifier, param type() changed to scope() - Introduce scope annotation param to @Counted, @Timed, @Gauge and @Metric --- .../microprofile/metrics/MetricRegistry.java | 44 +++---------------- .../metrics/annotation/Counted.java | 10 +++++ .../metrics/annotation/Gauge.java | 11 +++++ .../metrics/annotation/Metric.java | 9 ++++ .../metrics/annotation/RegistryType.java | 26 ++++++----- .../metrics/annotation/Timed.java | 10 +++++ .../metrics/annotation/package-info.java | 2 +- .../main/asciidoc/app-programming-model.adoc | 6 +-- spec/src/main/asciidoc/appendix.adoc | 30 ++++--------- .../metrics/tck/MetricRegistryTest.java | 10 ++--- .../metrics/test/MpMetricTest.java | 26 +++++------ 11 files changed, 92 insertions(+), 92 deletions(-) diff --git a/api/src/main/java/org/eclipse/microprofile/metrics/MetricRegistry.java b/api/src/main/java/org/eclipse/microprofile/metrics/MetricRegistry.java index e3083e6b..58f13c71 100644 --- a/api/src/main/java/org/eclipse/microprofile/metrics/MetricRegistry.java +++ b/api/src/main/java/org/eclipse/microprofile/metrics/MetricRegistry.java @@ -42,43 +42,11 @@ */ public interface MetricRegistry { - /** - * An enumeration representing the scopes of the MetricRegistry - */ - enum Type { - /** - * The Application (default) scoped MetricRegistry. Any metric registered/accessed via CDI will use this - * MetricRegistry. - */ - APPLICATION("application"), - - /** - * The Base scoped MetricRegistry. This MetricRegistry will contain required metrics specified in the - * MicroProfile Metrics specification. - */ - BASE("base"), - - /** - * The Vendor scoped MetricRegistry. This MetricRegistry will contain vendor provided metrics which may vary - * between different vendors. - */ - VENDOR("vendor"); - - private final String name; - - Type(String name) { - this.name = name; - } - - /** - * Returns the name of the MetricRegistry scope. - * - * @return the scope - */ - public String getName() { - return name; - } - } + public static final String APPLICATION_SCOPE = "application"; + + public static final String VENDOR_SCOPE = "vendor"; + + public static final String BASE_SCOPE = "base"; /** * Concatenates elements to form a dotted name, eliding any null values or empty strings. @@ -755,6 +723,6 @@ static String name(Class klass, String... names) { * * @return Type of this registry (VENDOR, BASE, APPLICATION) */ - String getType(); + String getScope(); } diff --git a/api/src/main/java/org/eclipse/microprofile/metrics/annotation/Counted.java b/api/src/main/java/org/eclipse/microprofile/metrics/annotation/Counted.java index ea6e0296..65e4be80 100644 --- a/api/src/main/java/org/eclipse/microprofile/metrics/annotation/Counted.java +++ b/api/src/main/java/org/eclipse/microprofile/metrics/annotation/Counted.java @@ -29,6 +29,7 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; +import org.eclipse.microprofile.metrics.MetricRegistry; import org.eclipse.microprofile.metrics.MetricUnits; import jakarta.enterprise.util.Nonbinding; @@ -144,4 +145,13 @@ @Nonbinding String unit() default MetricUnits.NONE; + /** + * The scope that this counter belongs to. + * + * @return The scope this counter belongs to. By default, the value is {@link MetricRegistry.APPLICATION_SCOPE}. + * + */ + @Nonbinding + String scope() default MetricRegistry.APPLICATION_SCOPE; + } diff --git a/api/src/main/java/org/eclipse/microprofile/metrics/annotation/Gauge.java b/api/src/main/java/org/eclipse/microprofile/metrics/annotation/Gauge.java index 35853d65..3e97bb4b 100644 --- a/api/src/main/java/org/eclipse/microprofile/metrics/annotation/Gauge.java +++ b/api/src/main/java/org/eclipse/microprofile/metrics/annotation/Gauge.java @@ -27,6 +27,8 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; +import org.eclipse.microprofile.metrics.MetricRegistry; + import jakarta.enterprise.util.Nonbinding; import jakarta.interceptor.InterceptorBinding; @@ -115,4 +117,13 @@ @Nonbinding String unit(); + /** + * The scope that this gauge belongs to. + * + * @return The scope this gauge belongs to. By default, the value is {@link MetricRegistry.APPLICATION_SCOPE}. + * + */ + @Nonbinding + String scope() default MetricRegistry.APPLICATION_SCOPE; + } diff --git a/api/src/main/java/org/eclipse/microprofile/metrics/annotation/Metric.java b/api/src/main/java/org/eclipse/microprofile/metrics/annotation/Metric.java index d9cb517d..b1880e85 100644 --- a/api/src/main/java/org/eclipse/microprofile/metrics/annotation/Metric.java +++ b/api/src/main/java/org/eclipse/microprofile/metrics/annotation/Metric.java @@ -27,6 +27,7 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; +import org.eclipse.microprofile.metrics.MetricRegistry; import org.eclipse.microprofile.metrics.MetricUnits; import jakarta.enterprise.util.Nonbinding; @@ -114,4 +115,12 @@ @Nonbinding String unit() default MetricUnits.NONE; + /** + * The scope that this counter belongs to. + * + * @return The scope this counter belongs to. By default, the value is {@link MetricRegistry.APPLICATION_SCOPE}. + * + */ + @Nonbinding + String scope() default MetricRegistry.APPLICATION_SCOPE; } diff --git a/api/src/main/java/org/eclipse/microprofile/metrics/annotation/RegistryType.java b/api/src/main/java/org/eclipse/microprofile/metrics/annotation/RegistryType.java index be6aef7a..1acf3cdc 100644 --- a/api/src/main/java/org/eclipse/microprofile/metrics/annotation/RegistryType.java +++ b/api/src/main/java/org/eclipse/microprofile/metrics/annotation/RegistryType.java @@ -29,10 +29,8 @@ import org.eclipse.microprofile.metrics.MetricRegistry; -import jakarta.inject.Qualifier; - /** - * Qualifies the type of Metric Registry to inject. + * The type of Metric Registry to inject. *

* This can be used to obtain the respective scoped {@link MetricRegistry}: *

@@ -40,17 +38,21 @@ *
  * 
  *      {@literal @}Inject
- *      {@literal @}RegistryType(type=MetricRegistry.Type.BASE)
- *      MetricRegistry baseRegistry;
+ *      {@literal @}RegistryType(type=MetricRegistry.APPLICATION_SCOPE)
+ *      MetricRegistry appRegistry;
+ * 
+ *      {@literal @}Inject
+ *      {@literal @}RegistryType(type="customScope")
+ *      MetricRegistry appRegistry;
  * 
  * 
* - * @see org.eclipse.microprofile.metrics.MetricRegistry.Type + * see {@link MetricRegistry.APPLICATION_SCOPE}, {@link MetricRegistry.BASE_SCOPE} and + * {@link MetricRegistry.VEDNOR_SCOPE} * * @author Raymond Lam * */ -@Qualifier @Documented @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER, ElementType.ANNOTATION_TYPE}) @@ -58,9 +60,11 @@ /** * The scope of the MetricRegistry. * - * @return Returns the scope of the MetricRegistry. The {@link MetricRegistry.Type} can be {@code APPLICATION}, - * {@code BASE}, or {@code VENDOR}. - * @see org.eclipse.microprofile.metrics.MetricRegistry.Type + * @return Returns or creates the scope of the MetricRegistry. The MicroProfile runtimes provides + * {@code application}, {@code base} and {@code vendor} scopes as part of the runtime. + * + * see {@link MetricRegistry.APPLICATION_SCOPE}, {@link MetricRegistry.BASE_SCOPE} and + * {@link MetricRegistry.VEDNOR_SCOPE} */ - MetricRegistry.Type type() default MetricRegistry.Type.APPLICATION; + String scope() default MetricRegistry.APPLICATION_SCOPE; } diff --git a/api/src/main/java/org/eclipse/microprofile/metrics/annotation/Timed.java b/api/src/main/java/org/eclipse/microprofile/metrics/annotation/Timed.java index 139d92ba..830a4f35 100644 --- a/api/src/main/java/org/eclipse/microprofile/metrics/annotation/Timed.java +++ b/api/src/main/java/org/eclipse/microprofile/metrics/annotation/Timed.java @@ -29,6 +29,7 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; +import org.eclipse.microprofile.metrics.MetricRegistry; import org.eclipse.microprofile.metrics.MetricUnits; import jakarta.enterprise.util.Nonbinding; @@ -138,4 +139,13 @@ @Nonbinding String unit() default MetricUnits.NANOSECONDS; + /** + * The scope that this Timer belongs to. + * + * @return The scope this Timer belongs to. By default, the value is {@link MetricRegistry.APPLICATION_SCOPE}. + * + */ + @Nonbinding + String scope() default MetricRegistry.APPLICATION_SCOPE; + } diff --git a/api/src/main/java/org/eclipse/microprofile/metrics/annotation/package-info.java b/api/src/main/java/org/eclipse/microprofile/metrics/annotation/package-info.java index 1fcae015..bff683ea 100644 --- a/api/src/main/java/org/eclipse/microprofile/metrics/annotation/package-info.java +++ b/api/src/main/java/org/eclipse/microprofile/metrics/annotation/package-info.java @@ -79,7 +79,7 @@ *
  * 
  *      {@literal @}Inject
- *      {@literal @}RegistryType(type=MetricRegistry.Type.BASE)
+ *      {@literal @}RegistryType(type=MetricRegistry.BASE_SCOPE)
  *      MetricRegistry baseRegistry;
  * 
  * 
diff --git a/spec/src/main/asciidoc/app-programming-model.adoc b/spec/src/main/asciidoc/app-programming-model.adoc index cb7f815f..18f794d6 100644 --- a/spec/src/main/asciidoc/app-programming-model.adoc +++ b/spec/src/main/asciidoc/app-programming-model.adoc @@ -493,7 +493,7 @@ MetricRegistry metricRegistry; [source, java] ---- @Inject -@RegistryType(type=MetricRegistry.Type.APPLICATION) +@RegistryType(scope=MetricRegistry.APPLICATION_SCOPE) MetricRegistry metricRegistry; ---- @@ -504,7 +504,7 @@ The implementation must produce the _base_ `MetricRegistry` when the `RegistryTy [source, java] ---- @Inject -@RegistryType(type=MetricRegistry.Type.BASE) +@RegistryType(scope=MetricRegistry.BASE_SCOPE) MetricRegistry baseRegistry; ---- @@ -515,7 +515,7 @@ The implementation must produce the _vendor_ `MetricRegistry` when the `Registry [source, java] ---- @Inject -@RegistryType(type=MetricRegistry.Type.VENDOR) +@RegistryType(scope=MetricRegistry.VENDOR_SCOPE) MetricRegistry vendorRegistry; ---- diff --git a/spec/src/main/asciidoc/appendix.adoc b/spec/src/main/asciidoc/appendix.adoc index 144abd80..8301b2f0 100644 --- a/spec/src/main/asciidoc/appendix.adoc +++ b/spec/src/main/asciidoc/appendix.adoc @@ -89,29 +89,17 @@ This configuration can be backed into the runtime or be provided via an external public class MetricRegistryFactory { @Produces - public static MetricRegistry getDefaultRegistry() { - return getApplicationRegistry(); - } + @Default + public MetricRegistry getApplicationRegistry(InjectionPoint ip) { - @Produces - @RegistryType(type = Type.APPLICATION) - public static MetricRegistry getApplicationRegistry() { - // Returns the static instance of the Application MetricRegistry - [...] - } + RegistryType registryTypeAnnotation = ip.getAnnotated().getAnnotation(RegistryType.class); - @Produces - @RegistryType(type = Type.BASE) - public static MetricRegistry getBaseRegistry() { - // Returns the static instance of the Base MetricRegistry - [...] - } - - @Produces - @RegistryType(type = Type.VENDOR) - public static MetricRegistry getVendorRegistry() { - // Returns the static instance of the Vendor MetricRegistry - [...] + if (registryTypeAnnotation == null) { + return getOrCreate(MetricRegistry.APPLICATION_SCOPE); + } else { + String annoScope = registryTypeAnnotation.scope(); + return getOrCreate(annoScope); + } } } diff --git a/tck/api/src/main/java/org/eclipse/microprofile/metrics/tck/MetricRegistryTest.java b/tck/api/src/main/java/org/eclipse/microprofile/metrics/tck/MetricRegistryTest.java index 37683a99..9f173b7a 100644 --- a/tck/api/src/main/java/org/eclipse/microprofile/metrics/tck/MetricRegistryTest.java +++ b/tck/api/src/main/java/org/eclipse/microprofile/metrics/tck/MetricRegistryTest.java @@ -55,11 +55,11 @@ public class MetricRegistryTest { private MetricRegistry metrics; @Inject - @RegistryType(type = MetricRegistry.Type.BASE) + @RegistryType(scope = MetricRegistry.BASE_SCOPE) private MetricRegistry baseMetrics; @Inject - @RegistryType(type = MetricRegistry.Type.VENDOR) + @RegistryType(scope = MetricRegistry.VENDOR_SCOPE) private MetricRegistry vendorMetrics; @Deployment @@ -106,9 +106,9 @@ public void useExistingMetaDataTest() { @Test @InSequence(5) public void testMetricRegistryType() { - Assert.assertEquals(MetricRegistry.Type.APPLICATION, metrics.getType()); - Assert.assertEquals(MetricRegistry.Type.BASE, baseMetrics.getType()); - Assert.assertEquals(MetricRegistry.Type.VENDOR, vendorMetrics.getType()); + Assert.assertEquals(MetricRegistry.APPLICATION_SCOPE, metrics.getScope()); + Assert.assertEquals(MetricRegistry.BASE_SCOPE, baseMetrics.getScope()); + Assert.assertEquals(MetricRegistry.VENDOR_SCOPE, vendorMetrics.getScope()); } private void assertExists(Class expected, MetricID metricID) { diff --git a/tck/rest/src/main/java/org/eclipse/microprofile/metrics/test/MpMetricTest.java b/tck/rest/src/main/java/org/eclipse/microprofile/metrics/test/MpMetricTest.java index 6db751ae..99263b22 100644 --- a/tck/rest/src/main/java/org/eclipse/microprofile/metrics/test/MpMetricTest.java +++ b/tck/rest/src/main/java/org/eclipse/microprofile/metrics/test/MpMetricTest.java @@ -262,7 +262,7 @@ public void testBaseSingularMetricsPresent() { List missing = new ArrayList<>(); - Map baseNames = getExpectedMetadataFromXmlFile(MetricRegistry.Type.BASE); + Map baseNames = getExpectedMetadataFromXmlFile(MetricRegistry.BASE_SCOPE); for (MiniMeta item : baseNames.values()) { if (item.name.startsWith("gc.")) { @@ -316,7 +316,7 @@ public void testBaseMetadataSingluarItems() { Map elements = jsonPath.getMap("."); List missing = new ArrayList<>(); - Map baseNames = getExpectedMetadataFromXmlFile(MetricRegistry.Type.BASE); + Map baseNames = getExpectedMetadataFromXmlFile(MetricRegistry.BASE_SCOPE); for (String item : baseNames.keySet()) { if (item.startsWith("gc.") || baseNames.get(item).optional) { continue; @@ -340,7 +340,7 @@ public void testBaseMetadataTypeAndUnit() { Map> elements = jsonPath.getMap("."); - Map expectedMetadata = getExpectedMetadataFromXmlFile(MetricRegistry.Type.BASE); + Map expectedMetadata = getExpectedMetadataFromXmlFile(MetricRegistry.BASE_SCOPE); checkMetadataPresent(elements, expectedMetadata); } @@ -408,7 +408,7 @@ public void testBaseMetadataSingluarItemsOpenMetrics() { String[] lines = data.split("\n"); - Map expectedMetadata = getExpectedMetadataFromXmlFile(MetricRegistry.Type.BASE); + Map expectedMetadata = getExpectedMetadataFromXmlFile(MetricRegistry.BASE_SCOPE); for (MiniMeta mm : expectedMetadata.values()) { boolean found = false; @@ -571,7 +571,7 @@ public void testApplicationMetadataItems() { List missing = new ArrayList<>(); - Map names = getExpectedMetadataFromXmlFile(MetricRegistry.Type.APPLICATION); + Map names = getExpectedMetadataFromXmlFile(MetricRegistry.APPLICATION_SCOPE); for (String item : names.keySet()) { if (!elements.containsKey(item)) { missing.add(item); @@ -590,7 +590,7 @@ public void testApplicationMetadataTypeAndUnit() { Map> elements = jsonPath.getMap("."); - Map expectedMetadata = getExpectedMetadataFromXmlFile(MetricRegistry.Type.APPLICATION); + Map expectedMetadata = getExpectedMetadataFromXmlFile(MetricRegistry.APPLICATION_SCOPE); checkMetadataPresent(elements, expectedMetadata); } @@ -777,7 +777,7 @@ public void testOptionalBaseMetrics() { JsonPath jsonPath = given().header(wantJson).options("/metrics/base").jsonPath(); Map elements = jsonPath.getMap("."); - Map names = getExpectedMetadataFromXmlFile(MetricRegistry.Type.BASE); + Map names = getExpectedMetadataFromXmlFile(MetricRegistry.BASE_SCOPE); for (MiniMeta item : names.values()) { if (elements.containsKey(item.toJSONName()) && names.get(item.name).optional) { @@ -911,7 +911,7 @@ public void testGcCountMetrics() { Header wantJson = new Header("Accept", APPLICATION_JSON); JsonPath jsonPath = given().header(wantJson).get("/metrics/base").jsonPath(); - Map baseNames = getExpectedMetadataFromXmlFile(MetricRegistry.Type.BASE); + Map baseNames = getExpectedMetadataFromXmlFile(MetricRegistry.BASE_SCOPE); MiniMeta gcCountMetricMeta = baseNames.get("gc.total"); Set expectedTags = gcCountMetricMeta.tags.keySet(); @@ -948,7 +948,7 @@ public void testGcTimeMetrics() { Header wantJson = new Header("Accept", APPLICATION_JSON); JsonPath jsonPath = given().header(wantJson).get("/metrics/base").jsonPath(); - Map baseNames = getExpectedMetadataFromXmlFile(MetricRegistry.Type.BASE); + Map baseNames = getExpectedMetadataFromXmlFile(MetricRegistry.BASE_SCOPE); MiniMeta gcTimeMetricMeta = baseNames.get("gc.time"); Set expectedTags = gcTimeMetricMeta.tags.keySet(); @@ -1109,18 +1109,18 @@ private Matcher closeTo(double operand) { return allOf(greaterThan((float) (operand - delta)), lessThan((float) (operand + delta))); } - private Map getExpectedMetadataFromXmlFile(MetricRegistry.Type scope) { + private Map getExpectedMetadataFromXmlFile(String scope) { ClassLoader cl = this.getClass().getClassLoader(); String fileName; switch (scope) { - case BASE : + case "base" : fileName = "base_metrics.xml"; break; - case APPLICATION : + case "application" : fileName = "application_metrics.xml"; break; default : - throw new IllegalArgumentException("No definitions for " + scope.getName() + " supported"); + throw new IllegalArgumentException("No definitions for " + scope + " supported"); } InputStream is = cl.getResourceAsStream(fileName); From 23635ae0af50d4bd06a052d32afe13cf3b2b7871 Mon Sep 17 00:00:00 2001 From: David Chan Date: Tue, 28 Jun 2022 10:11:09 -0400 Subject: [PATCH 3/7] Doc + copyright --- .../microprofile/metrics/annotation/Gauge.java | 2 +- .../microprofile/metrics/annotation/Metric.java | 2 +- .../metrics/annotation/RegistryType.java | 15 ++++++++------- .../metrics/annotation/package-info.java | 10 +++++----- 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/api/src/main/java/org/eclipse/microprofile/metrics/annotation/Gauge.java b/api/src/main/java/org/eclipse/microprofile/metrics/annotation/Gauge.java index 3e97bb4b..cb58033c 100644 --- a/api/src/main/java/org/eclipse/microprofile/metrics/annotation/Gauge.java +++ b/api/src/main/java/org/eclipse/microprofile/metrics/annotation/Gauge.java @@ -1,6 +1,6 @@ /* ********************************************************************** - * Copyright (c) 2017 Contributors to the Eclipse Foundation + * Copyright (c) 2017, 2022 Contributors to the Eclipse Foundation * 2010-2013 Coda Hale, Yammer.com * * See the NOTICES file(s) distributed with this work for additional diff --git a/api/src/main/java/org/eclipse/microprofile/metrics/annotation/Metric.java b/api/src/main/java/org/eclipse/microprofile/metrics/annotation/Metric.java index b1880e85..41e95ef9 100644 --- a/api/src/main/java/org/eclipse/microprofile/metrics/annotation/Metric.java +++ b/api/src/main/java/org/eclipse/microprofile/metrics/annotation/Metric.java @@ -1,6 +1,6 @@ /* ********************************************************************** - * Copyright (c) 2017, 2019 Contributors to the Eclipse Foundation + * Copyright (c) 2017, 2022 Contributors to the Eclipse Foundation * 2012 Ryan W Tenney (ryan@10e.us) * * See the NOTICES file(s) distributed with this work for additional diff --git a/api/src/main/java/org/eclipse/microprofile/metrics/annotation/RegistryType.java b/api/src/main/java/org/eclipse/microprofile/metrics/annotation/RegistryType.java index 1acf3cdc..d22167b5 100644 --- a/api/src/main/java/org/eclipse/microprofile/metrics/annotation/RegistryType.java +++ b/api/src/main/java/org/eclipse/microprofile/metrics/annotation/RegistryType.java @@ -1,6 +1,6 @@ /* ********************************************************************** - * Copyright (c) 2017 Contributors to the Eclipse Foundation + * Copyright (c) 2017, 2022 Contributors to the Eclipse Foundation * * See the NOTICES file(s) distributed with this work for additional * information regarding copyright ownership. @@ -30,7 +30,7 @@ import org.eclipse.microprofile.metrics.MetricRegistry; /** - * The type of Metric Registry to inject. + * The scope of Metric Registry to inject. *

* This can be used to obtain the respective scoped {@link MetricRegistry}: *

@@ -38,17 +38,18 @@ *
  * 
  *      {@literal @}Inject
- *      {@literal @}RegistryType(type=MetricRegistry.APPLICATION_SCOPE)
+ *      {@literal @}RegistryType(scope=MetricRegistry.APPLICATION_SCOPE)
  *      MetricRegistry appRegistry;
  * 
  *      {@literal @}Inject
- *      {@literal @}RegistryType(type="customScope")
- *      MetricRegistry appRegistry;
+ *      {@literal @}RegistryType(scope="customScope")
+ *      MetricRegistry customRegistry;
+ * 
  * 
  * 
* * see {@link MetricRegistry.APPLICATION_SCOPE}, {@link MetricRegistry.BASE_SCOPE} and - * {@link MetricRegistry.VEDNOR_SCOPE} + * {@link MetricRegistry.VENDOR_SCOPE} * * @author Raymond Lam * @@ -64,7 +65,7 @@ * {@code application}, {@code base} and {@code vendor} scopes as part of the runtime. * * see {@link MetricRegistry.APPLICATION_SCOPE}, {@link MetricRegistry.BASE_SCOPE} and - * {@link MetricRegistry.VEDNOR_SCOPE} + * {@link MetricRegistry.VENDOR_SCOPE} */ String scope() default MetricRegistry.APPLICATION_SCOPE; } diff --git a/api/src/main/java/org/eclipse/microprofile/metrics/annotation/package-info.java b/api/src/main/java/org/eclipse/microprofile/metrics/annotation/package-info.java index bff683ea..653e7a26 100644 --- a/api/src/main/java/org/eclipse/microprofile/metrics/annotation/package-info.java +++ b/api/src/main/java/org/eclipse/microprofile/metrics/annotation/package-info.java @@ -70,17 +70,17 @@ * * * - *

CDI Qualifier

+ *

RegistryType annotation

*

* The {@link org.eclipse.microprofile.metrics.annotation.RegistryType RegistryType} is used to identify which - * MetricRegistry (Application, Base, or Vendor) should be injected. By default, no - * RegistryType will inject the application MetricRegistry. + * MetricRegistry (Application, Base, Vendor or a user defined scope) should be injected. By default + * no RegistryType will inject the application MetricRegistry. * *

  * 
  *      {@literal @}Inject
- *      {@literal @}RegistryType(type=MetricRegistry.BASE_SCOPE)
- *      MetricRegistry baseRegistry;
+ *      {@literal @}RegistryType(scope=MetricRegistry.APPLICATION_SCOPE)
+ *      MetricRegistry appRegistry;
  * 
  * 
* From e42db8067551251b35aa19e2665c6c7722720eeb Mon Sep 17 00:00:00 2001 From: David Chan Date: Thu, 14 Jul 2022 13:31:54 -0400 Subject: [PATCH 4/7] plugin auto- formatting --- .../eclipse/microprofile/metrics/annotation/package-info.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/src/main/java/org/eclipse/microprofile/metrics/annotation/package-info.java b/api/src/main/java/org/eclipse/microprofile/metrics/annotation/package-info.java index 653e7a26..8f9f56d1 100644 --- a/api/src/main/java/org/eclipse/microprofile/metrics/annotation/package-info.java +++ b/api/src/main/java/org/eclipse/microprofile/metrics/annotation/package-info.java @@ -73,8 +73,8 @@ *

RegistryType annotation

*

* The {@link org.eclipse.microprofile.metrics.annotation.RegistryType RegistryType} is used to identify which - * MetricRegistry (Application, Base, Vendor or a user defined scope) should be injected. By default - * no RegistryType will inject the application MetricRegistry. + * MetricRegistry (Application, Base, Vendor or a user defined scope) should be injected. By default no + * RegistryType will inject the application MetricRegistry. * *

  * 

From 2a3cb1ad8910811e2a3c7819c41fad722de95ec6 Mon Sep 17 00:00:00 2001
From: David Chan 
Date: Thu, 4 Aug 2022 11:59:19 -0400
Subject: [PATCH 5/7] doc fixes + add custom scope test to MetricRegistryTest

---
 .../org/eclipse/microprofile/metrics/MetricRegistry.java   | 4 ++--
 .../eclipse/microprofile/metrics/annotation/Metric.java    | 4 ++--
 .../microprofile/metrics/annotation/RegistryType.java      | 2 +-
 .../microprofile/metrics/tck/MetricRegistryTest.java       | 7 +++++++
 4 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/api/src/main/java/org/eclipse/microprofile/metrics/MetricRegistry.java b/api/src/main/java/org/eclipse/microprofile/metrics/MetricRegistry.java
index 58f13c71..35acc7aa 100644
--- a/api/src/main/java/org/eclipse/microprofile/metrics/MetricRegistry.java
+++ b/api/src/main/java/org/eclipse/microprofile/metrics/MetricRegistry.java
@@ -719,9 +719,9 @@ static String name(Class klass, String... names) {
     Map 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();
 
diff --git a/api/src/main/java/org/eclipse/microprofile/metrics/annotation/Metric.java b/api/src/main/java/org/eclipse/microprofile/metrics/annotation/Metric.java
index 41e95ef9..3b3b199b 100644
--- a/api/src/main/java/org/eclipse/microprofile/metrics/annotation/Metric.java
+++ b/api/src/main/java/org/eclipse/microprofile/metrics/annotation/Metric.java
@@ -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
diff --git a/api/src/main/java/org/eclipse/microprofile/metrics/annotation/RegistryType.java b/api/src/main/java/org/eclipse/microprofile/metrics/annotation/RegistryType.java
index d22167b5..346ad4bd 100644
--- a/api/src/main/java/org/eclipse/microprofile/metrics/annotation/RegistryType.java
+++ b/api/src/main/java/org/eclipse/microprofile/metrics/annotation/RegistryType.java
@@ -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.
  * 

* This can be used to obtain the respective scoped {@link MetricRegistry}: *

diff --git a/tck/api/src/main/java/org/eclipse/microprofile/metrics/tck/MetricRegistryTest.java b/tck/api/src/main/java/org/eclipse/microprofile/metrics/tck/MetricRegistryTest.java index 9f173b7a..7d6fa1b1 100644 --- a/tck/api/src/main/java/org/eclipse/microprofile/metrics/tck/MetricRegistryTest.java +++ b/tck/api/src/main/java/org/eclipse/microprofile/metrics/tck/MetricRegistryTest.java @@ -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; @@ -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"); @@ -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 expected, MetricID metricID) { From a0cf5179ae2ae1eed82b633937493de83e4b02ee Mon Sep 17 00:00:00 2001 From: David Chan Date: Fri, 5 Aug 2022 14:25:50 -0400 Subject: [PATCH 6/7] Change RegistryType to RegistryScope + document changes from comments --- .../microprofile/metrics/MetricRegistry.java | 9 ++++++ .../{RegistryType.java => RegistryScope.java} | 11 +++---- .../metrics/annotation/package-info.java | 10 +++---- .../main/asciidoc/app-programming-model.adoc | 30 +++++++++---------- spec/src/main/asciidoc/appendix.adoc | 4 +-- .../metrics/tck/MetricRegistryTest.java | 10 +++---- 6 files changed, 42 insertions(+), 32 deletions(-) rename api/src/main/java/org/eclipse/microprofile/metrics/annotation/{RegistryType.java => RegistryScope.java} (86%) diff --git a/api/src/main/java/org/eclipse/microprofile/metrics/MetricRegistry.java b/api/src/main/java/org/eclipse/microprofile/metrics/MetricRegistry.java index 35acc7aa..4723cb9b 100644 --- a/api/src/main/java/org/eclipse/microprofile/metrics/MetricRegistry.java +++ b/api/src/main/java/org/eclipse/microprofile/metrics/MetricRegistry.java @@ -42,10 +42,19 @@ */ public interface MetricRegistry { + /** + * String constant to represent the scope value used for the application scope + */ public static final String APPLICATION_SCOPE = "application"; + /** + * String constant to represent the scope value used for the vendor scope + */ public static final String VENDOR_SCOPE = "vendor"; + /** + * String constant to represent the scope value used for the base scope + */ public static final String BASE_SCOPE = "base"; /** diff --git a/api/src/main/java/org/eclipse/microprofile/metrics/annotation/RegistryType.java b/api/src/main/java/org/eclipse/microprofile/metrics/annotation/RegistryScope.java similarity index 86% rename from api/src/main/java/org/eclipse/microprofile/metrics/annotation/RegistryType.java rename to api/src/main/java/org/eclipse/microprofile/metrics/annotation/RegistryScope.java index 346ad4bd..8b794841 100644 --- a/api/src/main/java/org/eclipse/microprofile/metrics/annotation/RegistryType.java +++ b/api/src/main/java/org/eclipse/microprofile/metrics/annotation/RegistryScope.java @@ -38,11 +38,11 @@ *
  * 
  *      {@literal @}Inject
- *      {@literal @}RegistryType(scope=MetricRegistry.APPLICATION_SCOPE)
+ *      {@literal @}RegistryScope(scope=MetricRegistry.APPLICATION_SCOPE)
  *      MetricRegistry appRegistry;
  * 
  *      {@literal @}Inject
- *      {@literal @}RegistryType(scope="customScope")
+ *      {@literal @}RegistryScope(scope="customScope")
  *      MetricRegistry customRegistry;
  * 
  * 
@@ -57,12 +57,13 @@
 @Documented
 @Retention(RetentionPolicy.RUNTIME)
 @Target({ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER, ElementType.ANNOTATION_TYPE})
-public @interface RegistryType {
+public @interface RegistryScope {
     /**
      * The scope of the MetricRegistry.
      * 
-     * @return Returns or creates the scope of the MetricRegistry. The MicroProfile runtimes provides
-     *         {@code application}, {@code base} and {@code vendor} scopes as part of the runtime.
+     * @return Indicates the scope of the MetricRegistry to be injected. The MicroProfile runtimes provides
+     *         {@code application}, {@code base} and {@code vendor} scopes automatically and creates user-defined scopes
+     *         as needed.
      * 
      *         see {@link MetricRegistry.APPLICATION_SCOPE}, {@link MetricRegistry.BASE_SCOPE} and
      *         {@link MetricRegistry.VENDOR_SCOPE}
diff --git a/api/src/main/java/org/eclipse/microprofile/metrics/annotation/package-info.java b/api/src/main/java/org/eclipse/microprofile/metrics/annotation/package-info.java
index 8f9f56d1..6d846b94 100644
--- a/api/src/main/java/org/eclipse/microprofile/metrics/annotation/package-info.java
+++ b/api/src/main/java/org/eclipse/microprofile/metrics/annotation/package-info.java
@@ -70,16 +70,16 @@
  * 
* * - *

RegistryType annotation

+ *

RegistryScope annotation

*

- * The {@link org.eclipse.microprofile.metrics.annotation.RegistryType RegistryType} is used to identify which - * MetricRegistry (Application, Base, Vendor or a user defined scope) should be injected. By default no - * RegistryType will inject the application MetricRegistry. + * The {@link org.eclipse.microprofile.metrics.annotation.RegistryScope RegistryScope} is used to identify which + * MetricRegistry (Application, Base, Vendor or a user-defined scope) should be injected. By default, no + * RegistryScope will inject the application MetricRegistry. * *

  * 
  *      {@literal @}Inject
- *      {@literal @}RegistryType(scope=MetricRegistry.APPLICATION_SCOPE)
+ *      {@literal @}RegistryScope(scope=MetricRegistry.APPLICATION_SCOPE)
  *      MetricRegistry appRegistry;
  * 
  * 
diff --git a/spec/src/main/asciidoc/app-programming-model.adoc b/spec/src/main/asciidoc/app-programming-model.adoc index 18f794d6..13c74b8b 100644 --- a/spec/src/main/asciidoc/app-programming-model.adoc +++ b/spec/src/main/asciidoc/app-programming-model.adoc @@ -106,12 +106,12 @@ The following Annotations exist, see below for common fields: |=== |Annotation | Description | Default -|@RegistryType| Qualifies the scope of Metric Registry to inject when injecting a MetricRegistry. | _application_ (scope) +|@RegistryScope| Indicates the scope of Metric Registry to inject when injecting a MetricRegistry. | _application_ (scope) |=== ==== Fields -All annotations (Except `RegistryType`) have the following fields that correspond to the metadata fields described +All annotations (Except `RegistryScope`) have the following fields that correspond to the metadata fields described in <>. `String name`:: Optional. Sets the name of the metric. If not explicitly given the name of the annotated object is used. @@ -120,6 +120,7 @@ If `false`, prepends the package name and class name before the given name. Defa `String displayName`:: Optional. A human readable display name for metadata. `String description`:: Optional. A description of the metric. `String unit`:: Unit of the metric. For `@Gauge` no default is provided. Check the `MetricUnits` class for a set of pre-defined units. +`String scope`:: Optional. The `MetricRegistry` scope that this metric belongs to. Default value is `application`. NOTE: Implementors are encouraged to issue warnings in the server log if metadata is missing. Implementors MAY stop the deployment of an application if Metadata is missing. @@ -468,19 +469,19 @@ There is one shared singleton of the `MetricRegistry` per pre-defined scope (_ap There is also one shared singleton of the `MetricRegistry` per custom scope. When metrics are registered using annotations and no scope is provided, the metrics are registered in the _application_ `MetricRegistry` (and thus the _application_ scope). -When injected, the `@RegistryType` is used as a qualifier to selectively inject one of the `APPLICATION`, `BASE`, `VENDOR` or custom registries. -If no qualifier is used, the default `MetricRegistry` returned is the `APPLICATION` registry. +When injected, the `@RegistryScope` is used to selectively inject one of the `APPLICATION`, `BASE`, `VENDOR` or custom registries. +If no _scope_ parameter is used, the default `MetricRegistry` returned is the `application` registry. Implementations may choose to use a Factory class to produce the injectable `MetricRegistry` bean via CDI. See <>. Note: The factory would be an internal class and not exposed to the application. -==== @RegistryType -The `@RegistryType` can be used to retrieve the `MetricRegistry` for a specific scope. -The implementation must produce the corresponding `MetricRegistry` specified by the `RegistryType`. +==== @RegistryScope +The `@RegistryScope` can be used to retrieve the `MetricRegistry` for a specific scope. +The implementation must produce the corresponding `MetricRegistry` specified by the `RegistryScope`. NOTE: The implementor can optionally provide a _read_only_ copy of the `MetricRegistry` for _base_ and _vendor_ scopes. ==== Application Metric Registry -The implementation must produce the _application_ `MetricRegistry` when no `RegistryType` is provided (`@Default`) or when the `RegistryType` is `APPLICATION`. +The implementation must produce the _application_ `MetricRegistry` when no `RegistryScope` is provided (`@Default`) or when the `RegistryScope` is `APPLICATION`. Application defined metrics can also be registered to <> .Example of the application injecting the application registry [source, java] @@ -493,32 +494,33 @@ MetricRegistry metricRegistry; [source, java] ---- @Inject -@RegistryType(scope=MetricRegistry.APPLICATION_SCOPE) +@RegistryScope(scope=MetricRegistry.APPLICATION_SCOPE) MetricRegistry metricRegistry; ---- ==== Base Metric Registry -The implementation must produce the _base_ `MetricRegistry` when the `RegistryType` is `BASE`. The _base_ `MetricRegistry` must contain the required metrics specified in <>. +The implementation must produce the _base_ `MetricRegistry` when the `RegistryScope` is `BASE`. The _base_ `MetricRegistry` must contain the required metrics specified in <>. .Example of the application injecting the base registry [source, java] ---- @Inject -@RegistryType(scope=MetricRegistry.BASE_SCOPE) +@RegistryScope(scope=MetricRegistry.BASE_SCOPE) MetricRegistry baseRegistry; ---- ==== Vendor Metric Registry -The implementation must produce the _vendor_ `MetricRegistry` when the `RegistryType` is `VENDOR`. The _vendor_ `MetricRegistry` must contain any vendor specific metrics. +The implementation must produce the _vendor_ `MetricRegistry` when the `RegistryScope` is `VENDOR`. The _vendor_ `MetricRegistry` must contain any vendor specific metrics. .Example of the application injecting the vendor registry [source, java] ---- @Inject -@RegistryType(scope=MetricRegistry.VENDOR_SCOPE) +@RegistryScope(scope=MetricRegistry.VENDOR_SCOPE) MetricRegistry vendorRegistry; ---- +[[pgm-custom-scope]] ==== Custom Metric Registries The implementation must produce the `MetricRegistry` corresponding to the custom-named registry when the `RegistryType` is a custom value. If the custom-named MetricRegistry does not yet exist the implementation must create a `MetricRegistry` with the specified name. @@ -530,8 +532,6 @@ The implementation must produce the `MetricRegistry` corresponding to the custom MetricRegistry motorGuideRegistry; ---- - - [[pgm-metadata]] ==== Metadata diff --git a/spec/src/main/asciidoc/appendix.adoc b/spec/src/main/asciidoc/appendix.adoc index 8301b2f0..1eacc055 100644 --- a/spec/src/main/asciidoc/appendix.adoc +++ b/spec/src/main/asciidoc/appendix.adoc @@ -90,9 +90,9 @@ public class MetricRegistryFactory { @Produces @Default - public MetricRegistry getApplicationRegistry(InjectionPoint ip) { + public MetricRegistry getMetricRegistry(InjectionPoint ip) { - RegistryType registryTypeAnnotation = ip.getAnnotated().getAnnotation(RegistryType.class); + RegistryScope registryTypeAnnotation = ip.getAnnotated().getAnnotation(RegistryScope.class); if (registryTypeAnnotation == null) { return getOrCreate(MetricRegistry.APPLICATION_SCOPE); diff --git a/tck/api/src/main/java/org/eclipse/microprofile/metrics/tck/MetricRegistryTest.java b/tck/api/src/main/java/org/eclipse/microprofile/metrics/tck/MetricRegistryTest.java index 7d6fa1b1..175d68fe 100644 --- a/tck/api/src/main/java/org/eclipse/microprofile/metrics/tck/MetricRegistryTest.java +++ b/tck/api/src/main/java/org/eclipse/microprofile/metrics/tck/MetricRegistryTest.java @@ -31,7 +31,7 @@ import org.eclipse.microprofile.metrics.MetricType; import org.eclipse.microprofile.metrics.Tag; import org.eclipse.microprofile.metrics.annotation.Metric; -import org.eclipse.microprofile.metrics.annotation.RegistryType; +import org.eclipse.microprofile.metrics.annotation.RegistryScope; import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.arquillian.junit.InSequence; @@ -57,15 +57,15 @@ public class MetricRegistryTest { private MetricRegistry metrics; @Inject - @RegistryType(scope = MetricRegistry.BASE_SCOPE) + @RegistryScope(scope = MetricRegistry.BASE_SCOPE) private MetricRegistry baseMetrics; @Inject - @RegistryType(scope = MetricRegistry.VENDOR_SCOPE) + @RegistryScope(scope = MetricRegistry.VENDOR_SCOPE) private MetricRegistry vendorMetrics; @Inject - @RegistryType(scope = CUSTOM_SCOPE) + @RegistryScope(scope = CUSTOM_SCOPE) private MetricRegistry customScope; @Deployment @@ -111,7 +111,7 @@ public void useExistingMetaDataTest() { @Test @InSequence(5) - public void testMetricRegistryType() { + public void testMetricRegistryScope() { Assert.assertEquals(MetricRegistry.APPLICATION_SCOPE, metrics.getScope()); Assert.assertEquals(MetricRegistry.BASE_SCOPE, baseMetrics.getScope()); Assert.assertEquals(MetricRegistry.VENDOR_SCOPE, vendorMetrics.getScope()); From 486eec594a3f84683e20215817ad24696cba8596 Mon Sep 17 00:00:00 2001 From: David Chan Date: Fri, 5 Aug 2022 15:50:05 -0400 Subject: [PATCH 7/7] typos! --- .../metrics/annotation/package-info.java | 5 +++-- spec/src/main/asciidoc/app-programming-model.adoc | 13 ++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/api/src/main/java/org/eclipse/microprofile/metrics/annotation/package-info.java b/api/src/main/java/org/eclipse/microprofile/metrics/annotation/package-info.java index 6d846b94..423df588 100644 --- a/api/src/main/java/org/eclipse/microprofile/metrics/annotation/package-info.java +++ b/api/src/main/java/org/eclipse/microprofile/metrics/annotation/package-info.java @@ -73,8 +73,9 @@ *

RegistryScope annotation

*

* The {@link org.eclipse.microprofile.metrics.annotation.RegistryScope RegistryScope} is used to identify which - * MetricRegistry (Application, Base, Vendor or a user-defined scope) should be injected. By default, no - * RegistryScope will inject the application MetricRegistry. + * MetricRegistry (Application, Base, Vendor or a user-defined scope) should be injected. Injecting a + * MetricRegistry without a RegistryScope annotation gives the application-scoped + * MetricRegistry. * *

  * 
diff --git a/spec/src/main/asciidoc/app-programming-model.adoc b/spec/src/main/asciidoc/app-programming-model.adoc
index 13c74b8b..46cbee7d 100644
--- a/spec/src/main/asciidoc/app-programming-model.adoc
+++ b/spec/src/main/asciidoc/app-programming-model.adoc
@@ -469,7 +469,7 @@ There is one shared singleton of the `MetricRegistry` per pre-defined scope (_ap
 There is also one shared singleton of the `MetricRegistry` per custom scope.
 When metrics are registered using annotations and no scope is provided, the metrics are registered in the _application_ `MetricRegistry` (and thus the _application_ scope).
 
-When injected, the `@RegistryScope` is used to selectively inject one of the `APPLICATION`, `BASE`, `VENDOR` or custom registries.
+When injected, the `@RegistryScope` is used to selectively inject one of the `application`, `base`, `vendor` or custom registries.
 If no _scope_ parameter is used, the default `MetricRegistry` returned is the `application` registry.
 
 Implementations may choose to use a Factory class to produce the injectable `MetricRegistry` bean via CDI. See <>. Note: The factory would be an internal class and not exposed to the application.
@@ -481,7 +481,7 @@ The implementation must produce the corresponding `MetricRegistry` specified by
 NOTE: The implementor can optionally provide a _read_only_ copy of the `MetricRegistry` for _base_ and _vendor_ scopes.
 
 ==== Application Metric Registry
-The implementation must produce the _application_ `MetricRegistry` when no `RegistryScope` is provided (`@Default`) or when the `RegistryScope` is `APPLICATION`. Application defined metrics can also be registered to <>
+The implementation must produce the _application_ `MetricRegistry` when no `RegistryScope` is provided or when the `RegistryScope` is `application` (i.e. `MetricRegistry.APPLICATION_SCOPE`). Application-defined metrics can also be registered to <>
 
 .Example of the application injecting the application registry
 [source, java]
@@ -499,7 +499,7 @@ MetricRegistry metricRegistry;
 ----
 
 ==== Base Metric Registry
-The implementation must produce the _base_ `MetricRegistry` when the `RegistryScope` is `BASE`. The _base_ `MetricRegistry` must contain the required metrics specified in <>.
+The implementation must produce the _base_ `MetricRegistry` when the `RegistryScope` is `base` (i.e. `MetricRegistry.BASE_SCOPE`). The _base_ `MetricRegistry` must contain the required metrics specified in <>.
 
 .Example of the application injecting the base registry
 [source, java]
@@ -510,7 +510,7 @@ MetricRegistry baseRegistry;
 ----
 
 ==== Vendor Metric Registry
-The implementation must produce the _vendor_ `MetricRegistry` when the `RegistryScope` is `VENDOR`. The _vendor_ `MetricRegistry` must contain any vendor specific metrics.
+The implementation must produce the _vendor_ `MetricRegistry` when the `RegistryScope` is `vendor` (i.e. `MetricRegistry.VENDOR_SCOPE`). The _vendor_ `MetricRegistry` must contain any vendor specific metrics.
 
 .Example of the application injecting the vendor registry
 [source, java]
@@ -521,14 +521,13 @@ MetricRegistry vendorRegistry;
 ----
 
 [[pgm-custom-scope]]
-==== Custom Metric Registries
-The implementation must produce the `MetricRegistry` corresponding to the custom-named registry when the `RegistryType` is a custom value. If the custom-named MetricRegistry does not yet exist the implementation must create a `MetricRegistry` with the specified name.
+The implementation must produce the `MetricRegistry` corresponding to the custom-named registry when the `RegistryType` is a custom value. If the custom-named `MetricRegistry` does not yet exist the implementation must create a `MetricRegistry` with the specified name.
 
 .Example of the application injecting a custom-named registry
 [source, java]
 ----
 @Inject
-@RegistryType(type="motorguide")
+@RegistryScope(scope="motorguide")
 MetricRegistry motorGuideRegistry;
 ----