Giter Site home page Giter Site logo

Comments (2)

jpkrohling avatar jpkrohling commented on August 16, 2024

Would you be able to provide some code and the current outcome, along with the expected outcome?

from specification.

robertvazan avatar robertvazan commented on August 16, 2024

The code in question is a bit too lengthy and complicated to post here. Consider simple parent-child pair with callback being called inside the child:

class Parent {
    Child child = new Child();
    Parent() {
        // subscribe to events in child
    }
}
class Child {
    void someCallback() {
        Span span = GlobalTracer.get().buildSpan("Child.someCallback").start();
        try (Scope scope = GlobalTracer.get().activateSpan(span)) {
            // possibly propagate the event to parent via some listener
        }
    }
}

If the child callback doesn't propagate the event to parent, information about the parent will be completely omitted from the trace.

As a workaround, I have a helper class OwnerTrace that is used like this:

class Parent {
    Child child = OwnerTrace.of(new Child())
        .parent(this)
        .tag("key1", "value")
        .target();
    Parent() {
        OwnerTrace.of(this).tag("key2", "value");
        // subscribe to events in child
    }
}
class Child {
    Child() {
        OwnerTrace.of(this).tag("key3", "value");
    }
    void someCallback() {
        Span span = GlobalTracer.get().buildSpan("Child.someCallback").start();
        OwnerTrace.of(this).fill(span); // fills in key1, key2, key3
        try (Scope scope = GlobalTracer.get().activateSpan(span)) {
            // possibly propagate the event to parent via some listener
        }
    }
}

The key point is that OwnerTrace.parent() creates ownership hierarchy and OwnerTrace.fill() pulls tags from all ancestors.

There are many issues with this solution. The most basic one is that this is effectively a non-standard extension to opentracing that is not supported by anything and limits code sharing.

The above example is trivial and as such allows for many workarounds, but in practice I get ownership chains that are 5 levels deep, spanning several internal libraries, and child objects usually don't know anything about their current parent.

from specification.

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.