-
Notifications
You must be signed in to change notification settings - Fork 73
Adds Pulsar sender #273
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
codefromthecrypt
merged 5 commits into
openzipkin:master
from
CodePrometheus:add-pulsar-sender
Feb 12, 2025
Merged
Adds Pulsar sender #273
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
3285e16
Adds Pulsar sender
CodePrometheus d6422c7
Fix round1: bump up to 3.5.0-SNAPSHOT and fix other issues
CodePrometheus 5585400
Merge remote-tracking branch 'origin/master' into add-pulsar-sender
CodePrometheus 907db08
Fix close resource
CodePrometheus e96aba2
Fix missing close scene
CodePrometheus File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
96 changes: 96 additions & 0 deletions
96
benchmarks/src/test/java/zipkin2/reporter/PulsarSenderBenchmarks.java
This file contains hidden or 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,96 @@ | ||
| /* | ||
| * Copyright The OpenZipkin Authors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
| package zipkin2.reporter; | ||
|
|
||
| import org.apache.pulsar.client.api.Consumer; | ||
| import org.apache.pulsar.client.api.PulsarClient; | ||
| import org.apache.pulsar.client.api.PulsarClientException; | ||
| import org.apache.pulsar.client.api.SubscriptionInitialPosition; | ||
| import org.apache.pulsar.client.api.SubscriptionType; | ||
| import org.openjdk.jmh.runner.Runner; | ||
| import org.openjdk.jmh.runner.RunnerException; | ||
| import org.openjdk.jmh.runner.options.Options; | ||
| import org.openjdk.jmh.runner.options.OptionsBuilder; | ||
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; | ||
| import org.testcontainers.containers.GenericContainer; | ||
| import org.testcontainers.containers.output.Slf4jLogConsumer; | ||
| import org.testcontainers.containers.wait.strategy.HttpWaitStrategy; | ||
| import zipkin2.reporter.internal.SenderBenchmarks; | ||
| import zipkin2.reporter.pulsar.PulsarSender; | ||
|
|
||
| import java.time.Duration; | ||
| import java.util.Collections; | ||
|
|
||
| import static org.testcontainers.utility.DockerImageName.parse; | ||
|
|
||
| public class PulsarSenderBenchmarks extends SenderBenchmarks { | ||
| static final Logger LOGGER = LoggerFactory.getLogger(PulsarSenderBenchmarks.class); | ||
|
|
||
| static final class PulsarContainer extends GenericContainer<PulsarContainer> { | ||
| static final int BROKER_PORT = 6650; | ||
| static final int BROKER_HTTP_PORT = 8080; | ||
|
|
||
| PulsarContainer() { | ||
| super(parse("apachepulsar/pulsar:4.0.2")); | ||
CodePrometheus marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| withExposedPorts(BROKER_PORT, BROKER_HTTP_PORT); | ||
| String cmd = "/pulsar/bin/apply-config-from-env.py /pulsar/conf/standalone.conf " + | ||
| "&& bin/pulsar standalone " + | ||
| "--no-functions-worker -nss"; | ||
| withEnv("PULSAR_MEM", "-Xms512m -Xmx512m -XX:MaxDirectMemorySize=1g"); // limit memory usage | ||
| waitStrategy = new HttpWaitStrategy() | ||
| .forPort(BROKER_HTTP_PORT) | ||
| .forStatusCode(200) | ||
| .forPath("/admin/v2/clusters") | ||
| .withStartupTimeout(Duration.ofSeconds(120)); | ||
| withCommand("/bin/bash", "-c", cmd); | ||
| withLogConsumer(new Slf4jLogConsumer(LOGGER)); | ||
| } | ||
|
|
||
| String serviceUrl() { | ||
| return "pulsar://" + getHost() + ":" + getMappedPort(BROKER_PORT); | ||
| } | ||
| } | ||
|
|
||
| PulsarContainer pulsar; | ||
| Consumer<byte[]> consumer; | ||
|
|
||
| @Override protected BytesMessageSender createSender() throws PulsarClientException { | ||
| pulsar = new PulsarContainer(); | ||
| pulsar.start(); | ||
|
|
||
| String topicName = "zipkin"; | ||
| PulsarSender sender = PulsarSender.newBuilder().topic(topicName) | ||
| .serviceUrl(pulsar.serviceUrl()).build(); | ||
|
|
||
| sender.send(Collections.emptyList()); | ||
| try (PulsarClient client = PulsarClient.builder() | ||
| .serviceUrl(pulsar.serviceUrl()) | ||
| .build()) { | ||
| consumer = client.newConsumer() | ||
| .topic(topicName) | ||
| .subscriptionType(SubscriptionType.Shared) | ||
| .subscriptionInitialPosition(SubscriptionInitialPosition.Earliest) | ||
| .subscriptionName(topicName) | ||
| .subscribe(); | ||
| } | ||
|
|
||
| return sender; | ||
| } | ||
|
|
||
| @Override protected void afterSenderClose() { | ||
| pulsar.stop(); | ||
| } | ||
|
|
||
| // Convenience main entry-point | ||
| public static void main(String[] args) throws RunnerException { | ||
| Options opt = new OptionsBuilder() | ||
| .include(".*" + PulsarSenderBenchmarks.class.getSimpleName() + ".*") | ||
| .build(); | ||
|
|
||
| new Runner(opt).run(); | ||
| } | ||
| } | ||
|
|
||
This file contains hidden or 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 hidden or 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 hidden or 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,4 @@ | ||
| Import-Package: \ | ||
| * | ||
| Export-Package: \ | ||
| zipkin2.reporter.pulsar |
This file contains hidden or 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,91 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <!-- | ||
|
|
||
| Copyright The OpenZipkin Authors | ||
| SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| --> | ||
| <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
| <modelVersion>4.0.0</modelVersion> | ||
|
|
||
| <parent> | ||
| <artifactId>zipkin-reporter-parent</artifactId> | ||
| <groupId>io.zipkin.reporter2</groupId> | ||
| <version>3.4.4-SNAPSHOT</version> | ||
CodePrometheus marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| </parent> | ||
|
|
||
| <artifactId>zipkin-sender-pulsar-client</artifactId> | ||
| <name>Zipkin Sender: Pulsar Client 4.x</name> | ||
|
|
||
| <properties> | ||
| <!-- Matches Export-Package in bnd.bnd --> | ||
| <module.name>zipkin2.reporter.pulsar</module.name> | ||
|
|
||
| <main.basedir>${project.basedir}/..</main.basedir> | ||
| <pulsar-client.version>4.0.2</pulsar-client.version> | ||
| </properties> | ||
|
|
||
| <dependencies> | ||
| <dependency> | ||
| <groupId>${project.groupId}</groupId> | ||
| <artifactId>zipkin-reporter</artifactId> | ||
| <version>${project.version}</version> | ||
| <!-- Senders don't use zipkin types. Excluding allows brave users to | ||
| avoid them by default. --> | ||
| <exclusions> | ||
| <exclusion> | ||
| <groupId>io.zipkin.zipkin2</groupId> | ||
| <artifactId>zipkin</artifactId> | ||
| </exclusion> | ||
| </exclusions> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>org.apache.pulsar</groupId> | ||
| <artifactId>pulsar-client</artifactId> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. good. sender name matches the artifact here! |
||
| <version>${pulsar-client.version}</version> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>org.testcontainers</groupId> | ||
| <artifactId>junit-jupiter</artifactId> | ||
| <version>${testcontainers.version}</version> | ||
| <scope>test</scope> | ||
| </dependency> | ||
| </dependencies> | ||
|
|
||
| <profiles> | ||
| <profile> | ||
| <id>release</id> | ||
| <properties> | ||
| <!-- pulsar 4.0+ is Java 8 bytecode --> | ||
| <maven.compiler.source>8</maven.compiler.source> | ||
| <maven.compiler.target>8</maven.compiler.target> | ||
| <maven.compiler.release>8</maven.compiler.release> | ||
| </properties> | ||
| <build> | ||
| <plugins> | ||
| <plugin> | ||
| <artifactId>maven-enforcer-plugin</artifactId> | ||
| <version>${maven-enforcer-plugin.version}</version> | ||
| <executions> | ||
| <execution> | ||
| <id>enforce-java</id> | ||
| <goals> | ||
| <goal>enforce</goal> | ||
| </goals> | ||
| <configuration> | ||
| <rules> | ||
| <!-- The only LTS JDK we support that can compile 8 bytecode is 11. | ||
| https://www.oracle.com/java/technologies/javase/17-relnote-issues.html --> | ||
| <requireJavaVersion> | ||
| <version>[11,12)</version> | ||
| </requireJavaVersion> | ||
| </rules> | ||
| </configuration> | ||
| </execution> | ||
| </executions> | ||
| </plugin> | ||
| </plugins> | ||
| </build> | ||
| </profile> | ||
| </profiles> | ||
| </project> | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add to the description the run of this benchmark in triple backticks