getsentry / getsentry/sentry-java

Apache Camel multicast does not have Hub cloned

未关闭
#2,330 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
Feature Java
主要语言
Kotlin
星标
1.4k
派生
478
平均合并
2 天 23 小时
30 天内合并 PR
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 摘要。