Giter VIP home page Giter VIP logo

Comments (5)

paulbakker avatar paulbakker commented on July 17, 2024

Are you explicitly creating one in your app (I think that's what you're saying) or is it something coming implicitly from Webflux?

If it's your own, do you create a bean of type ContextRegistgry as well? The DGS provided one is @ConditionalOnMissingBean so you can override it by providing one yourself. Does that work?

I'm trying to fully understand the scenario to figure out if we should have other conditionals (or config) for this.

from dgs-framework.

martinvisser avatar martinvisser commented on July 17, 2024

We don't create or try to load our own, and I'm not entirely sure where it came from. The ObervationRegistry is autowired. The DGS bean is loaded, so that means there isn't any other, based on the conditional on the DGS one.
I haven't tried creating our own context registry bean, but can try, although we never needed one.

from dgs-framework.

martinvisser avatar martinvisser commented on July 17, 2024

This works too indeed:

@Bean
fun contextRegistry(): ContextRegistry = ContextRegistry()

But obviously this just hides the DGS bean

from dgs-framework.

martinvisser avatar martinvisser commented on July 17, 2024

The one that already loads the ObservationThreadLocalAccessor comes from io.micrometer:micrometer-observation from META-INF/services/io.micrometer.context.ThreadLocalAccessor:

io.micrometer.observation.contextpropagation.ObservationThreadLocalAccessor

And is loaded via a ServiceLoader in ContextRegistry from:

private static final ContextRegistry instance = new ContextRegistry().loadContextAccessors()
        .loadThreadLocalAccessors();
// ...
public ContextRegistry loadThreadLocalAccessors() {
    ServiceLoader.load(ThreadLocalAccessor.class).forEach(this::registerThreadLocalAccessor);
    return this;
}

from dgs-framework.

martinvisser avatar martinvisser commented on July 17, 2024

Probably relevant, it's ContextPropagationSupport that loads the class, which is triggered because we have Hooks.enableAutomaticContextPropagation() in our Spring Boot app:

fun main(vararg args: String) {
    Hooks.enableAutomaticContextPropagation()
    runApplication<MySecondApplication>(*args)
}

ContextPropagationSupport comes from io.projectreactor:reactor-core

from dgs-framework.

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.