aaron-ai / rocketmq-opentelemetry

An example to integrate Apache RocketMQ with CNCF OpenTelemetry

Home Page:https://github.com/apache/rocketmq-clients

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

πŸš€ RocketMQ Γ— πŸ”­ OpenTelemetry Distributed Tracing

This repository provides a practical demonstration of how to leverage OpenTelemetry to achieve distributed tracing across RocketMQ 5.0 and other libraries like gRPC and Apache HTTP client.

Overview

OpenTelemetry is an open-source framework that provides a vendor-neutral API and instrumentation for distributed tracing, metrics, and logs. It enables observability and insight into complex distributed systems, allowing you to better understand how your systems are performing and identify potential issues.

This example shows how to use OpenTelemetry's automatic instrumentation approach, which involves using a Java agent to insert spans non-intrusively. By following this example, you can learn how to gain end-to-end visibility into your distributed system and improve your observability practices.

Prerequisites

Before using this library, you should have:

  • Java 8 or later installed.
  • The latest version of the OpenTelemetry Java agent.

You can download the Java agent from the here. The Java agent enables you to add instrumentation to your Java applications without modifying the source code.

Workflow

The entire system is divided into three processes. Process A acts as a gRPC client and sends an RPC request to process B, which acts as the gRPC server. While processing the gRPC request, process B sends a message to RocketMQ 5.0 server. Process C starts a RocketMQ 5.0 push consumer and, in the message listener for consuming the message, uses Apache HTTP client to send a GET request to https://taobao.com.

    Process A        Process B        Process C
  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
  β”‚gRPC Clientβ”œβ”€β”€β”€β”€β–ΊgRPC Serverβ”‚   β”‚ HTTP Client β”‚
  β””β”€β”€β”€β”€β”€β–²β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜   β””β”€β”€β”€β”€β”€β”€β–²β”€β”€β”€β”€β”€β”€β”˜
        β”‚                β”‚                β”‚
        β”‚          β”Œβ”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”
        β”‚          β”‚  RocketMQ β”œβ”€β”€β”€β–Ί   RocketMQ  β”œβ”€β”€β”€β–Ί Downstream
  Upstream Span    β”‚  Producer β”‚   β”‚ PushConsumerβ”‚        Span
                   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Specifically, the gRPC client sends a request within the scope of an upstream business span, while the RocketMQ push consumer also records a span for subsequent business logic after sending an HTTP request.

License

Apache License, Version 2.0 Copyright (C) Apache Software Foundation

About

An example to integrate Apache RocketMQ with CNCF OpenTelemetry

https://github.com/apache/rocketmq-clients


Languages

Language:Java 100.0%