This is an automated email from the ASF dual-hosted git repository.
dblevins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomee.git
The following commit(s) were added to refs/heads/master by this push:
new a5cd434 [TOMEE-2681] Translate MicroProfile Metrics Metered Example
to Spanish
new 824c6e0 Merge pull request #572 from cchacin/TOMEE-2681
a5cd434 is described below
commit a5cd434658dc25fa1417263029e83a41f0c6d9fb
Author: Carlos Chacin <[email protected]>
AuthorDate: Fri Sep 13 02:35:35 2019 -0700
[TOMEE-2681] Translate MicroProfile Metrics Metered Example to Spanish
---
examples/mp-metrics-metered/README.adoc | 177 ++++++++++++++++++-----------
examples/mp-metrics-metered/README_es.adoc | 174 ++++++++++++++++++++++++++++
2 files changed, 282 insertions(+), 69 deletions(-)
diff --git a/examples/mp-metrics-metered/README.adoc
b/examples/mp-metrics-metered/README.adoc
index 3c96c5a..4b4b1c7 100644
--- a/examples/mp-metrics-metered/README.adoc
+++ b/examples/mp-metrics-metered/README.adoc
@@ -7,48 +7,67 @@ This is an example on how to use microprofile metrics in
TomEE.
== Run the application:
- mvn clean install tomee:run
+[source,bash]
+----
+$ mvn clean install tomee:run
+----
-Within the application, there is an enpoint that will give you a weather
weather status for the day and week.
+Within the application, there is an enpoint that will give you a weather status
+for the day and week.
== For the day status call:
- GET http://localhost:8080/mp-metrics-metered/weather/day/status
-
+[source,bash]
+----
+$ curl -X GET http://localhost:8080/mp-metrics-metered/weather/day/status
+----
+
== Response:
- Hi, today is a sunny day!
+[source,text]
+----
+Hi, today is a sunny day!
+----
== Metered Feature
-MicroProfile metrics has a feature that can be used to find the rate of
requests to a service.
+MicroProfile metrics has a feature that can be used to find the rate of
+requests to a service.
+
+To use this feature you need to annotate the JAX-RS resource method with
+`@Metered`.
-To use this feature you need to annotate the JAX-RS resource method with
@Metered.
[source,java]
----
-
- @Path("/weather")
- @Produces(MediaType.APPLICATION_JSON)
- @Consumes(MediaType.APPLICATION_JSON)
- @ApplicationScoped
- public class WeatherService {
-
- @Path("/day/status")
- @Metered(name = "dailyStatus", unit = MetricUnits.MINUTES, description
= "Metrics to daily weather status method", absolute = true)
- @GET
- @Produces(MediaType.TEXT_PLAIN)
- public String dayStatus() {
- return "Hi, today is a sunny day!";
- }
- ...
+@Path("/weather")
+@Produces(MediaType.APPLICATION_JSON)
+@Consumes(MediaType.APPLICATION_JSON)
+@ApplicationScoped
+public class WeatherService {
+
+ @Path("/day/status")
+ @Metered(name = "dailyStatus",
+ unit = MetricUnits.MINUTES,
+ description = "Metrics to daily weather status method",
+ absolute = true)
+ @GET
+ @Produces(MediaType.TEXT_PLAIN)
+ public String dayStatus() {
+ return "Hi, today is a sunny day!";
}
+...
+}
----
-There are some configurations, as part of @Metered, that you need to know:
+
+There are some configurations, as part of `@Metered`, that you need to know:
**String name**
-Optional. Sets the name of the metric. If not explicitly given the name of the
annotated object is used.
+Optional. Sets the name of the metric. If not explicitly given the name of the
+annotated object is used.
**boolean absolute**
-If true, uses the given name as the absolute name of the metric. If false,
prepends the package name and class name before the given name. Default value
is false.
+If true, uses the given name as the 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.
@@ -57,13 +76,15 @@ Optional. A human-readable display name for metadata.
Optional. A description of the metric.
**String[] tags**
-Optional. Array of Strings in the <key>=<value> format to supply special tags
to a metric.
+Optional. Array of Strings in the <key>=<value> format to supply special tags
+to a metric.
**boolean reusable**
-Denotes if a metric with a certain name can be registered in more than one
place. Does not apply to gauges.
+Denotes if a metric with a certain name can be registered in more than one
+place. Does not apply to gauges.
**String unit**
-Unit of the metric. Default for @Metered is nanoseconds.
+Unit of the metric. Default for `@Metered` is nanoseconds.
== Metric data
@@ -71,62 +92,80 @@ Check the Metered metric doing a _GET_ request:
== Prometheus format:
- GET
http://localhost:8080/mp-metrics-metered/metrics/application/dailyStatus
-
+[source,bash]
+----
+$ curl -X GET
http://localhost:8080/mp-metrics-metered/metrics/application/dailyStatus
+----
+
== Response:
-
- # TYPE application:daily_status_seconds_count meter
- application:daily_status_seconds_count 1.2E-7
- # TYPE application:daily_status_rate_per_second meter
- application:daily_status_rate_per_second 0.0
- # TYPE application:daily_status_one_min_rate_per_second meter
- application:daily_status_one_min_rate_per_second 1.3376002644204984E-19
- # TYPE application:daily_status_five_min_rate_per_second meter
- application:daily_status_five_min_rate_per_second 3.5942838529305413E-20
- # TYPE application:daily_status_fifteen_min_rate_per_second meter
- application:daily_status_fifteen_min_rate_per_second
3.4665766454142955E-21
-
-
+
+[source,text]
+----
+# TYPE application:daily_status_seconds_count meter
+application:daily_status_seconds_count 1.2E-7
+# TYPE application:daily_status_rate_per_second meter
+application:daily_status_rate_per_second 0.0
+# TYPE application:daily_status_one_min_rate_per_second meter
+application:daily_status_one_min_rate_per_second 1.3376002644204984E-19
+# TYPE application:daily_status_five_min_rate_per_second meter
+application:daily_status_five_min_rate_per_second 3.5942838529305413E-20
+# TYPE application:daily_status_fifteen_min_rate_per_second meter
+application:daily_status_fifteen_min_rate_per_second 3.4665766454142955E-21
+----
+
== JSON Format:
-For json format add the header _Accept=application/json_ to the request.
-
- {
- "dailyStatus": {
- "count": 2,
- "fifteenMinRate": 5.77762774235716e-14,
- "fiveMinRate": 5.990473088217569e-13,
- "meanRate": 0,
- "oneMinRate": 2.229333774034164e-12,
- "unit": "minutes"
- }
+For json format add the header `Accept: application/json` to the request.
+
+[source,javascript]
+----
+{
+ "dailyStatus": {
+ "count": 2,
+ "fifteenMinRate": 5.77762774235716e-14,
+ "fiveMinRate": 5.990473088217569e-13,
+ "meanRate": 0,
+ "oneMinRate": 2.229333774034164e-12,
+ "unit": "minutes"
}
-
+}
+----
+
== Metric metadata
-A metric will have a metadata so you can know more information about it, like
displayName, description, tags etc.
+
+A metric will have a metadata so you can know more information about it, like
`displayName`, `description`, `tags`, etc.
Check the metric metadata doing a _OPTIONS_ request:
== Request
- OPTIONS
http://localhost:8080/mp-metrics-metered/metrics/application/dailyStatus
+[source,bash]
+----
+$ curl -X OPTIONS
http://localhost:8080/mp-metrics-metered/metrics/application/dailyStatus
+----
== Response:
- {
- "dailyStatus": {
- "description": "Metrics to daily weather status method",
- "displayName": "",
- "name": "dailyStatus",
- "reusable": false,
- "tags": "",
- "type": "meter",
- "typeRaw": "METERED",
- "unit": "minutes"
- }
+[source,javascript]
+----
+{
+ "dailyStatus": {
+ "description": "Metrics to daily weather status method",
+ "displayName": "",
+ "name": "dailyStatus",
+ "reusable": false,
+ "tags": "",
+ "type": "meter",
+ "typeRaw": "METERED",
+ "unit": "minutes"
}
+}
+----
== Test the application:
- mvn test
+[source,bash]
+----
+$ mvn test
+----
diff --git a/examples/mp-metrics-metered/README_es.adoc
b/examples/mp-metrics-metered/README_es.adoc
new file mode 100644
index 0000000..80a6f03
--- /dev/null
+++ b/examples/mp-metrics-metered/README_es.adoc
@@ -0,0 +1,174 @@
+= Métricas con MicroProfile `@Metered`
+:index-group: MicroProfile
+:jbake-type: page
+:jbake-status: published
+
+Este es un ejemplo sobre cómo utilizar las métricas de microperfil en TomEE.
+
+== Ejecute la aplicación:
+
+[source,bash]
+----
+$ mvn clean install tomee:run
+----
+
+Dentro de la aplicación, hay un endpoint que te dará el estado del clima para
+el día y la semana.
+
+== Obtenga el clima para la semana:
+
+[source,bash]
+----
+$ curl -X GET http://localhost:8080/mp-metrics-metered/weather/day/status
+----
+
+== Response:
+
+[source,text]
+----
+Hi, today is a sunny day!
+----
+
+== Usando `@Metered`
+
+Las métricas de MicroProfile tienen una función que se puede usar para medir
+solicitudes a un servicio.
+
+Para utilizar esta función, debe anotar los métodos de los recursos JAX-RS con
+`@Metered`.
+
+[source,java]
+----
+@Path("/weather")
+@Produces(MediaType.APPLICATION_JSON)
+@Consumes(MediaType.APPLICATION_JSON)
+@ApplicationScoped
+public class WeatherService {
+
+ @Path("/day/status")
+ @Metered(name = "dailyStatus",
+ unit = MetricUnits.MINUTES,
+ description = "Metrics to daily weather status method",
+ absolute = true)
+ @GET
+ @Produces(MediaType.TEXT_PLAIN)
+ public String dayStatus() {
+ return "Hi, today is a sunny day!";
+ }
+...
+}
+----
+
+Hay algunas configuraciones, como parte de `@Metered`, que necesita saber:
+
+**String name**
+Opcional. Establece el nombre de la métrica. Si no se proporciona
+explícitamente, se utiliza el nombre del objeto anotado.
+
+*boolean absolute* Si es verdadero, usa el nombre dado como el nombre absoluto
+de la métrica. Si es falso, antepone el nombre del paquete y el nombre de la
+clase antes del nombre dado. El valor predeterminado es falso.
+
+**String displayName**
+Opcional. Un nombre para mostrar legible para los metadatos.
+
+**String description**
+Opcional. Una descripción de la métrica.
+
+**String[] tags**
+Opcional. Matriz de cadenas en el formato <key>=<value> para suministrar
+etiquetas especiales a una métrica.
+
+**boolean reusable**
+Indica si una métrica con un nombre determinado se puede registrar en más de un
+lugar. No se aplica a `@Gauges` (medidores).
+
+**String unit**
+Unidad de la métrica. El valor predeterminado para `@Metered` es nanosegundos.
+
+== Datos de la Métrica
+
+Verifique la métrica `@Metered` haciendo una solicitud _GET_:
+
+== Formato Prometheus:
+
+[source,bash]
+----
+$ curl -X GET
http://localhost:8080/mp-metrics-metered/metrics/application/dailyStatus
+----
+
+== Respuesta Prometheus:
+
+[source,text]
+----
+# TYPE application:daily_status_seconds_count meter
+application:daily_status_seconds_count 1.2E-7
+# TYPE application:daily_status_rate_per_second meter
+application:daily_status_rate_per_second 0.0
+# TYPE application:daily_status_one_min_rate_per_second meter
+application:daily_status_one_min_rate_per_second 1.3376002644204984E-19
+# TYPE application:daily_status_five_min_rate_per_second meter
+application:daily_status_five_min_rate_per_second 3.5942838529305413E-20
+# TYPE application:daily_status_fifteen_min_rate_per_second meter
+application:daily_status_fifteen_min_rate_per_second 3.4665766454142955E-21
+----
+
+== Formato JSON:
+
+Para el formato json, agregue el encabezado `Accept: application/json` a la
+solicitud HTTP.
+
+== Respuesta JSON
+
+[source,javascript]
+----
+{
+ "dailyStatus": {
+ "count": 2,
+ "fifteenMinRate": 5.77762774235716e-14,
+ "fiveMinRate": 5.990473088217569e-13,
+ "meanRate": 0,
+ "oneMinRate": 2.229333774034164e-12,
+ "unit": "minutes"
+ }
+}
+----
+
+== Metadatos Métrica
+
+Una métrica tendrá metadatos para que pueda conocer más información al
+respecto, como `displayName`,`description`, `tags`, etc.
+
+Verifique los metadatos de la métrica haciendo una solicitud HTTP _OPTIONS_:
+
+== Solicitud HTTP _OPTIONS_
+
+[source,bash]
+----
+$ curl -X OPTIONS
http://localhost:8080/mp-metrics-metered/metrics/application/dailyStatus
+----
+
+== Respuesta:
+
+[source,javascript]
+----
+{
+ "dailyStatus": {
+ "description": "Metrics to daily weather status method",
+ "displayName": "",
+ "name": "dailyStatus",
+ "reusable": false,
+ "tags": "",
+ "type": "meter",
+ "typeRaw": "METERED",
+ "unit": "minutes"
+ }
+}
+----
+
+== Pruebe la aplicación:
+
+[source,bash]
+----
+$ mvn test
+----