From e8dce751e03e2777577156f9d44c2b95b04080b1 Mon Sep 17 00:00:00 2001 From: Mike Prieto Date: Thu, 26 Sep 2024 14:57:00 +0000 Subject: [PATCH] feat: Format OTel changes --- .../pubsub/v1/OpenTelemetryPubsubTracer.java | 15 +++++++++++---- .../com/google/cloud/pubsub/v1/Publisher.java | 13 ++++++------- .../com/google/cloud/pubsub/v1/Subscriber.java | 12 ++++++------ .../google/cloud/pubsub/v1/OpenTelemetryTest.java | 10 +++++++--- 4 files changed, 30 insertions(+), 20 deletions(-) diff --git a/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/OpenTelemetryPubsubTracer.java b/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/OpenTelemetryPubsubTracer.java index 8b27f2a56..cc7192a1f 100644 --- a/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/OpenTelemetryPubsubTracer.java +++ b/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/OpenTelemetryPubsubTracer.java @@ -88,9 +88,12 @@ void startPublisherSpan(PubsubMessageWrapper message) { createCommonSpanAttributesBuilder( message.getTopicName(), message.getTopicProject(), "publish", "create"); - attributesBuilder.put(MessagingIncubatingAttributes.MESSAGING_MESSAGE_BODY_SIZE, message.getDataSize()); + attributesBuilder.put( + MessagingIncubatingAttributes.MESSAGING_MESSAGE_BODY_SIZE, message.getDataSize()); if (!message.getOrderingKey().isEmpty()) { - attributesBuilder.put(MessagingIncubatingAttributes.MESSAGING_GCP_PUBSUB_MESSAGE_ORDERING_KEY, message.getOrderingKey()); + attributesBuilder.put( + MessagingIncubatingAttributes.MESSAGING_GCP_PUBSUB_MESSAGE_ORDERING_KEY, + message.getOrderingKey()); } Span publisherSpan = @@ -238,10 +241,14 @@ void startSubscriberSpan(PubsubMessageWrapper message, boolean exactlyOnceDelive .put(MessagingIncubatingAttributes.MESSAGING_GCP_PUBSUB_MESSAGE_ACK_ID, message.getAckId()) .put(MESSAGE_EXACTLY_ONCE_ATTR_KEY, exactlyOnceDeliveryEnabled); if (!message.getOrderingKey().isEmpty()) { - attributesBuilder.put(MessagingIncubatingAttributes.MESSAGING_GCP_PUBSUB_MESSAGE_ORDERING_KEY, message.getOrderingKey()); + attributesBuilder.put( + MessagingIncubatingAttributes.MESSAGING_GCP_PUBSUB_MESSAGE_ORDERING_KEY, + message.getOrderingKey()); } if (message.getDeliveryAttempt() > 0) { - attributesBuilder.put(MessagingIncubatingAttributes.MESSAGING_GCP_PUBSUB_MESSAGE_DELIVERY_ATTEMPT, message.getDeliveryAttempt()); + attributesBuilder.put( + MessagingIncubatingAttributes.MESSAGING_GCP_PUBSUB_MESSAGE_DELIVERY_ATTEMPT, + message.getDeliveryAttempt()); } Attributes attributes = attributesBuilder.build(); Context publisherSpanContext = message.extractSpanContext(attributes); diff --git a/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/Publisher.java b/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/Publisher.java index ff8288785..99d0be17b 100644 --- a/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/Publisher.java +++ b/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/Publisher.java @@ -927,14 +927,13 @@ public Builder setCompressionBytesThreshold(long compressionBytesThreshold) { return this; } - /** - * OpenTelemetry will be enabled if setEnableOpenTelemetry is true and and instance of OpenTelemetry has been provied. - Warning: traces are subject to change. The name and attributes of a span might - change without notice. Only use run traces interactively. Don't use in - automation. Running non-interactive traces can cause problems if the underlying - trace architecture changes without notice. - */ + * OpenTelemetry will be enabled if setEnableOpenTelemetry is true and and instance of + * OpenTelemetry has been provied. Warning: traces are subject to change. The name and + * attributes of a span might change without notice. Only use run traces interactively. Don't + * use in automation. Running non-interactive traces can cause problems if the underlying trace + * architecture changes without notice. + */ /** Gives the ability to enable Open Telemetry Tracing */ public Builder setEnableOpenTelemetryTracing(boolean enableOpenTelemetryTracing) { diff --git a/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/Subscriber.java b/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/Subscriber.java index c69f0273c..953b2d571 100644 --- a/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/Subscriber.java +++ b/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/Subscriber.java @@ -708,12 +708,12 @@ Builder setClock(ApiClock clock) { } /** - * OpenTelemetry will be enabled if setEnableOpenTelemetry is true and and instance of OpenTelemetry has been provied. - Warning: traces are subject to change. The name and attributes of a span might - change without notice. Only use run traces interactively. Don't use in - automation. Running non-interactive traces can cause problems if the underlying - trace architecture changes without notice. - */ + * OpenTelemetry will be enabled if setEnableOpenTelemetry is true and and instance of + * OpenTelemetry has been provied. Warning: traces are subject to change. The name and + * attributes of a span might change without notice. Only use run traces interactively. Don't + * use in automation. Running non-interactive traces can cause problems if the underlying trace + * architecture changes without notice. + */ /** Gives the ability to enable Open Telemetry Tracing */ public Builder setEnableOpenTelemetryTracing(boolean enableOpenTelemetryTracing) { diff --git a/google-cloud-pubsub/src/test/java/com/google/cloud/pubsub/v1/OpenTelemetryTest.java b/google-cloud-pubsub/src/test/java/com/google/cloud/pubsub/v1/OpenTelemetryTest.java index c242d9a63..f6c56e896 100644 --- a/google-cloud-pubsub/src/test/java/com/google/cloud/pubsub/v1/OpenTelemetryTest.java +++ b/google-cloud-pubsub/src/test/java/com/google/cloud/pubsub/v1/OpenTelemetryTest.java @@ -190,7 +190,8 @@ public void testPublishSpansSuccess() { .containsEntry(PROJECT_ATTR_KEY, PROJECT_NAME) .containsEntry(SemanticAttributes.CODE_FUNCTION, "publish") .containsEntry(SemanticAttributes.MESSAGING_OPERATION, "create") - .containsEntry(MessagingIncubatingAttributes.MESSAGING_GCP_PUBSUB_MESSAGE_ORDERING_KEY, ORDERING_KEY) + .containsEntry( + MessagingIncubatingAttributes.MESSAGING_GCP_PUBSUB_MESSAGE_ORDERING_KEY, ORDERING_KEY) .containsEntry(MessagingIncubatingAttributes.MESSAGING_MESSAGE_BODY_SIZE, messageSize) .containsEntry(SemanticAttributes.MESSAGING_MESSAGE_ID, MESSAGE_ID); @@ -499,9 +500,12 @@ public void testSubscribeSpansSuccess() { .containsEntry(PROJECT_ATTR_KEY, PROJECT_NAME) .containsEntry(SemanticAttributes.CODE_FUNCTION, "onResponse") .containsEntry(MessagingIncubatingAttributes.MESSAGING_MESSAGE_BODY_SIZE, messageSize) - .containsEntry(MessagingIncubatingAttributes.MESSAGING_GCP_PUBSUB_MESSAGE_ORDERING_KEY, ORDERING_KEY) + .containsEntry( + MessagingIncubatingAttributes.MESSAGING_GCP_PUBSUB_MESSAGE_ORDERING_KEY, ORDERING_KEY) .containsEntry(MessagingIncubatingAttributes.MESSAGING_GCP_PUBSUB_MESSAGE_ACK_ID, ACK_ID) - .containsEntry(MessagingIncubatingAttributes.MESSAGING_GCP_PUBSUB_MESSAGE_DELIVERY_ATTEMPT, DELIVERY_ATTEMPT) + .containsEntry( + MessagingIncubatingAttributes.MESSAGING_GCP_PUBSUB_MESSAGE_DELIVERY_ATTEMPT, + DELIVERY_ATTEMPT) .containsEntry(MESSAGE_EXACTLY_ONCE_ATTR_KEY, EXACTLY_ONCE_ENABLED) .containsEntry(MESSAGE_RESULT_ATTR_KEY, PROCESS_ACTION) .containsEntry(SemanticAttributes.MESSAGING_MESSAGE_ID, MESSAGE_ID);