GithubHelp home page GithubHelp logo

Comments (9)

objectiser avatar objectiser commented on July 17, 2024

Unfortunately this is not possible, as the library needs to register the APIExtensionsSpan instance with the ScopeManager, rather than the BraveSpan, as the wrapper intercepts various method calls on the span to then invoke the SpanObserver.

For example, instrumentation may later retrieve the active span from the ScopeManager to add tags, logs or finish the span. These must be performed on the APIExtensionsSpan instance, otherwise the observer would not be called.

from java-api-extensions.

objectiser avatar objectiser commented on July 17, 2024

I'm going to close the issue, but feel free to re-open if you would like to discuss further. Other option would be to raise an issue against the OT spec to start a discussion about supporting the observer as part of the core API.

from java-api-extensions.

michbeck100 avatar michbeck100 commented on July 17, 2024

Another option to implement the extensions would be to use a proxy using java.lang.reflect.Proxy. This would solve the problem with class casts.
Did you think about this option when implementing?

from java-api-extensions.

sjoerdtalsma avatar sjoerdtalsma commented on July 17, 2024

@michbeck100 Using proxies could actually be a really good idea.
One possibly complicating factor that must be considered is the new module system introduced by Java 9. Switching to proxies may make modularizing the api-extensions in the future more difficult.

from java-api-extensions.

objectiser avatar objectiser commented on July 17, 2024

@michbeck100 no didn't consider this option at the time, but as @sjoerdtalsma says, could be a good idea.

Would you be interested in contributing a PR, and also possibly looking into the java9 issue mentioned by @sjoerdtalsma ?

from java-api-extensions.

whiskeysierra avatar whiskeysierra commented on July 17, 2024

Another option to implement the extensions would be to use a proxy using java.lang.reflect.Proxy. This would solve the problem with class casts.

Java Proxies only support interfaces, not classes and BraveSpan is a class. I don't believe this would work.

What might work is to keep references to spans in weak-reference, identity hashmap which maps real span to instrumented span. Before passing something to the underlying implementation you unwrap it and when we get an uninstrumented span back that we need to expose we look it up in that map.

from java-api-extensions.

whiskeysierra avatar whiskeysierra commented on July 17, 2024

On a second thought, why not have a proxy for ScopeManager which automatically decorates any span it exposes via activeSpan?

from java-api-extensions.

objectiser avatar objectiser commented on July 17, 2024

@whiskeysierra How would the proxied ScopeManager be set on the tracer?

from java-api-extensions.

whiskeysierra avatar whiskeysierra commented on July 17, 2024

from java-api-extensions.

Related Issues (10)

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.