GH-1354 Added version header to Metric Message

Resolves #1354
Resolves #1356

polishing
This commit is contained in:
Oleg Zhurakousky
2018-04-11 14:12:29 -04:00
parent d459ebdf4a
commit 92f6d4556c
2 changed files with 8 additions and 3 deletions

View File

@@ -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]
----
@@ -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_CLOUD_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.

View File

@@ -57,7 +57,8 @@ import org.apache.commons.logging.Log;
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;
/**
*
@@ -229,7 +230,8 @@ class DefaultDestinationPublishingMeterRegistry extends MeterRegistry implements
@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_CLOUD_STREAM_VERSION", "2.x").build();
this.metersPublisherBinding.applicationMetrics().send(message);
}
}
}