|
1 | 1 | [//]: # "Copyright Amazon.com Inc. or its affiliates. All Rights Reserved." |
2 | 2 | [//]: # "SPDX-License-Identifier: CC-BY-SA-4.0" |
3 | 3 |
|
4 | | -# Adding a Metrics Interface to Crypto Tools Libraries |
| 4 | +# Adding a Metrics Interface |
| 5 | + |
| 6 | +***NOTE: This document will be used to gain alignment on |
| 7 | +this interface should look like and how it could be integrated with |
| 8 | +existing operations. This document will not seek to specify |
| 9 | +a Metrics implementation or specify which metrics will be collected |
| 10 | +from impacted APIs or configurations.*** |
5 | 11 |
|
6 | 12 | ## Affected APIs or Client Configurations |
7 | 13 |
|
8 | 14 | This serves as a reference of all APIs and Client Configurations that this change affects. |
9 | 15 | This list is not exhaustive. Any downstream consumer of any API or client configuration SHOULD |
10 | | -also be updated as part of this proposed changed. This list contains the obvious changes that |
11 | | -would need to happen in order to support a metrics interface. |
| 16 | +also be updated as part of this proposed changed. |
12 | 17 |
|
13 | 18 | | API/ Configuration | |
14 | 19 | | --------------------------------------------------------------------------------------- | |
@@ -37,3 +42,210 @@ The key words |
37 | 42 | "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" |
38 | 43 | in this document are to be interpreted as described in |
39 | 44 | [RFC 2119](https://tools.ietf.org/html/rfc2119). |
| 45 | + |
| 46 | +## Summary |
| 47 | + |
| 48 | +Existing users of Crypto Tools (CT) libraries do no have any insights as to |
| 49 | +how the librar(y/ies) behave(s) in their application. |
| 50 | +This can lead to frustrating debugging sessions where users |
| 51 | +are required to have explicit tests to assert they are using a particular feature |
| 52 | +correctly, or if customers are using any of the KMS keyrings users have to have |
| 53 | +AWS Cloudwatch open to verify their application is sending values users expect. |
| 54 | +This can be seen as a best practice and users may find this a good exercise; |
| 55 | +however, CT's libraries do not make debugging an easy task. |
| 56 | + |
| 57 | +A feature which allows customers to get real-time telemetry of their application's |
| 58 | +integration with CT's libraries would be welcomed by users and will deliver on the |
| 59 | +"easy to use and hard to misuse" tenet. |
| 60 | + |
| 61 | +Introducing a new interface that defines the operations that must be |
| 62 | +implemented in order to build a specification compliant MetricsAgent. |
| 63 | + |
| 64 | +## Requirements |
| 65 | + |
| 66 | +The interface should have three requirements. |
| 67 | + |
| 68 | +1. MUST be simple. |
| 69 | +1. MUST be extensible. |
| 70 | + |
| 71 | +The following is documented to signify its importance |
| 72 | +even though the interface is not able to make this guarantee. |
| 73 | +Every implementation of the proposed interface must |
| 74 | +ensure the following. |
| 75 | + |
| 76 | +1. MUST NOT block the application's execution thread. |
| 77 | + |
| 78 | +## Interface |
| 79 | + |
| 80 | +### Inputs |
| 81 | + |
| 82 | +The inputs to the MetricsAgent are groups of related fields, referred to as: |
| 83 | + |
| 84 | +- [AddDate Input](adddate-input) |
| 85 | +- [AddTime Input](#addtime-input) |
| 86 | +- [AddCount Input](#addcount-input) |
| 87 | +- [AddProperty Input](#addproperty-input) |
| 88 | + |
| 89 | +#### AddDate Input |
| 90 | + |
| 91 | +This is the input to the [AddDate](#adddate) behavior. |
| 92 | + |
| 93 | +The add date input MUST include the following: |
| 94 | + |
| 95 | +- A label |
| 96 | +- A date |
| 97 | + |
| 98 | +The add date input MAY include the following: |
| 99 | + |
| 100 | +- A transactionId |
| 101 | + |
| 102 | +#### AddTime Input |
| 103 | + |
| 104 | +This is the input to the [AddTime](#addtime) behavior. |
| 105 | + |
| 106 | +The add time input MUST include the following: |
| 107 | + |
| 108 | +- A label |
| 109 | +- A duration |
| 110 | + |
| 111 | +The add time input MAY include the following: |
| 112 | + |
| 113 | +- A transactionId |
| 114 | + |
| 115 | +#### AddCount Input |
| 116 | + |
| 117 | +This is the input to the [AddCount](#addcount) behavior. |
| 118 | + |
| 119 | +The add count input MUST include the following: |
| 120 | + |
| 121 | +- A label |
| 122 | +- A date |
| 123 | + |
| 124 | +The add count input MAY include the following: |
| 125 | + |
| 126 | +- A transactionId |
| 127 | + |
| 128 | +#### AddProperty Input |
| 129 | + |
| 130 | +This is the input to the [AddProperty](#addproperty) behavior. |
| 131 | + |
| 132 | +The add property input MUST include the following: |
| 133 | + |
| 134 | +- A label |
| 135 | +- A value |
| 136 | + |
| 137 | +The add property input MAY include the following: |
| 138 | + |
| 139 | +- a transactionId |
| 140 | + |
| 141 | +### Behaviors |
| 142 | + |
| 143 | +The MetricsAgent Interface MUST support the following behaviors: |
| 144 | + |
| 145 | +- [AddDate](#adddate) |
| 146 | +- [AddTime](#addtime) |
| 147 | +- [AddCount](#addcount) |
| 148 | +- [AddProperty](#addproperty) |
| 149 | + |
| 150 | + |
| 151 | +#### AddDate |
| 152 | + |
| 153 | + |
| 154 | +#### AddTime |
| 155 | + |
| 156 | + |
| 157 | +#### AddCount |
| 158 | + |
| 159 | + |
| 160 | +#### AddProperty |
| 161 | + |
| 162 | + |
| 163 | +## Points of Integration |
| 164 | + |
| 165 | + |
| 166 | +## Proposed Smithy Model |
| 167 | +```smithy |
| 168 | +use aws.polymorph#extendable |
| 169 | +
|
| 170 | +@extendable |
| 171 | +resource MetricsLogger { |
| 172 | + operations: [ |
| 173 | + AddDate, |
| 174 | + AddTime, |
| 175 | + AddCount, |
| 176 | + AddProperty |
| 177 | + ] |
| 178 | +} |
| 179 | +
|
| 180 | +// Operations for different metric types |
| 181 | +operation AddDate { |
| 182 | + input: AddDateInput, |
| 183 | + output: AddOutput, |
| 184 | + errors: [MetricsPutError] |
| 185 | +} |
| 186 | +
|
| 187 | +operation AddTime { |
| 188 | + input: AddTimeInput, |
| 189 | + output: AddOutput, |
| 190 | + errors: [MetricsPutError] |
| 191 | +} |
| 192 | +
|
| 193 | +operation AddCount { |
| 194 | + input: AddCountInput, |
| 195 | + output: AddOutput, |
| 196 | + errors: [MetricsPutError] |
| 197 | +} |
| 198 | +
|
| 199 | +operation AddProperty { |
| 200 | + input: AddPropertyInput, |
| 201 | + output: AddOutput, |
| 202 | + errors: [MetricsPutError] |
| 203 | +} |
| 204 | +
|
| 205 | +// Input structures for each operation with flattened values |
| 206 | +structure AddDateInput { |
| 207 | + @required |
| 208 | + label: String, |
| 209 | + @required |
| 210 | + date: Timestamp, |
| 211 | + transactionId: String |
| 212 | +} |
| 213 | +
|
| 214 | +structure AddTimeInput { |
| 215 | + @required |
| 216 | + label: String, |
| 217 | + @required |
| 218 | + duration: Long, // Duration in milliseconds |
| 219 | + transactionId: String |
| 220 | +} |
| 221 | +
|
| 222 | +structure AddCountInput { |
| 223 | + @required |
| 224 | + label: String, |
| 225 | + @required |
| 226 | + count: Long, |
| 227 | + transactionId: String |
| 228 | +} |
| 229 | +
|
| 230 | +structure AddPropertyInput { |
| 231 | + @required |
| 232 | + label: String, |
| 233 | + @required |
| 234 | + value: String, |
| 235 | + transactionId: String |
| 236 | +} |
| 237 | +
|
| 238 | +// Common output structure |
| 239 | +structure AddOutput {} |
| 240 | +
|
| 241 | +// Error structure |
| 242 | +@error("client") |
| 243 | +structure MetricsPutError { |
| 244 | + @required |
| 245 | + message: String |
| 246 | +} |
| 247 | +
|
| 248 | +@aws.polymorph#reference(resource: MetricsLogger) |
| 249 | +structure MetricsLoggerReference {} |
| 250 | +
|
| 251 | +``` |
0 commit comments