Coder Social home page Coder Social logo

Comments (7)

jeanbisutti avatar jeanbisutti commented on June 2, 2024

@Charlie441324219 CompletableFuture is auto-instrumented but Thread is not.

You can do the following thing to propagate the context:

            io.opentelemetry.context.Context context = io.opentelemetry.context.Context.current();
			Thread thread = new Thread(new Runnable() {
			    @Override
			    public void run() {
					try (Scope scope = context.makeCurrent()) {
				telemetry.trackEvent(baseHeaders, null, membershipNbr, "AI_LOG_CHILDREN_THREAD_THREAD")).start();
					}
			    }
			});
			thread.start();

from applicationinsights-java.

Charlie441324219 avatar Charlie441324219 commented on June 2, 2024

Hi @jeanbisutti ,

Thank you so much for your help, can you please provide more details about what condition context can auto propagate or what condition it cannot ?

from applicationinsights-java.

jeanbisutti avatar jeanbisutti commented on June 2, 2024

de more details about what condition context can auto propagate or what condition it cannot ?

@Charlie441324219, The propagation context is automatically propagated between all the automatic instrumentations. So, the context is propagated to CompletableFuture and the HTTP request can be known.

Thread is not automatically instrumented. So, the context is not automatically propagated into the methods of Thread , and it is needed to programmatically propagate the context.

from applicationinsights-java.

Charlie441324219 avatar Charlie441324219 commented on June 2, 2024

Hi @jeanbisutti , thank you for your reply, can you please provide more details about how to identify if a JAVA asynchronous technology is automatic instrumentations or not ?

from applicationinsights-java.

jeanbisutti avatar jeanbisutti commented on June 2, 2024

See https://learn.microsoft.com/en-us/azure/azure-monitor/app/opentelemetry-add-modify?tabs=java

from applicationinsights-java.

trask avatar trask commented on June 2, 2024

hi @Charlie441324219, context is intentionally not propagated to manually created threads, see open-telemetry/opentelemetry-java-instrumentation#2527, other cases are generally handled

from applicationinsights-java.

Charlie441324219 avatar Charlie441324219 commented on June 2, 2024

Thank you @jeanbisutti @trask ,

from applicationinsights-java.

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.