我有一个应用程序,它由以专有语言构建的多个服务组成。我想收集跟踪并摄取到 Jaeger 或 APM 解决方案中。没有仪器库。但是,这些服务以专有格式生成跟踪。我想将这些跟踪转换为 OpenTelemetry 跟踪并摄取到 Jaeger 或 APM 解决方案中。
我开始使用 OpenTelemetry-Java SDK。
// This is a just converter service, trying to convert proprietary traces to OLTP
// Not interested in instrumenting this converter service. Following code does not show the proprietary trace reading and conversion for brevity.
// Converter service - reading first service
private static void convert() {
OpenTelemetry openTelemetry = ExampleConfiguration.initOpenTelemetry();
Tracer tracer = openTelemetry.getTracer("io.opentelemetry.example");
Span exampleSpan = tracer.spanBuilder("exampleSpan").startSpan();
childOne(exampleSpan, openTelemetry);
...
}
// Converter service - reading second service
private static void childOne(Span parentSpan, OpenTelemetry openTelemetry) {
Tracer tracer = openTelemetry.getTracer("service2");
Span childSpan = tracer.spanBuilder("child").setParent(Context.current().with(parentSpan)).startSpan();
try {
Thread.sleep(4000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
childSpan.end();
}
配置适当的出口商。我可以按预期看到 Jeager 中的痕迹。
而我想描述两种不同的服务。这可能使用 OpenTelemetry 吗?