-
Notifications
You must be signed in to change notification settings - Fork 714
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Adrian Cole <adrian@tetrate.io>
- Loading branch information
1 parent
21779e3
commit 01266d6
Showing
33 changed files
with
1,174 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
# brave-instrumentation-rocketmq-client | ||
|
||
## Tracing for RocketMQ Client | ||
|
||
This module provides instrumentation for RocketMQ based services. | ||
|
||
## example | ||
|
||
### producer | ||
|
||
The key is to register our hook to the producer | ||
|
||
```java | ||
package brave.rocketmq.client; | ||
|
||
import brave.Tracing; | ||
import brave.messaging.MessagingRequest; | ||
import brave.messaging.MessagingTracing; | ||
import brave.sampler.SamplerFunction; | ||
import brave.sampler.SamplerFunctions; | ||
import org.apache.rocketmq.client.producer.DefaultMQProducer; | ||
import org.apache.rocketmq.common.message.Message; | ||
|
||
public class ProducerExample { | ||
|
||
public static void main(String[] args) throws Exception { | ||
// todo Replaced with actual tracing construct | ||
Tracing tracing = Tracing.newBuilder().build(); | ||
SamplerFunction<MessagingRequest> producerSampler = SamplerFunctions.deferDecision(); | ||
RocketMQTracing producerTracing = RocketMQTracing.create( | ||
MessagingTracing.newBuilder(tracing).producerSampler(producerSampler).build()); | ||
|
||
String topic = "testSend"; | ||
Message message = new Message(topic, "JoeKerouac", "hello".getBytes()); | ||
DefaultMQProducer producer = new DefaultMQProducer("testSend"); | ||
// todo This is the key, register the hook to the producer | ||
producer.getDefaultMQProducerImpl() | ||
.registerSendMessageHook(new SendMessageBraveHookImpl(producerTracing)); | ||
// Replace with actual address | ||
producer.setNamesrvAddr("127.0.0.1:9876"); | ||
producer.start(); | ||
producer.send(message); | ||
|
||
producer.shutdown(); | ||
} | ||
} | ||
|
||
``` | ||
|
||
### consumer | ||
|
||
Replace `org.apache.rocketmq.client.consumer.listener.MessageListenerConcurrently` | ||
with `brave.rocketmq.client.TracingMessageListenerConcurrently` | ||
or `org.apache.rocketmq.client.consumer.listener.MessageListenerOrderly` | ||
with `brave.rocketmq.client.TracingMessageListenerOrderly`; | ||
|
||
```java | ||
package brave.rocketmq.client; | ||
|
||
import brave.Span; | ||
import brave.Tracer; | ||
import brave.Tracing; | ||
import brave.messaging.MessagingRequest; | ||
import brave.messaging.MessagingTracing; | ||
import brave.sampler.SamplerFunction; | ||
import brave.sampler.SamplerFunctions; | ||
import org.apache.rocketmq.client.consumer.DefaultMQPushConsumer; | ||
import org.apache.rocketmq.common.message.MessageExt; | ||
|
||
import java.util.Optional; | ||
|
||
public class ProducerExample { | ||
|
||
public static void main(String[] args) throws Exception { | ||
// todo Replaced with actual tracing construct | ||
Tracing tracing = Tracing.newBuilder().build(); | ||
SamplerFunction<MessagingRequest> producerSampler = SamplerFunctions.deferDecision(); | ||
RocketMQTracing producerTracing = RocketMQTracing.create( | ||
MessagingTracing.newBuilder(tracing).producerSampler(producerSampler).build()); | ||
|
||
String topic = "testPushConsumer"; | ||
String nameserverAddr = "127.0.0.1:9876"; | ||
|
||
DefaultMQPushConsumer consumer = new DefaultMQPushConsumer("testPushConsumer"); | ||
consumer.setNamesrvAddr(nameserverAddr); | ||
consumer.subscribe(topic, "*"); | ||
consumer.registerMessageListener(new TraceableMessageListenerConcurrently(0, producerTracing) { | ||
@Override | ||
protected void handleMessage(MessageExt messageExt) { | ||
Span span = | ||
Optional.ofNullable(Tracing.currentTracer()).map(Tracer::currentSpan).orElse(null); | ||
// do something | ||
} | ||
}); | ||
consumer.start(); | ||
} | ||
} | ||
|
||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# We use brave.internal.Nullable, but it is not used at runtime. | ||
Import-Package: \ | ||
!brave.internal*,\ | ||
* | ||
Export-Package: \ | ||
brave.rocketmq.client |
Oops, something went wrong.