Skip to content

Commit 2f17445

Browse files
committed
udpates
1 parent ca37826 commit 2f17445

File tree

3 files changed

+93
-49
lines changed

3 files changed

+93
-49
lines changed

changes/2025-09-12_introduce-metrics-interface/background.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,21 @@ if they wish to do so.
120120
There is no need to reinvent the wheel. Other metric frameworks have solved many
121121
of the issues that are described above, (e.g. handling failing requests, perform
122122
blocking requests to CT libraries, use a separate thread/thread pool that handles
123-
these request). By just providing a wrapper, customers can use the framework they
124-
are most comfortable with.
123+
these request). By providing a wrapper around a language's most popular logging
124+
framework, customer's can configure their metrics provider of their liking and
125+
it would just work with CT libraries.
125126

126127
#### Yes
128+
129+
CT has always shipped custom implementations of interfaces it provides customers.
130+
One could argue that any of the KMS keyrings is simply a wrapper around KMS.
131+
While true, these keyring implementations do more than just call KMS.
132+
The metrics worker that CT provides customers would just delegate all operations
133+
to the underlying client. If anything, CT _may_ implement an operation to flush
134+
any metrics the wrappers have collected.
135+
136+
## Success Criteria
137+
138+
To consider this feature a success, customers should be able to wrap their
139+
telemetry provider of choice with the proposed interface and experience
140+
negligible application latency.

changes/2025-09-12_introduce-metrics-interface/change.md

Lines changed: 61 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ integration with CT's libraries would be welcomed by users and will deliver on t
5959
"easy to use and hard to misuse" tenet.
6060

6161
Introducing a new interface that defines the operations that must be
62-
implemented in order to build a specification compliant MetricsAgent.
62+
implemented in order to build a specification compliant MetricsWorker.
6363

6464
## Requirements
6565

@@ -77,8 +77,8 @@ ensure the following.
7777

7878
## Points of Integration
7979

80-
To collect metrics across CT's library stack multiple points of integration
81-
are needed in order to collect metrics across CT's libraries.
80+
To collect metrics across CT's library stack, multiple points of integration
81+
are needed in order to collect metrics.
8282
Generally, CT's libraries work as follows:
8383

8484
_Note: Not every Client supports the Material Provider Library.
@@ -100,12 +100,12 @@ sequenceDiagram
100100

101101
To optionally emit metrics from a top level client,
102102
all customer facing APIs MUST be changed to optionally accept
103-
a Metrics Agent. This will allow customers to define and supply one top
104-
level Metrics Agent; this agent will get plumbed throughout CT's stack.
103+
a Metrics Worker. This will allow customers to define and supply one top
104+
level Metrics Worker; this agent will get plumbed throughout CT's stack.
105105

106106
For example, in the ESDK for Java this would look like:
107107

108-
**This example uses a simple metrics agent that the mpl provides to customers**
108+
**This example uses a simple Metrics Worker that the mpl provides to customers**
109109

110110
**This simple interface is simply a wrapper around a battle tested logging framework.**
111111

@@ -124,16 +124,16 @@ final IKeyring rawAesKeyring = matProv.CreateRawAesKeyring(keyringInput);
124124
final Map<String, String> encryptionContext =
125125
Collections.singletonMap("ExampleContextKey", "ExampleContextValue");
126126

127-
// Create a Metrics Agent
128-
final IMetricsAgent metrics = matProv.CreateSimpleMetricsAgent(metricsAgentInput);
127+
// Create a Metrics Worker
128+
final IMetricsWorker metricWorker = matProv.CreateSimpleMetricsWorker(metricsWorkerInput);
129129
// 4. Encrypt the data
130130
final CryptoResult<byte[], ?> encryptResult =
131-
crypto.encryptData(rawAesKeyring, metrics, EXAMPLE_DATA, encryptionContext);
131+
crypto.encryptData(rawAesKeyring, metricWorker, EXAMPLE_DATA, encryptionContext);
132132
final byte[] ciphertext = encryptResult.getResult();
133133
```
134134

135-
This change will allow Crypto Tools to introduce a Metrics Agent in a
136-
non-breaking way as the Metrics Agent will be an optional parameter
135+
This change will allow Crypto Tools to introduce a Metrics Worker in a
136+
non-breaking way as the Metrics Worker will be an optional parameter
137137
at customer facing API call sites.
138138

139139
Currently, the ESDK client APIs models are defined [here](https://github.com/aws/aws-encryption-sdk/blob/mainline/AwsEncryptionSDK/dafny/AwsEncryptionSdk/Model/esdk.smithy#L60-L126).
@@ -154,7 +154,7 @@ structure EncryptInput {
154154

155155
frameLength: FrameLength,
156156

157-
+ metricsAgent: aws.cryptography.materialProviders#MetricsAgentReference
157+
+ metricsWorker: aws.cryptography.materialProviders#MetricsWorkerReference
158158
}
159159
...
160160
structure DecryptInput {
@@ -171,21 +171,50 @@ structure DecryptInput {
171171
//# - [Encryption Context](#encryption-context)
172172
encryptionContext: aws.cryptography.materialProviders#EncryptionContext,
173173

174-
+ metricsAgent: aws.cryptography.materialProviders#MetricsAgentReference
174+
+ metricsWorker: aws.cryptography.materialProviders#MetricsWorkerReference
175175
}
176176
```
177177

178178
## Issues and Alternatives
179179

180-
### Issue 0: Should Metric Agents be supported on client construction?
180+
### Issue 0: Should Metrics Workers be supported on client construction?
181+
182+
This options assumes that a Metrics Worker on client instantiation
183+
is optional. Making the Metrics Worker required would face pushback
184+
and overall losses customer trust.
181185

182186
#### Yes
183187

184-
#### No
188+
Set it and forget it. This would make it easy for our customers to only have
189+
to supply their metrics workers in one place rather than to reason about which
190+
operations should get metrics. Additionally, this option would be a blanket
191+
over the entire CT stack and output all metrics the library tracks.
192+
193+
This option also gives customers a very nice integration point of always capture
194+
metrics to this one worker and to only sometimes capture metrics to this
195+
other worker.
196+
197+
#### No (recommended)
198+
199+
Since this would be an optional argument to the client, adding the option
200+
in a separate minor release is a two-way door. Even if at launch CT decides
201+
to add the optional argument later on to remove the option would be a one-way
202+
door since customers who use the optional feature would get build errors.
203+
204+
As CT learns from its customers, more and more
205+
of them seems to prefer or rather are forced to do request overrides for
206+
specific requests.
207+
208+
Additionally, there is nuanced behavior that CT would need to decide to determine
209+
the appropriate behavior when a client is configured with a metrics worker and
210+
supplied with a metrics worker at the API call site.
211+
CT would need to settle on this behavior regardless of making it optional, but it
212+
allows CT to get metrics into the hands of customers much faster.
185213

186214
## Appendix
187215

188-
The following API changes are not complete. These changes assume that the new optional parameter is supplied to any additional downstream consumer that may or may not be listed here.
216+
The following API changes are not complete. These changes assume that the new optional parameter
217+
is supplied to any additional downstream consumer that may or may not be listed here.
189218

190219
### MPL
191220

@@ -231,7 +260,7 @@ structure GetEncryptionMaterialsInput {
231260

232261
requiredEncryptionContextKeys: EncryptionContextKeys,
233262

234-
+ metricsAgent: aws.cryptography.materialProviders#MetricsAgentReference
263+
+ metricsWorker: aws.cryptography.materialProviders#MetricsWorkerReference
235264
}
236265
...
237266
structure DecryptMaterialsInput {
@@ -265,7 +294,7 @@ structure DecryptMaterialsInput {
265294

266295
reproducedEncryptionContext: EncryptionContext,
267296

268-
+ metricsAgent: aws.cryptography.materialProviders#MetricsAgentReference
297+
+ metricsWorker: aws.cryptography.materialProviders#MetricsWorkerReference
269298
}
270299
```
271300

@@ -306,7 +335,7 @@ structure OnEncryptInput {
306335
@required
307336
materials: EncryptionMaterials,
308337

309-
+ metricsAgent: aws.cryptography.materialProviders#MetricsAgentReference
338+
+ metricsWorker: aws.cryptography.materialProviders#MetricsWorkerReference
310339
}
311340

312341
structure OnEncryptOutput {
@@ -330,7 +359,7 @@ structure OnDecryptInput {
330359
@required
331360
encryptedDataKeys: EncryptedDataKeyList,
332361

333-
+ metricsAgent: aws.cryptography.materialProviders#MetricsAgentReference
362+
+ metricsWorker: aws.cryptography.materialProviders#MetricsWorkerReference
334363
}
335364

336365
structure OnDecryptOutput {
@@ -355,10 +384,10 @@ public PutObjectResponse putObject(PutObjectRequest putObjectRequest, RequestBod
355384
...
356385
}
357386

358-
+ public PutObjectResponse putObject(PutObjectRequest putObjectRequest, RequestBody requestBody, IMetricsAgent metricsAgent)
387+
+ public PutObjectResponse putObject(PutObjectRequest putObjectRequest, RequestBody requestBody, IMetricsWorker metricsWorker)
359388
+ throws AwsServiceException, SdkClientException {
360389
+ ...
361-
+ ## Pass the IMetricsAgent reference to the appropriate downstream consumers
390+
+ ## Pass the IMetricsWorker reference to the appropriate downstream consumers
362391
+}
363392
...
364393

@@ -371,10 +400,10 @@ public <T> T getObject(GetObjectRequest getObjectRequest,
371400

372401
+public <T> T getObject(GetObjectRequest getObjectRequest,
373402
+ ResponseTransformer<GetObjectResponse, T> responseTransformer,
374-
+ IMetricsAgent metricsAgent)
403+
+ IMetricsWorker metricsWorker)
375404
+ throws AwsServiceException, SdkClientException {
376405
+ ...
377-
+ ## Pass the IMetricsAgent reference to the appropriate downstream consumers
406+
+ ## Pass the IMetricsWorker reference to the appropriate downstream consumers
378407
+}
379408
```
380409

@@ -390,7 +419,7 @@ public class GetEncryptedObjectPipeline {
390419
private final long _bufferSize;
391420
private final InstructionFileConfig _instructionFileConfig;
392421
private final CommitmentPolicy _commitmentPolicy;
393-
+ private final IMetricsAgent _metricsAgent;
422+
+ private final IMetricsWorker _metricsWorker;
394423

395424
public static Builder builder() {
396425
return new Builder();
@@ -404,7 +433,7 @@ public class GetEncryptedObjectPipeline {
404433
this._bufferSize = builder._bufferSize;
405434
this._instructionFileConfig = builder._instructionFileConfig;
406435
this._commitmentPolicy = builder._commitmentPolicy;
407-
+ this._metricsAgent = builder._metricsAgentl
436+
+ this._metricsWorker = builder._metricsWorkerl
408437
}
409438
...
410439
}
@@ -420,7 +449,7 @@ public class PutEncryptedObjectPipeline {
420449
final private AsyncContentEncryptionStrategy _asyncContentEncryptionStrategy;
421450
final private ContentMetadataEncodingStrategy _contentMetadataEncodingStrategy;
422451
final private AlgorithmSuite _encryptionAlgorithm;
423-
+ final private IMetricsAgent _metricsAgent;
452+
+ final private IMetricsWorker _metricsWorker;
424453

425454
public static Builder builder() {
426455
return new Builder();
@@ -432,7 +461,7 @@ public class PutEncryptedObjectPipeline {
432461
this._asyncContentEncryptionStrategy = builder._asyncContentEncryptionStrategy;
433462
this._contentMetadataEncodingStrategy = builder._contentMetadataEncodingStrategy;
434463
this._encryptionAlgorithm = builder._encryptionAlgorithm;
435-
+ this._metricsAgent = builder._metricsAgent;
464+
+ this._metricsWorker = builder._metricsWorker;
436465
}
437466
...
438467
}
@@ -446,9 +475,9 @@ package software.amazon.encryption.s3.materials;
446475
import java.util.List;
447476
public interface Keyring {
448477
EncryptionMaterials onEncrypt(final EncryptionMaterials materials);
449-
+ EncryptionMaterials onEncrypt(final EncryptionMaterials materials, final IMetricsAgent metricsAgent);
478+
+ EncryptionMaterials onEncrypt(final EncryptionMaterials materials, final IMetricsWorker metricsWorker);
450479
DecryptionMaterials onDecrypt(final DecryptionMaterials materials, final List<EncryptedDataKey> encryptedDataKeys);
451-
+ DecryptionMaterials onDecrypt(final DecryptionMaterials materials, final List<EncryptedDataKey> encryptedDataKeys, final IMetricsAgent metricsAgent);
480+
+ DecryptionMaterials onDecrypt(final DecryptionMaterials materials, final List<EncryptedDataKey> encryptedDataKeys, final IMetricsWorker metricsWorker);
452481
}
453482
```
454483

@@ -459,8 +488,8 @@ package software.amazon.encryption.s3.materials;
459488

460489
public interface CryptographicMaterialsManager {
461490
EncryptionMaterials getEncryptionMaterials(EncryptionMaterialsRequest request);
462-
+ EncryptionMaterials getEncryptionMaterials(EncryptionMaterialsRequest request, IMetricsAgent metricsAgent);
491+
+ EncryptionMaterials getEncryptionMaterials(EncryptionMaterialsRequest request, IMetricsWorker metricsWorker);
463492
DecryptionMaterials decryptMaterials(DecryptMaterialsRequest request);
464-
+ DecryptionMaterials decryptMaterials(DecryptMaterialsRequest request, IMetricsAgent metricsAgent);
493+
+ DecryptionMaterials decryptMaterials(DecryptMaterialsRequest request, IMetricsWorker metricsWorker);
465494
}
466495
```
Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[//]: # "Copyright Amazon.com Inc. or its affiliates. All Rights Reserved."
22
[//]: # "SPDX-License-Identifier: CC-BY-SA-4.0"
33

4-
# Metrics Agent Interface
4+
# Metrics Worker Interface
55

66
_NOTE: Still in draft but in a state to receive feedback on 9-15-2025_
77

@@ -24,10 +24,10 @@ _NOTE: Still in draft but in a state to receive feedback on 9-15-2025_
2424

2525
## Overview
2626

27-
The Metrics Agent defines defines operations that allow messages
27+
The Metrics Worker defines defines operations that allow messages
2828
to be published to a destination.
29-
The Metrics Agent interface describes the interface that all
30-
Metrics Agents MUST implement.
29+
The Metrics Worker interface describes the interface that all
30+
Metrics Workers MUST implement.
3131

3232
## Definitions
3333

@@ -41,19 +41,21 @@ in this document are to be interpreted as described in [RFC 2119](https://tools.
4141
A label is a string that is used
4242
as an attribute name to aggregate
4343
measurements. A label can be used to
44-
add a dimension to the Metrics Agent
44+
add a dimension to the Metrics Worker
4545

4646
### date
4747

4848
A date is a value in milliseconds since epoch.
4949

5050
### duration
5151

52-
A duration is a value in milliseconds
52+
A duration is an enum value union with valid
53+
options being seconds, minutes, milliseconds,
54+
or hours.
5355

5456
### count
5557

56-
A count is an Long value
58+
A count is a long value
5759

5860
### value
5961

@@ -66,15 +68,15 @@ A transactionId is a string that
6668
is used to coalasce multiple metric requests
6769
for a given client request.
6870

69-
## Supported Metrics Agents
71+
## Supported Metrics Workers
7072

71-
Note: A user MAY create their own custom Metrics Agent.
73+
Note: A user MAY create their own custom Metrics Worker.
7274

7375
## Interface
7476

7577
### Inputs
7678

77-
The inputs to the MetricsAgent are groups of related fields, referred to as:
79+
The inputs to the MetricsWorker are groups of related fields, referred to as:
7880

7981
- [AddDate Input](#adddate-input)
8082
- [AddTime Input](#addtime-input)
@@ -135,7 +137,7 @@ The add property input MAY include the following:
135137

136138
### Behaviors
137139

138-
The MetricsAgent Interface MUST support the following behaviors:
140+
The MetricsWorker Interface MUST support the following behaviors:
139141

140142
- [AddDate](#adddate)
141143
- [AddTime](#addtime)
@@ -164,7 +166,7 @@ Used to add context/metadata in the form of a key-value pair related to a Metric
164166
use aws.polymorph#extendable
165167
166168
@extendable
167-
resource MetricsAgent {
169+
resource MetricsWorker {
168170
operations: [
169171
AddDate,
170172
AddTime,
@@ -237,7 +239,6 @@ structure AddPropertyInput {
237239
// Common output structure
238240
structure AddOutput {}
239241
240-
@aws.polymorph#reference(resource: MetricsAgent)
241-
structure MetricsAgentReference {}
242-
242+
@aws.polymorph#reference(resource: MetricsWorker)
243+
structure MetricsWorkerReference {}
243244
```

0 commit comments

Comments
 (0)