Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/streamnative/pulsar-tracing

Tracing instrumentation for Apache Pulsar clients.
https://github.com/streamnative/pulsar-tracing

apache-pulsar jaeger messaging opentelemetry opentracing pubsub

Last synced: about 2 months ago
JSON representation

Tracing instrumentation for Apache Pulsar clients.

Awesome Lists containing this project

README

        

# Apache Pulsar Client Tracing Instrumentation
Tracing instrumentation for Apache Pulsar client.

## OpenTracing Instrumentation
### Requirements

- Java 8
- Pulsar client >= 2.5.0

### Installation

Add Pulsar client and OpenTracing instrumentation for the Pulsar client.

```xml

org.apache.pulsar
pulsar-client
VERSION

```
```xml

io.streamnative
opentracing-pulsar-client
VERSION

```

### Usage

#### Interceptors based solution

```java
// Instantiate tracer
Tracer tracer = ...

// Optionally register tracer with GlobalTracer
GlobalTracer.register(tracer);
```

**Producer**

```java
// Instantiate Producer with tracing interceptor.
Producer producer = client
.newProducer(Schema.STRING)
.intercept(new TracingProducerInterceptor())
.topic("your-topic")
.create();

// Send messages.
producer.send("Hello OpenTracing!");
```

**Consumer**
```java
// Instantiate Consumer with tracing interceptor.
Consumer consumer = client.newConsumer(Schema.STRING)
.topic("your-topic")
.intercept(new TracingConsumerInterceptor<>())
.subscriptionName("your-sub")
.subscribe();

// Receive messages.
Message message = consumer.receive();

// To retrieve SpanContext from the message(Consumer side).
SpanContext spanContext = TracingPulsarUtils.extractSpanContext(message, tracer);
```

## License

[Apache 2.0 License](./LICENSE).