elastic / elastic/ecs-logging-java

Adding ECS formatting to Quarkus

Ouverte
#146 1 commentaire 13 réactions 0 personnes assignées Voir sur GitHub
agent-java community
Langage dominant
Java
Étoiles
148
Forks
82
Merge moyen
2 j 17 h
PR mergées (30 j)
3

Description

Hi there,

I wanted to start a discussion about adding ECS formatting to the [Quarkus](https://quarkus.io/) framework. This issue describes what I was trying to achieve: https://github.com/quarkiverse/quarkus-logging-json/issues/132.

Now I have a working solution and was wondering how I can contribute to his library.

The solution consist of the following code which is based on your classes:
- Serializer: https://gist.github.com/nadworny/5fc96555c5f5d24c919fcacc482e820c
- Formatter: https://gist.github.com/nadworny/a80d405b4b4fc50f6e078ca14f451ab4

My EcsFormatter doesn't extend the Formatter class as it requires a slightly different approach namely it writes directly into the generator.

The final JsonProvider, which uses the [quarkus-logging-json](https://github.com/quarkiverse/quarkus-logging-json) framework, looks like this:
```java
@ApplicationScoped
public class EcsJsonProvider implements JsonProvider {

private final EcsQuarkusFormatter ecsFormatter;

@Inject
public EcsJsonProvider(EcsConfiguration ecsConfiguration) {
ecsFormatter = new EcsQuarkusFormatter(ecsConfiguration.service().name(), ecsConfiguration.service()
.nodeName().orElse(null), Boolean.TRUE.equals(ecsConfiguration.logOrigin().orElse(null)),
Boolean.TRUE.equals(ecsConfiguration.errorStackTraceAsArray().orElse(null)));
}

@Override
public void writeTo(JsonGenerator generator, ExtLogRecord event) throws IOException {
ecsFormatter.format(generator, event);
}
}
```

Any suggestions/contributions how we could re-use my code and make it into this library would be greatly appreciated.

Guide de contribution

Ouvrir le guide de contribution

Piste de recherche

Commencez par examiner l’issue quarkiverse liée et les deux gists du sérialiseur et du formateur ECS, puis inspectez les points d’extension existants Formatter et JsonProvider de cette bibliothèque. La contribution est terminée lorsque le projet a convenu d’une approche d’intégration et que le formatage ECS est pris en charge dans la bibliothèque avec les tests appropriés ; aucun fichier ni test du dépôt n’est nommé ici.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
java
Domaine
observability-sre
Type d'issue
Fonctionnalité
Difficulté
5/5
Temps estimé
Plus d'une semaine
Activité
À l'abandon
Clarté
À clarifier
Accessibilité débutants
25/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.