Skip to content

Commit

Permalink
feat: Format OTel changes
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelpri10 committed Sep 26, 2024
1 parent 305610e commit e8dce75
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit e8dce75

Please sign in to comment.