Skip to content

Commit

Permalink
Merge pull request #3 from raymondlam/changeMetricUnits
Browse files Browse the repository at this point in the history
Changing MetricUnit to MetricUnits

Signed-off-by: Fahham Khan <fahhamk@ca.ibm.com>
  • Loading branch information
fahhamk committed Sep 8, 2017
2 parents b7f6b8d + 4f6f2d3 commit 5732a33
Show file tree
Hide file tree
Showing 16 changed files with 49 additions and 49 deletions.
10 changes: 5 additions & 5 deletions api/src/main/java/org/eclipse/microprofile/metrics/Metadata.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
* </li>
* <li>
* {@code Unit}: (Optional) The unit of the metric.
* The unit may be any unit specified as a String or one specified in {@link MetricUnit}.
* The unit may be any unit specified as a String or one specified in {@link MetricUnits}.
* </li>
* <li>
* {@code Tags}: (Optional) The tags (represented by key/value pairs) of the metric which is augmented by global tags (if available).
Expand Down Expand Up @@ -102,7 +102,7 @@ public class Metadata {
* An optional field which holds the Unit of the metric object.
* </p>
*/
private String unit = MetricUnit.NONE;
private String unit = MetricUnits.NONE;

/**
* Tags of the metric. Augmented by global tags.
Expand Down Expand Up @@ -143,16 +143,16 @@ public Metadata(String name, MetricType type) {
// Assign default units
switch (type) {
case TIMER:
this.unit = MetricUnit.NANOSECONDS;
this.unit = MetricUnits.NANOSECONDS;
break;
case METERED:
this.unit = MetricUnit.PER_SECOND;
this.unit = MetricUnits.PER_SECOND;
break;
case HISTOGRAM:
case GAUGE:
case COUNTER:
default:
this.unit = MetricUnit.NONE;
this.unit = MetricUnits.NONE;
break;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
*
* @author hrupp
*/
public final class MetricUnit {
public final class MetricUnits {
/** No unit */
public static final String NONE = "none";

Expand Down Expand Up @@ -81,5 +81,5 @@ public final class MetricUnit {
public static final String PER_SECOND = "per_second";


private MetricUnit() {}
private MetricUnits() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import javax.enterprise.util.Nonbinding;
import javax.interceptor.InterceptorBinding;

import org.eclipse.microprofile.metrics.MetricUnit;
import org.eclipse.microprofile.metrics.MetricUnits;

/**
* An annotation for marking a method, constructor, or class as counted.
Expand Down Expand Up @@ -123,12 +123,12 @@


/**
* @return The unit of the counter. By default, the value is {@link MetricUnit#NONE}.
* @return The unit of the counter. By default, the value is {@link MetricUnits#NONE}.
*
* @see org.eclipse.microprofile.metrics.Metadata
* @see org.eclipse.microprofile.metrics.MetricUnit
* @see org.eclipse.microprofile.metrics.MetricUnits
*/
@Nonbinding
String unit() default MetricUnit.NONE;
String unit() default MetricUnits.NONE;

}
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
* @return (Required) The unit of the gauge.
*
* @see org.eclipse.microprofile.metrics.Metadata
* @see org.eclipse.microprofile.metrics.MetricUnit
* @see org.eclipse.microprofile.metrics.MetricUnits
*/
@Nonbinding
String unit();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import javax.enterprise.util.Nonbinding;
import javax.interceptor.InterceptorBinding;

import org.eclipse.microprofile.metrics.MetricUnit;
import org.eclipse.microprofile.metrics.MetricUnits;

/**
* An annotation for marking a method, constructor, or class as metered.
Expand Down Expand Up @@ -109,12 +109,12 @@
String description() default "";

/**
* @return The unit of the meter. By default, the value is {@link MetricUnit#PER_SECOND}.
* @return The unit of the meter. By default, the value is {@link MetricUnits#PER_SECOND}.
*
* @see org.eclipse.microprofile.metrics.Metadata
* @see org.eclipse.microprofile.metrics.MetricUnit
* @see org.eclipse.microprofile.metrics.MetricUnits
*/
@Nonbinding
String unit() default MetricUnit.PER_SECOND;
String unit() default MetricUnits.PER_SECOND;

}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import javax.enterprise.util.Nonbinding;
import javax.interceptor.InterceptorBinding;

import org.eclipse.microprofile.metrics.MetricUnit;
import org.eclipse.microprofile.metrics.MetricUnits;

/**
* An annotation requesting that a metric be injected or registered.
Expand Down Expand Up @@ -105,12 +105,12 @@
String description() default "";

/**
* @return The unit of the metric. By default, the value is {@link MetricUnit#NONE}.
* @return The unit of the metric. By default, the value is {@link MetricUnits#NONE}.
*
* @see org.eclipse.microprofile.metrics.Metadata
* @see org.eclipse.microprofile.metrics.MetricUnit
* @see org.eclipse.microprofile.metrics.MetricUnits
*/
@Nonbinding
String unit() default MetricUnit.NONE;
String unit() default MetricUnits.NONE;

}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import javax.enterprise.util.Nonbinding;
import javax.interceptor.InterceptorBinding;

import org.eclipse.microprofile.metrics.MetricUnit;
import org.eclipse.microprofile.metrics.MetricUnits;

/**
* An annotation for marking a method, constructor, or class as timed.
Expand Down Expand Up @@ -108,12 +108,12 @@
String description() default "";

/**
* @return The unit of the timer. By default, the value is {@link MetricUnit#NANOSECONDS}.
* @return The unit of the timer. By default, the value is {@link MetricUnits#NANOSECONDS}.
*
* @see org.eclipse.microprofile.metrics.Metadata
* @see org.eclipse.microprofile.metrics.MetricUnit
* @see org.eclipse.microprofile.metrics.MetricUnits
*/
@Nonbinding
String unit() default MetricUnit.NANOSECONDS;
String unit() default MetricUnits.NANOSECONDS;

}
18 changes: 9 additions & 9 deletions spec/src/main/asciidoc/metrics_spec.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -1005,7 +1005,7 @@ In order to make setting the values easier, Annotations are made available.
.Example set-up of two Gauge metrics
[source,java]
----
@Gauge(unit = MetricUnit.MEGABYTES) <1>
@Gauge(unit = MetricUnits.MEGABYTES) <1>
int diskUsage;
@Gauge(name = "queueSize") <2>
Expand All @@ -1014,7 +1014,7 @@ public int getQueueSize() {
}
----
<1> The metric is of type Gauge and the values are in Megabytes
<2> No unit is given, so `MetricUnit.NONE` is used, an explicit name is provided
<2> No unit is given, so `MetricUnits.NONE` is used, an explicit name is provided

NOTE: The programming API follows Dropwizard Metrics 3.2.3 API, but with local changes.
It is expected that many existing DropWizard Metrics based applications can easily be
Expand Down Expand Up @@ -1078,12 +1078,12 @@ The following Annotations exist, see below for common fields:
|===
|Annotation | Applies to | Description | Default Unit

|@Counted | M, C, T | Denotes a counter, which counts the invocations of the annotated object. | MetricUnit.NONE
|@Counted | M, C, T | Denotes a counter, which counts the invocations of the annotated object. | MetricUnits.NONE
|@Gauge | M, F | Denotes a gauge, which samples the value of the annotated object. | _none_ Must be supplied by the user
|@Metered | M, C, T | Denotes a meter, which tracks the frequency of invocations of the annotated object. | MetricUnit.PER_SECOND
|@Metered | M, C, T | Denotes a meter, which tracks the frequency of invocations of the annotated object. | MetricUnits.PER_SECOND
|@Metric | M, F, P | An annotation requesting that a metric should be injected. This annotation can be used on the fields
of type `Meter`, `Timer`, `Counter`, and `Histogram`. | MetricUnit.NONE
|@Timed | M, C, T | Denotes a timer, which tracks duration of the annotated object. | MetricUnit.NANOSECONDS
of type `Meter`, `Timer`, `Counter`, and `Histogram`. | MetricUnits.NONE
|@Timed | M, C, T | Denotes a timer, which tracks duration of the annotated object. | MetricUnits.NANOSECONDS
|===
(C=Constructor, F=Field, M=Method, P=Parameter, T=Type)

Expand All @@ -1104,7 +1104,7 @@ in <<meta-data-def>>.
`boolean absolute`:: If `true`, uses the given name as an absolute name of the metric. If `false`, prepends the package name and class name before the given name. Default value is `false`.
`String displayName`:: Optional. A human readable display name for metadata.
`String description`:: Optional. A description of the metric.
`MetricUnit unit`:: Unit of the metric. For `@Gauge` no default is provided.
`MetricUnits unit`:: Unit of the metric. For `@Gauge` no default is provided.
`String[] tags`:: Optional. Array of Strings in the `<key>=<value>` format to supply special tags to a metric.

NOTE: Implementors are encouraged to issue warnings in the server log if metadata is missing. Implementors
Expand Down Expand Up @@ -1511,7 +1511,7 @@ public class Metadata {
/**
* Unit of the metric.
*/
private String unit = MetricUnit.NONE;
private String unit = MetricUnits.NONE;
/**
* Tags of the metric. Augmented by global tags.
Expand Down Expand Up @@ -1594,7 +1594,7 @@ public enum MetricType {

[source, java]
----
public final class MetricUnit {
public final class MetricUnits {
/** No unit */
public static final String NONE = "none";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
package io.astefanutti.metrics.cdi.se;

import org.eclipse.microprofile.metrics.MetricUnit;
import org.eclipse.microprofile.metrics.MetricUnits;
import org.eclipse.microprofile.metrics.annotation.Gauge;

import javax.enterprise.context.ApplicationScoped;
Expand All @@ -25,7 +25,7 @@ public class GaugeInjectionBean {

private long gauge;

@Gauge(name = "gaugeInjection", unit=MetricUnit.NONE)
@Gauge(name = "gaugeInjection", unit=MetricUnits.NONE)
public long getGauge() {
return gauge;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
package io.astefanutti.metrics.cdi.se;

import org.eclipse.microprofile.metrics.MetricUnit;
import org.eclipse.microprofile.metrics.MetricUnits;
import org.eclipse.microprofile.metrics.annotation.Gauge;

import javax.enterprise.context.ApplicationScoped;
Expand All @@ -25,7 +25,7 @@ public class GaugeMethodBean {

private long gauge;

@Gauge(name = "gaugeMethod", unit=MetricUnit.NONE)
@Gauge(name = "gaugeMethod", unit=MetricUnits.NONE)
public long getGauge() {
return gauge;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
package io.astefanutti.metrics.cdi.se;

import org.eclipse.microprofile.metrics.MetricUnit;
import org.eclipse.microprofile.metrics.MetricUnits;
import org.eclipse.microprofile.metrics.annotation.Gauge;

import javax.enterprise.context.ApplicationScoped;
Expand All @@ -25,7 +25,7 @@ public class InheritedChildGaugeMethodBean {

private long childGauge;

@Gauge(name = "inheritedChildGaugeMethod", unit=MetricUnit.NONE)
@Gauge(name = "inheritedChildGaugeMethod", unit=MetricUnits.NONE)
public long getChildGauge() {
return childGauge;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
package io.astefanutti.metrics.cdi.se;

import org.eclipse.microprofile.metrics.MetricUnit;
import org.eclipse.microprofile.metrics.MetricUnits;
import org.eclipse.microprofile.metrics.annotation.Gauge;

import javax.enterprise.context.ApplicationScoped;
Expand All @@ -26,7 +26,7 @@ public class InheritedGaugeMethodBean extends GaugeMethodBean {

private long childGauge;

@Gauge(name = "childGaugeMethod", unit=MetricUnit.NONE)
@Gauge(name = "childGaugeMethod", unit=MetricUnits.NONE)
public long getChildGauge() {
return childGauge;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
package io.astefanutti.metrics.cdi.se;

import org.eclipse.microprofile.metrics.MetricUnit;
import org.eclipse.microprofile.metrics.MetricUnits;
import org.eclipse.microprofile.metrics.annotation.Gauge;

import javax.enterprise.context.ApplicationScoped;
Expand All @@ -25,7 +25,7 @@ public class InheritedParentGaugeMethodBean {

private long gauge;

@Gauge(name = "inheritedParentGaugeMethod", unit=MetricUnit.NONE)
@Gauge(name = "inheritedParentGaugeMethod", unit=MetricUnits.NONE)
public long getGauge() {
return gauge;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
package io.astefanutti.metrics.cdi.se;

import org.eclipse.microprofile.metrics.MetricUnit;
import org.eclipse.microprofile.metrics.MetricUnits;
import org.eclipse.microprofile.metrics.annotation.Counted;
import org.eclipse.microprofile.metrics.annotation.Gauge;
import org.eclipse.microprofile.metrics.annotation.Metered;
Expand All @@ -27,7 +27,7 @@
public class MultipleMetricsMethodBean {

@Counted(name = "counter", monotonic = true)
@Gauge(name = "gauge", unit=MetricUnit.NONE)
@Gauge(name = "gauge", unit=MetricUnits.NONE)
@Metered(name = "meter")
@Timed(name = "timer")
public String metricsMethod() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import org.eclipse.microprofile.metrics.Counter;
import org.eclipse.microprofile.metrics.Metadata;
import org.eclipse.microprofile.metrics.MetricType;
import org.eclipse.microprofile.metrics.MetricUnit;
import org.eclipse.microprofile.metrics.MetricUnits;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.shrinkwrap.api.ShrinkWrap;
Expand All @@ -43,7 +43,7 @@ public class TagsTest {
@Inject
Counter count;

Metadata metadata = new Metadata("count", "countMe", "countMe tags test", MetricType.COUNTER, MetricUnit.PERCENT, "colour=blue");
Metadata metadata = new Metadata("count", "countMe", "countMe tags test", MetricType.COUNTER, MetricUnits.PERCENT, "colour=blue");

@Deployment
public static JavaArchive createDeployment() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import org.eclipse.microprofile.metrics.Histogram;
import org.eclipse.microprofile.metrics.Meter;
import org.eclipse.microprofile.metrics.MetricRegistry;
import org.eclipse.microprofile.metrics.MetricUnit;
import org.eclipse.microprofile.metrics.MetricUnits;
import org.eclipse.microprofile.metrics.Timer;
import org.eclipse.microprofile.metrics.annotation.Counted;
import org.eclipse.microprofile.metrics.annotation.Metered;
Expand Down Expand Up @@ -82,7 +82,7 @@ public void gaugeMe() {

}

@org.eclipse.microprofile.metrics.annotation.Gauge(unit=MetricUnit.KIBIBITS)
@org.eclipse.microprofile.metrics.annotation.Gauge(unit=MetricUnits.KIBIBITS)
public long gaugeMeA() {
return 1000L;
}
Expand Down

0 comments on commit 5732a33

Please sign in to comment.