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

fix: Typos #20

Merged
merged 1 commit into from
Jul 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 15 additions & 14 deletions docs/workshop.md
Original file line number Diff line number Diff line change
Expand Up @@ -312,9 +312,10 @@ transfer-encoding: chunked

```

Go then to the log folder (``easypay-service/logs/``) , look around the log files and look into these issues.

You should get these log entries in JSON format. Open one of these files and check out the logs.
Go then to the log folder (``easypay-service/logs/``).
You should get these log entries in JSON format.
Open one of these files and check out the logs.
Look into the ``easypay-service-log.json`` to pinpoint these issues.

> aside positive
>
Expand All @@ -339,7 +340,8 @@ Think to use the corresponding class to instantiate it!

Use the most appropriate log level

The log level is a fundamental concept in logging, no matter which logging framework you use. It allows you to tag log records according to their severity or importance. SLF4J offers the following log levels by default:
The log level is a fundamental concept in logging. Whether the logging framework you use, it allows you to tag log records according to their severity or importance.
For instance, [SLF4J](https://www.slf4j.org/) offers the [following log levels by default](https://www.slf4j.org/apidocs/org/slf4j/event/Level.html):

* ``TRACE`` : typically used to provide detailed diagnostic information that can be used for troubleshooting and debugging. Compare to DEBUG messages, TRACE messages are more fine-grained and verbose.
* ``DEBUG``: used to provide information that can be used to diagnose issues especially those related to program state.
Expand Down Expand Up @@ -393,13 +395,15 @@ For this error, you can log the error with the following content:


You can also add more logs:

In the ``CarValidator.checkLunKey()`` method, you can add a warn message when the key is not valid.
For instance:

```java
log.warn("checkLunKey KO: {}",cardNumber);
```
In the ``CarValidator.checkExpiryDate()`` method, you can add a warn message when a ``DateTimeParseException`` is thrown.

For instance:

```java
Expand All @@ -410,17 +414,20 @@ You can go further and add as many log you think it would help in production.

### Check your code

You can restart your easy pay service by typing ``CTRL+C`` in your console prompt, and run the following command:
You can restart your easy pay service running the following commands:

```bash
$ ./gradlew :easypay-service:bootRun -x test
$ docker compose down easypay-service
$ docker compose build easypay-service
$ docker compose up -d easypay-service
```

Now you can run the same commands ran earlier and check again the logs.

### A technical issue

Another issue was raised for the POS (Point of Sell) ``POS-02``.

When you reach the API using this command:

```bash
Expand Down Expand Up @@ -490,7 +497,7 @@ public boolean isActive(String posId) {

You can also prevent this issue by simply fixing the SQL import file.

In the file ``easypay-service/src/main/resources/db/postgresql/data.sql``, Modify the implied line for ``POS-02`` from:
In the file ``easypay-service/src/main/resources/db/postgresql/data.sql``, modify the implied line for ``POS-02`` from:

```sql
INSERT INTO pos_ref(id, pos_id, location, active) VALUES (2, 'POS-02', 'Blois France', NULL) ON CONFLICT DO NOTHING;
Expand All @@ -505,7 +512,7 @@ INSERT INTO pos_ref(id, pos_id, location, active) VALUES (2, 'POS-02', 'Blois Fr
### Using Mapped Diagnostic Context (MDC) to get more insights
> aside positive
>
> Mapped Diagnostic Context (MDC) will help us add more context on every log output. For more information, refer to this web page: https://logback.qos.ch/manual/mdc.html
> Mapped Diagnostic Context (MDC) will help us add more context on every log output. For more information, refer to this web page: [https://logback.qos.ch/manual/mdc.html](https://logback.qos.ch/manual/mdc.html).


Go to the ``PaymentResource`` class and modify the method ``processPayment()`` to instantiate the [MDC](https://logback.qos.ch/manual/mdc.html):
Expand Down Expand Up @@ -685,11 +692,6 @@ You can also view traces for the other services (e.g., ``api-gateway``)

Finally, you can search logs based on the correlation ID

> aside negative
>
> TODO MEttre la procédure


## Metrics

Let’s take control of our application’s metrics!
Expand Down Expand Up @@ -1667,7 +1669,6 @@ http POST :8080/api/easypay/payments posId=POS-01 cardNumber=5555567898780008 ex
> Similarly, your traces being ingested by Tempo might also take some time. Patience is key 😅

## Correlation
Duration: 0:15:00

Grafana allows correlation between all our telemetry data:

Expand Down
Loading