Skip to content

Commit

Permalink
Merge pull request #113 from fahhamk/addingAPITCK
Browse files Browse the repository at this point in the history
Adding the TCK
  • Loading branch information
mikecroft committed Sep 10, 2017
2 parents 309fc44 + 5732a33 commit 5323d51
Show file tree
Hide file tree
Showing 90 changed files with 6,306 additions and 691 deletions.
10 changes: 5 additions & 5 deletions api/src/main/java/org/eclipse/microprofile/metrics/Metadata.java
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
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() {}
}
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;

}
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
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;

}
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;

}
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;

}
1 change: 1 addition & 0 deletions pom.xml
Expand Up @@ -76,6 +76,7 @@
<module>api</module>
<module>spec</module>
<module>tck/rest</module>
<module>tck/api</module>
</modules>

<dependencyManagement>
Expand Down
18 changes: 9 additions & 9 deletions spec/src/main/asciidoc/metrics_spec.adoc
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
88 changes: 88 additions & 0 deletions tck/api/pom.xml
@@ -0,0 +1,88 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- 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. -->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>org.eclipse.microprofile.metrics</groupId>
<artifactId>microprofile-metrics-api-tck</artifactId>
<version>1.0-SNAPSHOT</version>
<name>MicroProfile Metrics API-TCK</name>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.17</version>
</plugin>
</plugins>
</build>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jboss.arquillian</groupId>
<artifactId>arquillian-bom</artifactId>
<version>1.1.8.Final</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<!-- mp-metrics dependencies: -->
<dependency>
<groupId>org.eclipse.microprofile.metrics</groupId>
<artifactId>microprofile-metrics-api</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.enterprise</groupId>
<artifactId>cdi-api</artifactId>
<version>1.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-integration</artifactId>
<version>1.2.1</version>
</dependency>

<!-- Arquillian dependencies -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.junit</groupId>
<artifactId>arquillian-junit-container</artifactId>
<scope>compile</scope>
</dependency>

<!-- Container adapters: -->
<dependency>
<groupId>org.jboss.arquillian.container</groupId>
<artifactId>arquillian-wlp-managed-8.5</artifactId>
<version>1.0.0.Beta2</version>
</dependency>

</dependencies>
</project>
@@ -0,0 +1,23 @@
/**
* Copyright © 2013 Antonin Stefanutti (antonin.stefanutti@gmail.com)
*
* 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.astefanutti.metrics.cdi.se;

public abstract class AbstractGenericBean {

public void normallyNotTimedMethod() {
// This should become timed if a concrete implementation class is Timed
}
}
@@ -0,0 +1,25 @@
/**
* Copyright © 2013 Antonin Stefanutti (antonin.stefanutti@gmail.com)
*
* 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.astefanutti.metrics.cdi.se;

import org.eclipse.microprofile.metrics.annotation.Timed;

@Timed
public abstract class AbstractTimedBean {

public void timedMethod() {
}
}

0 comments on commit 5323d51

Please sign in to comment.