You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In Javascript, there is no way to easily determine if a number is an integer or a float, as JS numbers are [floats](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number). This makes `value: Int!` hard to use, because there is no way to ask callers to provide metadata in integer values only. To support clients (typically in JS/TS) well, we need to accept `value: Float!` - however, this is a breaking change:
```
In element #0: In field "parameters": In field "metadata": In element #1: In field "value": Expected type "Float", found 0. (line 3, column 28)
```
To make this change smoothly, we accept `value: JSONValue` in the GraphQL input and validate that it is a numeric value in the backend - this allows clients to provide both integers and floats.
For events export, the change is simpler - we add a new field `metadata = 5`, and mark the existing metadata field as deprecated (`legacy_metadata`). In proto, only the field index matters, so the rename is safe, and ensures there is no disruption for data going to BigQuery, since we can continue to use `metadata` as the JSON field and simply drop `legacy_metadata` entirely.
For existing clients, out-of-band telemetry clients (namely Cody) will need to be updated to round values to integers unless interacting with a more recent Sourcegraph version, e.g. sourcegraph/cody#1913 (comment)
## Test plan
- Unit tests validating GraphQL schema works as expected, including back-compat
- Unit tests on telemetry gateway field migration
- Eixsting tests
| version |[int32](#int32)|| <p>Version of the event parameters, used for indicating the "shape" of this</p><p>event's metadata, beginning at 0. Useful for denoting if the shape of</p><p>metadata has changed in any way.</p> |
189
+
| legacy_metadata |[EventParameters.LegacyMetadataEntry](#telemetrygateway-v1-EventParameters-LegacyMetadataEntry)| repeated | <p>Legacy metadata format that only accepted int64 - use the new metadata</p><p>field instead, which accepts float values. Values sent through this proto</p><p>field will be merged into the new metadata attributes.</p><p>We don't use a [deprecated = true] tag because we use this field to handle</p><p>accepting exporters sending metadata in this format.</p> |
188
190
| metadata |[EventParameters.MetadataEntry](#telemetrygateway-v1-EventParameters-MetadataEntry)| repeated | <p>Strictly typed metadata, restricted to integer values to avoid accidentally</p><p>exporting sensitive or private data.</p> |
189
191
| private_metadata |[google.protobuf.Struct](#google-protobuf-Struct)| optional | <p>Additional potentially sensitive metadata - i.e. not restricted to integer</p><p>values.</p><p>🚨 SECURITY: This metadata is NOT exported from instances by default, as it</p><p>can contain arbitrarily-shaped data that may accidentally contain sensitive</p><p>or private contents.</p><p>This metadata is only exported on an allowlist basis based on terms of</p><p>use agreements and combinations of event feature and action, alongside</p><p>careful audit of callsites.</p> |
0 commit comments