mirror of https://github.com/apache/nifi.git
NIFI-6977 - Change the reporting behavior of Azure Reporting task to report report the time when metrics are generated
Signed-off-by: Pierre Villard <pierre.villard.fr@gmail.com> This closes #4211.
This commit is contained in:
parent
a61a4c2b58
commit
9df53e7204
|
@ -133,11 +133,15 @@ public abstract class AbstractAzureLogAnalyticsReportingTask extends AbstractRep
|
|||
|
||||
protected void sendToLogAnalytics(final HttpPost request, final String workspaceId, final String linuxPrimaryKey,
|
||||
final String rawJson) throws IllegalArgumentException, RuntimeException, IOException {
|
||||
|
||||
final int bodyLength = rawJson.getBytes(UTF8).length;
|
||||
final String nowRfc1123 = RFC_1123_DATE_TIME.format(ZonedDateTime.now(ZoneOffset.UTC));
|
||||
final ZonedDateTime zNow = ZonedDateTime.now(ZoneOffset.UTC);
|
||||
final String nowRfc1123 = zNow.format(DateTimeFormatter.RFC_1123_DATE_TIME);
|
||||
final String nowISO8601 = zNow.format(DateTimeFormatter.ISO_DATE_TIME);
|
||||
final String createAuthorization = createAuthorization(workspaceId, linuxPrimaryKey, bodyLength, nowRfc1123);
|
||||
request.addHeader("Authorization", createAuthorization);
|
||||
request.addHeader("x-ms-date", nowRfc1123);
|
||||
request.addHeader("time-generated-field", nowISO8601);
|
||||
request.setEntity(new StringEntity(rawJson));
|
||||
try (CloseableHttpClient httpClient = HttpClients.createDefault()) {
|
||||
postRequest(httpClient, request);
|
||||
|
|
|
@ -213,9 +213,13 @@ public class TestAzureLogAnalyticsReportingTask {
|
|||
testedReportingTask.onTrigger(reportingContextStub);
|
||||
|
||||
HttpPost postRequest = testedReportingTask.getPostRequest();
|
||||
ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class);
|
||||
verify(postRequest, atLeast(1)).addHeader( eq("Authorization"), captor.capture());
|
||||
assertTrue(captor.getValue().contains("SharedKey"));
|
||||
ArgumentCaptor<String> captorAuthorization = ArgumentCaptor.forClass(String.class);
|
||||
ArgumentCaptor<String> captorXMsDate = ArgumentCaptor.forClass(String.class);
|
||||
ArgumentCaptor<String> captorTimeGeneratedField = ArgumentCaptor.forClass(String.class);
|
||||
verify(postRequest, atLeast(1)).addHeader( eq("Authorization"), captorAuthorization.capture());
|
||||
verify(postRequest, atLeast(1)).addHeader( eq("x-ms-date"), captorXMsDate.capture());
|
||||
verify(postRequest, atLeast(1)).addHeader( eq("time-generated-field"), captorTimeGeneratedField.capture());
|
||||
assertTrue(captorAuthorization.getValue().contains("SharedKey"));
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue