getsentry / getsentry/sentry-java

Apache Camel multicast does not have Hub cloned

Offen
#2,330 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Feature Java
Vorherrschende Sprache
Kotlin
Sterne
1.4k
Forks
478
Ø Merge
2 T. 23 Std.
Gemergte PRs (30 T.)
67

Beschreibung

### Integration

sentry

### Java Version

8

### Version

6.6.0

### Steps to Reproduce

Create Apache Camel sample where multicast is used like:

```Java
package io.sentry.samples.spring.boot;

import java.util.UUID;
import org.apache.camel.CamelContext;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.impl.DefaultCamelContext;
import org.apache.camel.model.rest.RestBindingMode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
class RestApi extends RouteBuilder {

@Autowired PersonService personService;

@Override
public void configure() {
CamelContext context = new DefaultCamelContext();

restConfiguration()
.contextPath("/camel")
.port(8080)
.enableCORS(true)
.apiContextPath("/api-doc")
.apiProperty("api.title", "Test REST API")
.apiProperty("api.version", "v1")
.apiContextRouteId("doc-api")
.component("servlet")
.bindingMode(RestBindingMode.json);

rest("/api/")
.id("api-route")
.consumes("application/json")
.post("/bean")
.bindingMode(RestBindingMode.json_xml)
.type(MyBean.class)
.to("direct:remoteService");

rest("/api/")
.id("api-route")
.consumes("application/json")
.post("/bean2")
.bindingMode(RestBindingMode.json_xml)
.type(MyBean.class)
.to("direct:insert");

from("direct:remoteService")
.routeId("direct-route")
.tracing()
.multicast()
.parallelProcessing()
.to("direct:insert", "direct:insert2")
.log(">>> ${body.id}")
.log(">>> ${body.name}")
.transform()
.simple("Hello ${in.body.name}")
.setHeader(Exchange.HTTP_RESPONSE_CODE, constant(200));

from("direct:insert")
.process(
new Processor() {
public void process(Exchange xchg) throws Exception {
// Take the Employee object from the exchange and create the insert query
MyBean employee = xchg.getIn().getBody(MyBean.class);
String query =
"INSERT INTO person(id,firstName, lastName)values('"
+ employee.getId()
+ "','"
+ employee.getName()
+ "','"
+ UUID.randomUUID().toString()
+ "')";
// Set the insert query in body and call camel jdbc
xchg.getIn().setBody(query);
}
})
.to("jdbc:dataSource");

from("direct:insert2")
.process(
new Processor() {
public void process(Exchange xchg) throws Exception {
// Take the Employee object from the exchange and create the insert query
MyBean employee = xchg.getIn().getBody(MyBean.class);
String query =
"INSERT INTO person(id,firstName, lastName)values('9999"
+ employee.getId()
+ "','"
+ employee.getName()
+ "2','"
+ UUID.randomUUID().toString()
+ "')";
// Set the insert query in body and call camel jdbc
xchg.getIn().setBody(query);
}
})
.to("jdbc:dataSource");
}
}
```

Then e.g. check `SentryJdbcEventListener` using a debugger. It's run on a separate thread and has a separate Hub instance and therefore can't find the parent Span using `hub.getSpan()`.

### Expected Result

Hub is somehow cloned or passed to multicasted camel things (whatever the correct term here is) and Spans can be added to the parent span of the multicast.

### Actual Result

Hub is not cloned therefore parent Span can't be found.

### Ideas

We'd need some way of cloning the Hub onto the thread executing each of the multicasted parts. Maybe there's some sort of context in Apache Camel we can use.

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.