Skip to content
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

GH-1354 Added version header to Metric Message #1356

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2379,7 +2379,7 @@ java -jar time-source.jar \
--spring.cloud.stream.metrics.meter-filter=spring.integration.*
----

The following example shows data published to the binding destination as a result of the preceding command:
The following example shows the payload of the data published to the binding destination as a result of the preceding command:

[source,javascript]
----
Expand Down Expand Up @@ -2425,6 +2425,9 @@ The following example shows data published to the binding destination as a resul
}
----

NOTE: Given that the format of the Metric message has slightly changed after migrating to Micrometer, the published message will also have
a `STREAM_VERSION` header set to `2.x` to help distinguish between Metric messages from the older versions of the Spring Cloud Stream.

== Samples

For Spring Cloud Stream samples, see the https://github.com/spring-cloud/spring-cloud-stream-samples[spring-cloud-stream-samples] repository on GitHub.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@
import org.apache.commons.logging.LogFactory;

import org.springframework.context.SmartLifecycle;
import org.springframework.messaging.support.GenericMessage;
import org.springframework.messaging.Message;
import org.springframework.messaging.support.MessageBuilder;

/**
*
Expand Down Expand Up @@ -229,7 +230,8 @@ private static final class MessageChannelPublisher implements Consumer<String> {
@Override
public void accept(String metricData) {
logger.trace(metricData);
this.metersPublisherBinding.applicationMetrics().send(new GenericMessage<String>(metricData));
Message<String> message = MessageBuilder.withPayload(metricData).setHeader("STREAM_VERSION", "2.x").build();
this.metersPublisherBinding.applicationMetrics().send(message);
}
}
}