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 161322e [TOMEE-2669] [Translation] mp-metrics-counted example to
Spanish
new d87a796 Merge pull request #563 from cchacin/TOMEE-2673-3
161322e is described below
commit 161322ece054b25269ccaddac1734af2b8232835
Author: Carlos Chacin <[email protected]>
AuthorDate: Mon Sep 9 00:47:33 2019 -0700
[TOMEE-2669] [Translation] mp-metrics-counted example to Spanish
---
examples/mp-metrics-counted/README.adoc | 136 ++++++++++++---------
examples/mp-metrics-counted/README_es.adoc | 188 +++++++++++++++++++++++++++++
2 files changed, 265 insertions(+), 59 deletions(-)
diff --git a/examples/mp-metrics-counted/README.adoc
b/examples/mp-metrics-counted/README.adoc
index 2429ee3..a38369c 100644
--- a/examples/mp-metrics-counted/README.adoc
+++ b/examples/mp-metrics-counted/README.adoc
@@ -3,44 +3,51 @@
:jbake-type: page
:jbake-status: published
-This is an example on how to use microprofile metrics in TomEE. The project
includes a docker profile which can be used to create a Docker image.
+This is an example of how to use microprofile metrics in TomEE. The project
+includes a docker profile which can be used to create a Docker image.
== Run the application:
-....
-mvn clean install tomee:run
-....
+[source,bash]
+----
+$ mvn clean install tomee:run
+----
-== Alternatively build and run the application via Docker (note the use of the
docker profile):
+NOTE: Alternatively, build and run the application via Docker (note the use of
the docker profile):
-....
-mvn -Pdocker docker:build
-docker run -it --rm \
- -p 8080:8080 \
- --name=tomee-mp-metrics-counted \
- tomee/mp-metrics-counted
-....
+[source,bash]
+----
+$ mvn -Pdocker docker:build
+----
-Within the application there is an endpoint that will give you weather
+[source,bash]
+----
+$ docker run -it --rm -p 8080:8080 --name=tomee-mp-metrics-counted
tomee/mp-metrics-counted
+----
+
+Within the application, there is an endpoint that will give you weather
status for the day and week.
-== For the day status call:
+== Get the weather for the week:
-....
-GET http://localhost:8080/mp-metrics-counted/weather/week/status
-....
+[source,bash]
+----
+$ curl -X GET http://localhost:8080/mp-metrics-counted/weather/week/status
+----
-== If running via Docker, because the application is installed as the ROOT
application, remove the application name such as:
+IMPORTANT: If running via Docker, because the application is installed as the
ROOT application, remove the application name from the URL:
-....
-GET http://localhost:8080/weather/week/status
-....
+[source,bash]
+----
+$ curl -X GET http://localhost:8080/weather/week/status
+----
== Response:
-....
+[source,text]
+----
Hi, today is a sunny day!
-....
+----
== Counted Feature
@@ -48,9 +55,10 @@ MicroProfile metrics has a feature that can be used to count
requests to
a service.
To use this feature you need to annotate the JAX-RS resource method with
-@Counted.
+`@Counted`.
-....
+[source,java]
+----
@Path("/weather")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
@@ -66,28 +74,26 @@ public class WeatherService {
}
...
}
-....
+----
-There are some configurations, as part of @Counted, that you need to
-know:
+There are some configurations, as part of `@Counted`, 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.
+*String name* 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.
+*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.
-*String displayName* Optional. A human-readable display name for
-metadata.
+*String displayName* Optional. A human-readable display name for metadata.
*String description* Optional. A description of the metric.
-*String[] tags* Optional. Array of Strings in the = format to supply
-special tags to a metric.
+*String[] tags* Optional. Array of Strings in the = 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.
+*boolean reusable* Denotes if a metric with a certain name can be registered in
+more than one place. Does not apply to `@Gauge`.
== Metric data
@@ -95,22 +101,32 @@ Check the counter metric doing a _GET_ request:
=== Prometheus format:
-....
-GET
http://localhost:8080/mp-metrics-counted/metrics/application/weather_day_status
-....
+[source,bash]
+----
+$ curl -X GET
http://localhost:8080/mp-metrics-counted/metrics/application/weather_day_status
+----
-=== Response:
+=== Prometheus Response:
-....
+[source,text]
+----
# TYPE application:weather_day_status counter
application:weather_day_status 1.0
-....
+----
=== JSON Format:
-For json format add the header _Accept=application/json_ to the request.
+For json format add the header `Accept: application/json` to the HTTP request.
+
+[source,bash]
+----
+$ curl -X GET -H "Accept: application/json"
http://localhost:8080/mp-metrics-counted/metrics/application/weather_day_status
+----
+
+=== JSON Response:
-....
+[source,javascript]
+----
{
"weather_day_status": {
"delegate": {},
@@ -118,24 +134,26 @@ For json format add the header _Accept=application/json_
to the request.
"count": 1
}
}
-....
+----
== Metric metadata
-A metric will have a metadata so you can know more information about it,
-like displayName, description, tags e etc.
+A metric will have metadata so you can know more information about it,
+like `displayName`, `description`, `tags`, etc.
-Check the metric metadata doing a _OPTIONS_ request:
+Check the metric metadata doing a _OPTIONS_ HTTP request:
-=== Request
+=== _OPTIONS_ HTTP Request
-....
-OPTIONS
http://localhost:8080/mp-metrics-counted/metrics/application/weather_day_status
-....
+[source,bash]
+----
+$ curl -X OPTIONS
http://localhost:8080/mp-metrics-counted/metrics/application/weather_day_status
+----
=== Response:
-....
+[source,javascript]
+----
{
"weather_day_status": {
"unit": "none",
@@ -159,7 +177,7 @@ OPTIONS
http://localhost:8080/mp-metrics-counted/metrics/application/weather_day
"tags": ""
}
}
-....
+----
-You can also try it out using the WeatherServiceTest.java available in
-the project.
+You can also try it out using the WeatherServiceTest.java available in the
+project.
diff --git a/examples/mp-metrics-counted/README_es.adoc
b/examples/mp-metrics-counted/README_es.adoc
new file mode 100644
index 0000000..15e016a
--- /dev/null
+++ b/examples/mp-metrics-counted/README_es.adoc
@@ -0,0 +1,188 @@
+= Métricas con MicroProfile `@Counted` (Contado)
+:index-group: MicroProfile
+:jbake-type: page
+:jbake-status: published
+
+Este es un ejemplo sobre cómo utilizar las métricas de microperfil en TomEE. El
+proyecto incluye un perfil de Docker que se puede usar para crear una imagen de
+Docker.
+
+== Ejecute la aplicación:
+
+[source,bash]
+----
+$ mvn clean install tomee:run
+----
+
+NOTE: AAlternativamente, compile y ejecute la aplicación a través de Docker
+(tenga en cuenta el uso del perfil de docker):
+
+[source,bash]
+----
+$ mvn -Pdocker docker:build
+----
+
+[source,bash]
+----
+$ docker run -it --rm -p 8080:8080 --name=tomee-mp-metrics-counted
tomee/mp-metrics-counted
+----
+
+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-counted/weather/week/status
+----
+
+IMPORTANT: Si ejecuta usando Docker, debido a que la aplicación está instalada
+como la aplicación ROOT, elimine el nombre de la aplicación de la URL:
+
+[source,bash]
+----
+$ curl -X GET http://localhost:8080/weather/week/status
+----
+
+== Response:
+
+[source,text]
+----
+Hi, today is a sunny day!
+----
+
+== Usando `@Counted`
+
+Las métricas de MicroProfile tienen una función que se puede usar para contar
+solicitudes a un servicio.
+
+Para utilizar esta función, debe anotar los métodos de los recursos JAX-RS con
+`@Counted`.
+
+[source,java]
+----
+@Path("/weather")
+@Produces(MediaType.APPLICATION_JSON)
+@Consumes(MediaType.APPLICATION_JSON)
+@ApplicationScoped
+public class WeatherService {
+
+ @Path("/day/status")
+ @Counted(monotonic = true, name = "weather_day_status", absolute = true)
+ @GET
+ @Produces(MediaType.TEXT_PLAIN)
+ public String dayStatus() {
+ return "Hi, today is a sunny day!";
+ }
+...
+}
+----
+
+Hay algunas configuraciones, como parte de `@Counted`, 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 = 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).
+
+== Datos de la Métrica
+
+Verifique la métrica del contador haciendo una solicitud _GET_:
+
+=== Formato Prometheus:
+
+[source,bash]
+----
+$ curl -X GET
http://localhost:8080/mp-metrics-counted/metrics/application/weather_day_status
+----
+
+=== Respuesta Prometheus:
+
+[source,text]
+----
+# TYPE application:weather_day_status counter
+application:weather_day_status 1.0
+----
+
+=== Formato JSON:
+
+Para el formato json, agregue el encabezado `Accept: application/json` a la
+solicitud HTTP.
+
+[source,bash]
+----
+$ curl -X GET -H "Accept: application/json"
http://localhost:8080/mp-metrics-counted/metrics/application/weather_day_status
+----
+
+=== Respuesta JSON:
+
+[source,javascript]
+----
+{
+ "weather_day_status": {
+ "delegate": {},
+ "unit": "none",
+ "count": 1
+ }
+}
+----
+
+== 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-counted/metrics/application/weather_day_status
+----
+
+=== Respuesta:
+
+[source,javascript]
+----
+{
+ "weather_day_status": {
+ "unit": "none",
+ "displayName": "Weather Day Status",
+ "name": "weather_day_status",
+ "typeRaw": "COUNTER",
+ "description": "This metric shows the weather status of the day.",
+ "type": "counter",
+ "value": {
+ "unit": "none",
+ "displayName": "Weather Day Status",
+ "name": "weather_day_status",
+ "tagsAsString": "",
+ "typeRaw": "COUNTER",
+ "description": "This metric shows the weather status of the day.",
+ "type": "counter",
+ "reusable": false,
+ "tags": {}
+ },
+ "reusable": false,
+ "tags": ""
+ }
+}
+----
+
+También puede probarlo utilizando WeatherServiceTest.java disponible en el
+proyecto.