-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Expand file tree
/
Copy pathTracingUtils.cpp
More file actions
48 lines (43 loc) · 2.61 KB
/
TracingUtils.cpp
File metadata and controls
48 lines (43 loc) · 2.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#include <smithy/tracing/TracingUtils.h>
using namespace smithy::components::tracing;
const char TracingUtils::COUNT_METRIC_TYPE[] = "Count";
const char TracingUtils::MICROSECOND_METRIC_TYPE[] = "Microseconds";
const char TracingUtils::BYTES_PER_SECOND_METRIC_TYPE[] = "Bytes/Second";
const char TracingUtils::SMITHY_CLIENT_DURATION_METRIC[] = "smithy.client.duration";
const char TracingUtils::SMITHY_CLIENT_ENDPOINT_RESOLUTION_METRIC[] = "smithy.client.resolve_endpoint_duration";
const char TracingUtils::SMITHY_CLIENT_DESERIALIZATION_METRIC[] = "smithy.client.deserialization_duration";
const char TracingUtils::SMITHY_CLIENT_SERIALIZATION_METRIC[] = "smithy.client.serialization_duration";
const char TracingUtils::SMITHY_CLIENT_SERVICE_CALL_METRIC[] = "smithy.client.service_call_duration";
const char TracingUtils::SMITHY_CLIENT_SIGNING_METRIC[] = "smithy.client.auth.signing_duration";
const char TracingUtils::SMITHY_CLIENT_SERVICE_BACKOFF_DELAY_METRIC[] = "smithy.client.backoff_delay";
const char TracingUtils::SMITHY_CLIENT_SERVICE_ATTEMPTS_METRIC[] = "smithy.client.attempts";
const char TracingUtils::SMITHY_METHOD_AWS_VALUE[] = "aws-api";
const char TracingUtils::SMITHY_SERVICE_DIMENSION[] = "rpc.service";
const char TracingUtils::SMITHY_METHOD_DIMENSION[] = "rpc.method";
const char TracingUtils::SMITHY_SYSTEM_DIMENSION[] = "rpc.system";
const char TracingUtils::SMITHY_METRICS_DNS_DURATION[] = "smithy.client.http.dns_duration";
const char TracingUtils::SMITHY_METRICS_CONNECT_DURATION[] = "smithy.client.http.connect_duration";
const char TracingUtils::SMITHY_METRICS_SSL_DURATION[] = "smithy.client.http.ssl_duration";
const char TracingUtils::SMITHY_METRICS_DOWNLOAD_SPEED_METRIC[] = "smithy.client.http.download_speed";
const char TracingUtils::SMITHY_METRICS_UPLOAD_SPEED_METRIC[] = "smithy.client.http.upload_speed";
const char TracingUtils::SMITHY_METRICS_UNKNOWN_METRIC[] = "smithy.client.http.unknown_metric";
void TracingUtils::RecordExecutionDuration(
SteadyTime before,
SteadyTime after,
Aws::String metricName,
const Meter &meter,
Aws::Map<Aws::String, Aws::String> attributes,
Aws::String description
) {
auto duration = std::chrono::duration_cast<std::chrono::microseconds>(after - before).count();
auto histogram = meter.CreateHistogram(std::move(metricName), MICROSECOND_METRIC_TYPE, description);
if (!histogram) {
AWS_LOG_ERROR("TracingUtil", "Failed to create histogram");
} else {
histogram->record((double) duration, std::move(attributes));
}
}