Coder Social home page Coder Social logo

Tracing Context not logged in access-log when replacing ReactorNettyHttpTracing with standard HttpClient/HttpServer integration about reactor-netty HOT 6 CLOSED

sandra-markerud avatar sandra-markerud commented on September 21, 2024
Tracing Context not logged in access-log when replacing ReactorNettyHttpTracing with standard HttpClient/HttpServer integration

from reactor-netty.

Comments (6)

violetagg avatar violetagg commented on September 21, 2024 1

@sandra-markerud For your use case you need to add the change below to your de.markerud.upgrade.configuration.TracingChannelDuplexHandler

    @Override
    public void flush(ChannelHandlerContext ctx) {
        try (Scope scope = contextSnapshotFactory.setThreadLocalsFrom(ctx.channel())) {
            ctx.flush();
        }
    }

from reactor-netty.

violetagg avatar violetagg commented on September 21, 2024 1

@sandra-markerud Can you try the code below?

class TracingChannelDuplexHandler extends ChannelDuplexHandler {
    private final ContextSnapshotFactory contextSnapshotFactory;

    public TracingChannelDuplexHandler(ContextSnapshotFactory contextSnapshotFactory) {
        this.contextSnapshotFactory = contextSnapshotFactory;
    }

    @Override
    public void channelRead(ChannelHandlerContext ctx, Object msg) {
        try (Scope scope = contextSnapshotFactory.setThreadLocalsFrom(ctx.channel())) {
            ctx.fireChannelRead(msg);
        }
    }

    @Override
    public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) {
        try (Scope scope = contextSnapshotFactory.setThreadLocalsFrom(ctx.channel())) {
            ctx.write(msg, promise);
        }
    }

    @Override
    public void flush(ChannelHandlerContext ctx) {
        try (Scope scope = contextSnapshotFactory.setThreadLocalsFrom(ctx.channel())) {
            ctx.flush();
        }
    }
}

from reactor-netty.

sandra-markerud avatar sandra-markerud commented on September 21, 2024 1

@violetagg You're right of course. My bad!
Thank you a lot for your quick response.

from reactor-netty.

sandra-markerud avatar sandra-markerud commented on September 21, 2024

@violetagg Thank you so much!
I can confirm, that the access-log now shows the tracing context.

I have one more question though:
The TracingChannelDuplexHandler is always coupled with Logbook.
How could I separate this?
Say, I always want the tracing-context logged in the access-log, but I need to be able to disable logbook.

from reactor-netty.

sandra-markerud avatar sandra-markerud commented on September 21, 2024

@violetagg this would still work for the access-log. Yes.
But now the logbook logs would not be written.
I need to instrument the TracingChannelDuplexHandler either with or without logbook, depending on if logbook is enabled or not

from reactor-netty.

violetagg avatar violetagg commented on September 21, 2024

@sandra-markerud I don't understand ... you can use different ChannelDuplexHandler implementations depending on whether you want to use logbook or not.

from reactor-netty.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.