dd-trace-java icon indicating copy to clipboard operation
dd-trace-java copied to clipboard

Apache Camel support

Open tfactor2 opened this issue 5 years ago • 7 comments

Hi, We are using DataDog java agent with out-of-the-box frameworks integrations. It satisfies most of our needs except the ability to conveniently trace Apache Camel routes. It's a blocker for us, so we have to do custom development and integrate opentracing into the application.

Is there any plan to add the support of Apache Camel? According to traces mentioned in the issue https://github.com/DataDog/dd-trace-java/issues/433 the demand is there:

[main] DEBUG datadog.trace.agent.tooling.AgentInstaller$LoggingListener - Transformed class io.undertow.servlet.handlers.DefaultServlet -- sun.misc.Launcher$AppClassLoader@7e72c127
[Camel Thread #0 - LRUCacheFactory] DEBUG datadog.trace.agent.tooling.AgentInstaller$LoggingListener - Transformed class java.util.concurrent.ForkJoinPool -- null
[Camel Thread #0 - LRUCacheFactory] DEBUG datadog.trace.agent.tooling.AgentInstaller$LoggingListener - Transformed class java.util.concurrent.ForkJoinTask -- null
[Camel Thread #0 - LRUCacheFactory] DEBUG datadog.trace.agent.tooling.AgentInstaller$LoggingListener - Transformed class java.util.concurrent.ForkJoinTask$RunnableExecuteAction -- null
[Camel Thread #0 - LRUCacheFactory] DEBUG datadog.trace.agent.tooling.AgentInstaller$LoggingListener - Transformed class java.util.concurrent.ForkJoinTask$AdaptedCallable -- null
[main] DEBUG datadog.trace.agent.tooling.AgentInstaller$LoggingListener - Transformed class org.apache.camel.component.jetty.CamelContinuationServlet -- sun.misc.Launcher$AppClassLoader@7e72c127

tfactor2 avatar Nov 11 '20 09:11 tfactor2

Current workaround seems to be to use Open Tracing integration:

orange-buffalo avatar Nov 12 '20 03:11 orange-buffalo

Any news?

tfactor2 avatar Nov 27 '20 09:11 tfactor2

Any updates here, guys?

nedemon avatar Jul 02 '21 20:07 nedemon

Also looking for an update.

onyxraven avatar Apr 11 '22 22:04 onyxraven

For those asking for support, what would that look like to you? Part of the difficulty here is deciding where to create spans, how to handle workflow steps, how to handle fan-out, etc.

Ideas on what you would want these traces to end up looking like would be great. If you could include sample code defining a workflow with your ideas that would be even better

devinsba avatar Apr 18 '22 21:04 devinsba

I have spent some time and have a first pass at an adapter and setup example that I can share once I get internal approval. It uses camel-opentracing and sets up the right strategy. This is all provided by the opentracing library, and may work with the opentelemetry one too (assuming the agent injects the right providers?)

I've also created a prototype decorator that can use the _datadog header like the serverless tracing bits, for integrating microservice and serverless. It's a little weird due to some of the limitations of various layers. I've got some other opinions about this that are for another forum.

onyxraven avatar Apr 19 '22 00:04 onyxraven

Hey ya'll - so this is supported "out of the box" and works pretty well. This is thanks to opentracing. The documentation on the camel site works, and the following has the couple of additions.

camel context setup

To get the full effect (propagation, and automatic per-processor spans) you need to use the OpenTracingTracingStrategy as mentioned in the documentation (but not well mentioned how to apply it). You need to give it a Tracer instance (in this case, I'm using spring to get it auto injected), which will already be hooked up to the DDTracer by the agent.

package com.mypackage.config

import org.apache.camel.CamelContext
import org.apache.camel.ExtendedCamelContext
import org.apache.camel.opentracing.OpenTracingTracer
import org.apache.camel.opentracing.OpenTracingTracingStrategy
import org.apache.camel.spring.boot.CamelContextConfiguration
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration


@Configuration
class CamelConfig(
    private val tracer: OpenTracingTracer
) {

    @Bean
    fun contextConfiguration(): CamelContextConfiguration {
        return object : CamelContextConfiguration {
            override fun beforeApplicationStart(context: CamelContext) {
                context.adapt(ExtendedCamelContext::class.java).addInterceptStrategy(OpenTracingTracingStrategy(tracer))
            }

            override fun afterApplicationStart(camelContext: CamelContext) {
                // noop
            }
        }
    }
}

Note that this all only works on Camel > 3.7

onyxraven avatar May 04 '22 18:05 onyxraven

any update? Support of openTracing was removed in Camel 4. Therefore we need to migrate from openTracing to OpenTelemetry. That's why it will be nice to have support of Camel in dd java agent in order to avoid migration to openTelemetry

RuslanHryn avatar Jun 28 '23 08:06 RuslanHryn

We don't have any immediate plans to add support for Camel. However, we did add support for OpenTelemetry APIs recently.

dougqh avatar Jun 28 '23 20:06 dougqh

Camel is now supported in Beta via our OpenTelemetry API support

If you notice any issues, please reach out to support so that we can look into them properly

bm1549 avatar Oct 02 '23 14:10 bm1549

There are a few options described here with Opentracing: https://camel.apache.org/components/3.21.x/others/opentracing.html

saghayar avatar Nov 21 '23 17:11 saghayar