Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create MpTelemetry 2.0 Blog #4238

Merged
merged 11 commits into from
Mar 26, 2025

Conversation

yasmin-aumeeruddy
Copy link
Member

For issue #4228

:url-about: /
//Blank line here is necessary before starting the body of the post.

A microservices architecture has many well-known advantages for developers such as scalability, flexibility and improved collaboration. However, having a distributed system is likely to make it harder to find the source of latency or inaccuracy that users may experience. There are multiple ways to increase observability of an application to overcome this problem. For example, by collecting metrics, traces and logs.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
A microservices architecture has many well-known advantages for developers such as scalability, flexibility and improved collaboration. However, having a distributed system is likely to make it harder to find the source of latency or inaccuracy that users may experience. There are multiple ways to increase observability of an application to overcome this problem. For example, by collecting metrics, traces and logs.
A microservices architecture has many well-known advantages for developers such as scalability, flexibility and improved collaboration. However, having a distributed system is likely to make it harder to find the source of latency or inaccuracy that users may experience. There are multiple ways to increase observability of an application to overcome this problem (e.g. by collecting metrics, traces and logs).


A microservices architecture has many well-known advantages for developers such as scalability, flexibility and improved collaboration. However, having a distributed system is likely to make it harder to find the source of latency or inaccuracy that users may experience. There are multiple ways to increase observability of an application to overcome this problem. For example, by collecting metrics, traces and logs.

link:https://opentelemetry.io/[OpenTelemetry] is a set of APIs, SDKs, tooling, and integrations that are designed for the creation and management of telemetry data such as traces, metrics, and logs. link:https://projects.eclipse.org/projects/technology.microprofile/releases/telemetry-2.0[MicroProfile Telemetry 2.0] adopts OpenTelemetry so your MicroProfile applications benefit from both manual and automatic traces and metrics. These can be collectively exported along with runtime and application logs in a standardized way!
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
link:https://opentelemetry.io/[OpenTelemetry] is a set of APIs, SDKs, tooling, and integrations that are designed for the creation and management of telemetry data such as traces, metrics, and logs. link:https://projects.eclipse.org/projects/technology.microprofile/releases/telemetry-2.0[MicroProfile Telemetry 2.0] adopts OpenTelemetry so your MicroProfile applications benefit from both manual and automatic traces and metrics. These can be collectively exported along with runtime and application logs in a standardized way!
link:https://opentelemetry.io/[OpenTelemetry] contains a set of APIs, SDKs, tooling, and integrations that are designed for the creation and management of telemetry data such as traces, metrics, and logs. link:https://projects.eclipse.org/projects/technology.microprofile/releases/telemetry-2.0[MicroProfile Telemetry 2.0] adopts OpenTelemetry so your MicroProfile applications benefit from both manual and automatic traces and metrics. These can be collectively exported along with runtime and application logs in a standardized way!


* *Car service*: Allows users to create records of cars, given the make of the car and the id of the person who owns the car.

image::img/blog/car_person_service.png[align="center",Diagram of an application with a Car and Person service.]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The image is too large.

* *Traces* and *spans* to track user operations, including both the requests and responses.

== Running the backend exporters

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the prior section, you need to explain why you will need a backend exporter.


== Running the backend exporters

Before running this demo, it is recommended to set up a a backend system to collect the telemetry data from the application. See the link:https://github.com/grafana/docker-otel-lgtm[docker-otel-lgtm] repository and clone the repo:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please explain the popular backend exporter.


git clone https://github.com/yasmin-aumeeruddy/car-person-demo.git

Each service has MpTelemetry 2.0 and Monitor-1.0 enabled in its link:https://github.com/yasmin-aumeeruddy/car-person-demo/blob/main/car/src/main/liberty/config/server.xml#L8[server]:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Each service has MpTelemetry 2.0 and Monitor-1.0 enabled in its link:https://github.com/yasmin-aumeeruddy/car-person-demo/blob/main/car/src/main/liberty/config/server.xml#L8[server]:
Each service has `mpTelemetry-2.0` and `monitor-1.0` enabled in its link:https://github.com/yasmin-aumeeruddy/car-person-demo/blob/main/car/src/main/liberty/config/server.xml#L8[server]:

</featureManager>
----

By default, MicroProfile Telemetry is off. To collect and export telemetry data, enable OpenTelemetry by using the following system property or environment variable:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
By default, MicroProfile Telemetry is off. To collect and export telemetry data, enable OpenTelemetry by using the following system property or environment variable:
Due to performance concerns, MicroProfile Telemetry is disabled by default. To collect and export telemetry data, enable OpenTelemetry by using the following system property or environment variable:

@Inject
Meter meter;

@Inject
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

duplication

[source, sh]
----
cd car \
mvn liberty:run
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
mvn liberty:run
mvn liberty:dev

Copy link
Member

@Emily-Jiang Emily-Jiang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logs were not explained


== Running the monitoring backend

Before running this demo, it is recommended to set up a backend system to collect the telemetry data from the application. See the link:https://github.com/grafana/docker-otel-lgtm[docker-otel-lgtm] repository and clone the repo:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Before running this demo, it is recommended to set up a backend system to collect the telemetry data from the application. See the link:https://github.com/grafana/docker-otel-lgtm[docker-otel-lgtm] repository and clone the repo:
The backend system is to collect the telemetry data from the application. See the link:https://github.com/grafana/docker-otel-lgtm[docker-otel-lgtm] repository and clone the repo:

* *Traces* and *spans* to track user operations, including both the requests and responses.

Exporters are systems that send data to a backend service so you can visualise and monitor the spans, metrics and logs.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The following section illustrates how to set up a backend service.


image::img/blog/otel-lgtm-car-person.png[align="center",width=50%,Diagram of the otel lgtm backend exporter with the Car and Person service.]

== Start the demo
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
== Start the demo
== The Demo App


image::img/blog/otel-lgtm-car-person.png[align="center",width=50%,Diagram of the otel lgtm backend exporter with the Car and Person service.]

== Start the demo
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
== Start the demo
== The Demo App

Emily-Jiang
Emily-Jiang previously approved these changes Mar 20, 2025
@yasmin-aumeeruddy yasmin-aumeeruddy changed the base branch from prod to staging March 20, 2025 16:07
@yasmin-aumeeruddy yasmin-aumeeruddy dismissed Emily-Jiang’s stale review March 20, 2025 16:07

The base branch was changed.

Copy link
Member

@dmuelle dmuelle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @yasmin-aumeeruddy - I left a few minor suggestions for clarity.

Also, when domyou want tom publish- need to change the filename to reflect the desired publish date. It's currently targeting a past date of 1/22/25


Check out the demo repo and clone the repository:

git clone https://github.com/yasmin-aumeeruddy/car-person-demo.git
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be in code format, similar to the previous clone command example?


`{"age":21,"id":5859008369859564999,"name":"bob"}`

View the traces that were automatically created from your request in the Grafana link:http://localhost:3000/explore?schemaVersion=1&panes=%7B%22xze%22:%7B%22datasource%22:%22tempo%22,%22queries%22:%5B%7B%22refId%22:%22A%22,%22datasource%22:%7B%22type%22:%22tempo%22,%22uid%22:%22tempo%22%7D,%22queryType%22:%22traceqlSearch%22,%22limit%22:20,%22tableType%22:%22traces%22,%22filters%22:%5B%7B%22id%22:%224d7a67f7%22,%22operator%22:%22%3D%22,%22scope%22:%22span%22%7D%5D%7D%5D,%22range%22:%7B%22from%22:%22now-1h%22,%22to%22:%22now%22%7D%7D%7D&orgId=1[dashboard].
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the grafana dashboard needs some kind of introduction- I assume that if you are running the demo, these links will resolve.

I think the grafana dashboard is provided by the backend you set up in "Running the monitoring backend"? If that's the case, we should clearly state that before the first reference to the dashboard at line 148

Before instrumenting your code, the following prerequisite is required:

• Third-party APIs must be made visible for your application in the link:https://github.com/yasmin-aumeeruddy/car-person-demo/blob/main/car/src/main/liberty/config/server.xml#L18[server.xml]:

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this already set in the demo server/.xml, or does the reader need to make the change? If the latter, we should clearly state that

In addition to the supported runtime metric components, you can also use the OpenTelemetry metrics API to define custom metrics in your application code.
Before instrumenting your code, the following prerequisite is required:

• Third-party APIs must be made visible for your application in the link:https://github.com/yasmin-aumeeruddy/car-person-demo/blob/main/car/src/main/liberty/config/server.xml#L18[server.xml]:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Third-party APIs must be made visible for your application in the link:https://github.com/yasmin-aumeeruddy/car-person-demo/blob/main/car/src/main/liberty/config/server.xml#L18[server.xml]:
Add the following configuration in your link:https://github.com/yasmin-aumeeruddy/car-person-demo/blob/main/car/src/main/liberty/config/server.xml#L18[server.xml] to make third-party APIs visible for your application:

</webApplication>
----

The OpenTelemetry API can then be to create custom metrics. In link:https://github.com/yasmin-aumeeruddy/car-person-demo/blob/main/car/src/main/java/io/openliberty/demo/car/CarService.java#L101-L108[`CarService.java`], `Meter` is used to define instruments, in this case, a counter.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The OpenTelemetry API can then be to create custom metrics. In link:https://github.com/yasmin-aumeeruddy/car-person-demo/blob/main/car/src/main/java/io/openliberty/demo/car/CarService.java#L101-L108[`CarService.java`], `Meter` is used to define instruments, in this case, a counter.
You can the use the OpenTelemetry API to create custom metrics. In link:https://github.com/yasmin-aumeeruddy/car-person-demo/blob/main/car/src/main/java/io/openliberty/demo/car/CarService.java#L101-L108[`CarService.java`], `Meter` is used to define instruments, in this case, a counter.


You can see the application logs in the link:http://localhost:3000/explore?schemaVersion=1&panes=%7B%224j4%22:%7B%22datasource%22:%22loki%22,%22queries%22:%5B%7B%22refId%22:%22A%22,%22expr%22:%22%7Bservice_name%3D%5C%22car%5C%22%7D%20%7C%3D%20%60%60%22,%22queryType%22:%22range%22,%22datasource%22:%7B%22type%22:%22loki%22,%22uid%22:%22loki%22%7D,%22editorMode%22:%22builder%22%7D%5D,%22range%22:%7B%22from%22:%22now-1h%22,%22to%22:%22now%22%7D%7D%7D&orgId=1[dashboard].

=== Use the OpenTelemetry API to manually create traces
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we clarify that this is only required if you want custom trace? Is that correct?

Copy link
Member

@dmuelle dmuelle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks

@dmuelle dmuelle merged commit 9a1d389 into OpenLiberty:staging Mar 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants