admin管理员组文章数量:1350059
I have a NiFi flow that includes various custom processors to collect data from Kafka, perform calculations, and store results in a database. I want to add OpenTelemetry tracing to gain better insights into what happens internally throughout the flow by adding spans.
I went through OpenTelemetry concepts and examples and then attempted to add spans inside my NiFi custom processors.
Here’s what I did: Added OpenTelemetry dependencies in pom.xml:
<dependency>
<groupId>io.opentelemetry</groupId>
<artifactId>opentelemetry-api</artifactId>
<version>1.28.0</version>
</dependency>
<dependency>
<groupId>io.opentelemetry</groupId>
<artifactId>opentelemetry-sdk</artifactId>
<version>1.28.0</version>
</dependency>
<dependency>
<groupId>io.opentelemetry</groupId>
<artifactId>opentelemetry-exporter-otlp</artifactId>
<version>1.28.0</version>
</dependency>
<dependency>
<groupId>io.opentelemetry.semconv</groupId>
<artifactId>opentelemetry-semconv</artifactId>
<version>1.30.0</version>
</dependency>
Initialized OpenTelemetry in my custom processor:
@OnScheduled
public void onScheduled(final ProcessContext context) {
AttributeKey<String> strKey = AttributeKey.stringKey("NiFi-CustomProcessor");
Attributes attr = Attributes.builder()
.put(strKey, "String")
.build();
Resource resource = Resource.create(attr);
SdkTracerProvider sdkTracerProvider = SdkTracerProvider.builder()
.addSpanProcessor(BatchSpanProcessor.builder(OtlpGrpcSpanExporter.builder().build()).build())
.setResource(resource)
.build();
openTelemetry = OpenTelemetrySdk.builder().setTracerProvider(sdkTracerProvider).build();
tracer = openTelemetry.getTracer("MyCustomProcessorTracer");
}
Added spans inside onTrigger:
@Override
public void onTrigger(final ProcessContext context, final ProcessSession session) {
Span span = tracer.spanBuilder("processFlowFile").startSpan();
// ........
span.addEvent("Processor Started");
//business logic
span.addEvent("Processor Finished");
span.end();
}
Configured the OpenTelemetry Java Agent in nifi-bootstrap.conf:
java.arg.extra=javaagent:/path/to/opentelemetry-javaagent.jar
Trying to set up an OpenTelemetry Collector but not finding a proper .exe file to run it on Windows.
Need help on the following:
- Am I on the right track for adding OpenTelemetry tracing to NiFi custom processors?
- Do I need to manually initialize OpenTelemetry inside each processor, or is there a better way?
- How do I correctly set up the OpenTelemetry Collector on Windows?
- Is adding the Java agent in nifi-bootstrap.conf sufficient for tracing, or do I need additional configurations?
- Any guidance or improvements on my approach would be greatly appreciated!
本文标签: open telemetryHow to Add OpenTelemetry Tracing to NiFi Custom ProcessorsStack Overflow
版权声明:本文标题:open telemetry - How to Add OpenTelemetry Tracing to NiFi Custom Processors? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743854088a2550544.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论