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

Adding ECS formatting to Quarkus #146

Open
nadworny opened this issue Oct 5, 2021 · 1 comment
Open

Adding ECS formatting to Quarkus #146

nadworny opened this issue Oct 5, 2021 · 1 comment
Labels
agent-java community Issues and PRs created by the community

Comments

@nadworny
Copy link

nadworny commented Oct 5, 2021

Hi there,

I wanted to start a discussion about adding ECS formatting to the Quarkus framework. This issue describes what I was trying to achieve: quarkiverse/quarkus-logging-json#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:

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 framework, looks like this:

@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.

@AlexanderWert AlexanderWert added agent-java community Issues and PRs created by the community labels Oct 11, 2021
@mabartos
Copy link

Any progress on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
agent-java community Issues and PRs created by the community
Projects
None yet
Development

No branches or pull requests

3 participants