getsentry / getsentry/sentry-java

Apache Camel multicast does not have Hub cloned

オープン
#2,330 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
Feature Java
主要言語
Kotlin
スター
1.4k
フォーク
478
平均マージ
2日 23時間
マージ済み PR(30日)
67

説明

### 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.

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。