Skip to content

Commit

Permalink
feat: Ensure SubscriberStreamingConnection and MessageDispatcher have…
Browse files Browse the repository at this point in the history
… default no-op tracers by default for tests
  • Loading branch information
michaelpri10 committed Sep 12, 2024
1 parent ca4680f commit d07b493
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class MessageDispatcher {

private final String subscriptionName;
private final boolean enableOpenTelemetryTracing;
private final PubsubTracer tracer;
private PubsubTracer tracer = new BasePubsubTracer();

/** Internal representation of a reply to a Pubsub message, to be sent back to the service. */
public enum AckReply {
Expand Down Expand Up @@ -227,7 +227,9 @@ private MessageDispatcher(Builder builder) {

subscriptionName = builder.subscriptionName;
enableOpenTelemetryTracing = builder.enableOpenTelemetryTracing;
tracer = builder.tracer;
if (builder.tracer != null) {
tracer = builder.tracer;
}
}

private boolean shouldSetMessageFuture() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package com.google.cloud.pubsub.v1;

import com.google.api.core.InternalApi;
import com.google.common.base.Preconditions;
import com.google.pubsub.v1.PubsubMessage;
import com.google.pubsub.v1.SubscriptionName;
import com.google.pubsub.v1.TopicName;
Expand Down Expand Up @@ -427,7 +426,6 @@ public Builder(
}

public PubsubMessageWrapper build() {
Preconditions.checkArgument(this.topicName != null || this.subscriptionName != null);
return new PubsubMessageWrapper(this);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ final class StreamingSubscriberConnection extends AbstractApiService implements
private final String clientId = UUID.randomUUID().toString();

private final boolean enableOpenTelemetryTracing;
private final PubsubTracer tracer;
private PubsubTracer tracer = new BasePubsubTracer();

private StreamingSubscriberConnection(Builder builder) {
subscription = builder.subscription;
Expand Down Expand Up @@ -156,7 +156,9 @@ private StreamingSubscriberConnection(Builder builder) {
}

enableOpenTelemetryTracing = builder.enableOpenTelemetryTracing;
tracer = builder.tracer;
if (builder.tracer != null) {
tracer = builder.tracer;
}

messageDispatcher =
messageDispatcherBuilder
Expand Down

0 comments on commit d07b493

Please sign in to comment.