Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug 1820611 - Document string list behavior with empty lists #2420

Merged
merged 3 commits into from
Mar 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions docs/dev/core/internal/payload.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,18 @@ A [String](../../../book/reference/metrics/string.md) is represented by its stri

A [String List](../../../book/reference/metrics/string_list.md) is represented as an array of strings.

#### Example

```json
["sample string", "another one"]
```

An empty list is accepted and send as one:
badboy marked this conversation as resolved.
Show resolved Hide resolved

```json
[]
```

### Timespan

A [Timespan](../../../book/reference/metrics/timespan.md) is represented as an object of their duration as an integer and the time unit.
Expand Down Expand Up @@ -288,3 +296,13 @@ A [Rate](../../../book/reference/metrics/rate.md) is represented by its `numerat
"denominator": 7,
}
```

### Text

A [Text](../../../book/reference/metrics/text.md) is represented by its string value.

#### Example

```json
"sample string"
```
8 changes: 4 additions & 4 deletions docs/user/reference/metrics/string.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,15 @@ Glean.searchDefault.name.set("wikipedia");

{{#include ../../../shared/tab_footer.md}}

#### Limits

* Fixed maximum string length: 100. Longer strings are truncated. This is measured in the number of bytes when the string is encoded in UTF-8.

#### Recorded errors

* [`invalid_overflow`](../../user/metrics/error-reporting.md): if the string is too long. (Prior to Glean 31.5.0, this recorded an `invalid_value`).
* [`invalid_type`](../../user/metrics/error-reporting.md): if a non-string value is given.

#### Limits

* Fixed maximum string length: 100. Longer strings are truncated. This is measured in the number of bytes when the string is encoded in UTF-8.

## Testing API

### `testGetValue`
Expand Down
5 changes: 3 additions & 2 deletions docs/user/reference/metrics/string_list.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ Glean.search.engines.add("duck duck go");
### `set`

Set the metric to a specific list of strings.
An empty list is accepted.

{{#include ../../../shared/tab_header.md}}
<div data-lang="Kotlin" class="tab">
Expand Down Expand Up @@ -181,8 +182,8 @@ Glean.search.engines.set(["wikipedia", "duck duck go"]);

#### Recorded errors

* `invalid_overflow`: if the string is too long. (Prior to Glean 31.5.0, this recorded an `invalid_value`).
* `invalid_value`: if the list is too long.
* [`invalid_overflow`](../../user/metrics/error-reporting.md): if any string in the list is too long, see [Limits](#limits-1) below. (Prior to Glean 31.5.0, this recorded an `invalid_value`).
* [`invalid_value`](../../user/metrics/error-reporting.md): if the list is too long, see [Limits](#limits-1) below.
* [`invalid_type`](../../user/metrics/error-reporting.md): if a non-string array is given.

#### Limits
Expand Down
4 changes: 4 additions & 0 deletions glean-core/rlb/tests/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ fn validate_against_schema() {
stringlist_metric.add("one".into());
stringlist_metric.add("two".into());

// Let's make sure an empty array is accepted.
let stringlist_metric2 = StringListMetric::new(common("stringlist2"));
stringlist_metric2.set(vec![]);

let timespan_metric = TimespanMetric::new(common("timespan"), TimeUnit::Nanosecond);
timespan_metric.start();
timespan_metric.stop();
Expand Down