Skip to content

Commit 46a89fe

Browse files
committed
telemetry(vscode): MetricBase.requestId
Problem: In the generated `telemetry.gen.ts` for vscode toolkit, `MetricBase` does not have various common fields. This adds friction when setting these fields. Solution: - Align commonMetadata with VS (see `BaseTelemetryEvent.cs`) - Except `causedBy` and `errorCode`, because their purpose is still TBD: - `errorCode` seems redundant with `reason` - `causedBy` is a high-level category which possibly could be decided by `hasFault` in vscode toolkit: https://github.com/aws/aws-toolkit-vscode/blob/6300d520ac347b7596d98c7cec312b67f98ee528/packages/core/src/shared/errors.ts#L519
1 parent 70f193a commit 46a89fe

File tree

5 files changed

+101
-32
lines changed

5 files changed

+101
-32
lines changed

telemetry/definitions/commonDefinitions.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@
130130
{
131131
"name": "awsAccount",
132132
"type": "string",
133-
"description": "AWS account ID associated with a metric. \"n/a\" if credentials are not available. \"not-set\" if credentials are not selected. \"invalid\" if account ID cannot be obtained."
133+
"description": "AWS account ID associated with a metric.\n- \"n/a\" if credentials are not available.\n- \"not-set\" if credentials are not selected.\n- \"invalid\" if account ID cannot be obtained."
134134
},
135135
{
136136
"name": "awsFiletype",
@@ -155,7 +155,7 @@
155155
{
156156
"name": "awsRegion",
157157
"type": "string",
158-
"description": "AWS Region associated with a metric"
158+
"description": "AWS Region associated with a metric\n- \"n/a\" if not associated with a region.\n- \"not-set\" if metric is associated with a region, but region is unknown."
159159
},
160160
{
161161
"name": "causedBy",
@@ -1133,7 +1133,7 @@
11331133
{
11341134
"name": "httpStatusCode",
11351135
"type": "string",
1136-
"description": "Describes the HTTP status code for request made. The semantics are contextual based off of other fields (e.g. `requestId`)"
1136+
"description": "HTTP status code for the request (if any) associated with a metric."
11371137
},
11381138
{
11391139
"name": "iamResourceType",
@@ -1303,7 +1303,7 @@
13031303
{
13041304
"name": "requestId",
13051305
"type": "string",
1306-
"description": "A generic request ID field. The semantics are contextual based off of other fields (e.g. `requestServiceType`). For example, an event with `requestServiceType: s3` means that the request ID is associated with an S3 API call. Events that cover mutliple API calls should use the request ID of the most recent call."
1306+
"description": "Request ID (if any) associated with a metric. For example, an event with `requestServiceType: s3` means that the request ID is associated with an S3 API call. Events that cover multiple API calls should use the request ID of the most recent call."
13071307
},
13081308
{
13091309
"name": "requestServiceType",

telemetry/telemetryformat.md

Lines changed: 38 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -48,24 +48,47 @@ These are then used to generate functions that take arguments pertaining to metr
4848

4949
### Global Arguments
5050

51-
Global arguments that can be appended to any generated telemetry call.
51+
Global properties that can annotate any telemetry event.
5252

53-
```
53+
```javascript
5454
// The time that the event took place
55-
createTime?: Date
56-
// Value based on unit and call type
57-
value?: number
55+
createTime: Date
56+
// AWS account ID associated with a metric.
57+
// - "n/a" if credentials are not available.
58+
// - "not-set" if credentials are not selected.
59+
// - "invalid" if account ID cannot be obtained.
60+
awsAccount: string
61+
// AWS Region associated with a metric.
62+
// - "n/a" if not associated with a region.
63+
// - "not-set" if metric is associated with a region, but region is unknown.
64+
awsRegion: string
65+
// The duration of the operation in milliseconds.
66+
duration: number
67+
// HTTP status code for the request (if any) associated with a metric.
68+
httpStatusCode: string
5869
// The language-related user preference information. Examples: en-US, en-GB, etc.
59-
string?: locale
60-
// The AWS account ID associated with a metric
61-
// If a metric is not associated with credentials: "n/a"
62-
// If a metric is associated with credentials, but credentials are not selected: "not-set"
63-
// If a metric is associated with credentials, but an account ID cannot be obtained: "invalid"
64-
string? awsAccount
65-
// The AWS Region associated with a metric
66-
// If a metric is not associated with a region: "n/a"
67-
// If a metric is associated with a region, but no region is known: "not-set"
68-
string? awsRegion
70+
locale: string
71+
// Reason code or name for an event (when result=Succeeded) or error (when result=Failed).
72+
// Unlike the `reasonDesc` field, this should be a stable/predictable name for
73+
// a class of events or errors (typically the exception name, e.g. FileIOException).
74+
reason: string
75+
// Error message detail. May contain arbitrary message details (unlike the
76+
// `reason` field), but should be truncated (recommendation: 200 chars).
77+
reasonDesc: string
78+
// Request ID (if any) associated with a metric.
79+
// For example, an event with `requestServiceType: s3` means that the request ID
80+
// is associated with an S3 API call. Events that cover mutliple API calls
81+
// should use the request ID of the most recent call.
82+
requestId: string
83+
// Per-request service identifier. Unlike `serviceType` (which describes the
84+
// originator of the request), this describes the request itself.
85+
requestServiceType: string
86+
// The result of the operation.
87+
result: Result
88+
// Indicates that the metric was not caused by an explicit user action.
89+
passive: boolean
90+
// Value based on unit and call type
91+
value: number
6992
```
7093

7194
If not specified `createTime` defaults to UTC now, `value` defaults to `1.0`.

telemetry/vscode/src/generate.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,19 @@ function getTypeOrThrow(types: MetadataType[] = [], name: string) {
121121
}
122122

123123
const baseName = 'MetricBase'
124-
const commonMetadata = ['result', 'reason', 'reasonDesc', 'duration', 'awsRegion']
124+
125+
const commonMetadata = [
126+
'awsAccount',
127+
'awsRegion',
128+
'duration',
129+
'httpStatusCode',
130+
'reason',
131+
'reasonDesc',
132+
'requestId',
133+
'requestServiceType',
134+
'result',
135+
]
136+
125137
const passive: PropertySignatureStructure = {
126138
isReadonly: true,
127139
hasQuestionToken: true,

telemetry/vscode/test/resources/generatorOutput.ts

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,33 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55
export interface MetricBase {
6-
/** The result of the operation */
7-
readonly result?: Result
6+
/**
7+
* AWS account ID associated with a metric.
8+
* - "n/a" if credentials are not available.
9+
* - "not-set" if credentials are not selected.
10+
* - "invalid" if account ID cannot be obtained.
11+
*/
12+
readonly awsAccount?: string
13+
/**
14+
* AWS Region associated with a metric
15+
* - "n/a" if not associated with a region.
16+
* - "not-set" if metric is associated with a region, but region is unknown.
17+
*/
18+
readonly awsRegion?: string
19+
/** The duration of the operation in milliseconds */
20+
readonly duration?: number
21+
/** HTTP status code for the request (if any) associated with a metric. */
22+
readonly httpStatusCode?: string
823
/** Reason code or name for an event (when result=Succeeded) or error (when result=Failed). Unlike the `reasonDesc` field, this should be a stable/predictable name for a class of events or errors (typically the exception name, e.g. FileIOException). */
924
readonly reason?: string
1025
/** Error message detail. May contain arbitrary message details (unlike the `reason` field), but should be truncated (recommendation: 200 chars). */
1126
readonly reasonDesc?: string
12-
/** The duration of the operation in milliseconds */
13-
readonly duration?: number
14-
/** AWS Region associated with a metric */
15-
readonly awsRegion?: string
27+
/** Request ID (if any) associated with a metric. For example, an event with `requestServiceType: s3` means that the request ID is associated with an S3 API call. Events that cover multiple API calls should use the request ID of the most recent call. */
28+
readonly requestId?: string
29+
/** Per-request service identifier. Unlike `serviceType` (which describes the originator of the request), this describes the request itself. */
30+
readonly requestServiceType?: string
31+
/** The result of the operation */
32+
readonly result?: Result
1633
/** A flag indicating that the metric was not caused by the user. */
1734
readonly passive?: boolean
1835
/** @deprecated Arbitrary "value" of the metric. */

telemetry/vscode/test/resources/generatorOverrideOutput.ts

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,33 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55
export interface MetricBase {
6-
/** The result of the operation */
7-
readonly result?: Result
6+
/**
7+
* AWS account ID associated with a metric.
8+
* - "n/a" if credentials are not available.
9+
* - "not-set" if credentials are not selected.
10+
* - "invalid" if account ID cannot be obtained.
11+
*/
12+
readonly awsAccount?: string
13+
/**
14+
* AWS Region associated with a metric
15+
* - "n/a" if not associated with a region.
16+
* - "not-set" if metric is associated with a region, but region is unknown.
17+
*/
18+
readonly awsRegion?: string
19+
/** The duration of the operation in milliseconds */
20+
readonly duration?: number
21+
/** HTTP status code for the request (if any) associated with a metric. */
22+
readonly httpStatusCode?: string
823
/** Reason code or name for an event (when result=Succeeded) or error (when result=Failed). Unlike the `reasonDesc` field, this should be a stable/predictable name for a class of events or errors (typically the exception name, e.g. FileIOException). */
924
readonly reason?: string
1025
/** Error message detail. May contain arbitrary message details (unlike the `reason` field), but should be truncated (recommendation: 200 chars). */
1126
readonly reasonDesc?: string
12-
/** The duration of the operation in milliseconds */
13-
readonly duration?: number
14-
/** AWS Region associated with a metric */
15-
readonly awsRegion?: string
27+
/** Request ID (if any) associated with a metric. For example, an event with `requestServiceType: s3` means that the request ID is associated with an S3 API call. Events that cover multiple API calls should use the request ID of the most recent call. */
28+
readonly requestId?: string
29+
/** Per-request service identifier. Unlike `serviceType` (which describes the originator of the request), this describes the request itself. */
30+
readonly requestServiceType?: string
31+
/** The result of the operation */
32+
readonly result?: Result
1633
/** A flag indicating that the metric was not caused by the user. */
1734
readonly passive?: boolean
1835
/** @deprecated Arbitrary "value" of the metric. */

0 commit comments

Comments
 (0)