Skip to content
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
3 changes: 2 additions & 1 deletion .dictionary
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
personal_ws-1.1 en 303 utf-8
personal_ws-1.1 en 304 utf-8
AAR
AARs
ABI
Expand Down Expand Up @@ -264,6 +264,7 @@ subpath
subprocess
subprocesses
substring
subtypes
swiftlint
tcsh
templating
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@

* General
* BREAKING: Remove infill 0 buckets from custom distributions ([#3246](https://github.com/mozilla/glean/pull/3246))
* Add a new `oneOf` type to Glean's object metric type structure ([#3273](https://github.com/mozilla/glean/pull/3273))
* Rust
* Use an associated type for `TestGetValue` ([#3259](https://github.com/mozilla/glean/pull/3259))
* Swift
* Make `EventMetricType`, `ObjectMetricType`, `URLMetricType` and `Ping` `Sendable` ([#3255](https://github.com/mozilla/glean/pull/3255))
* Glean for iOS is now being built with Xcode 16.4 ([#3270](https://github.com/mozilla/glean/pull/3270))
* Updated to `glean_parser` v18.0.0 ([#3273](https://github.com/mozilla/glean/pull/3273))

# v65.2.2 (2025-10-02)

Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ docs-python: build-python ## Build the Python documentation
.PHONY: docs docs-rust docs-swift

docs-metrics: setup-python ## Build the internal metrics documentation
$(GLEAN_PYENV)/bin/pip install glean_parser~=17.2
$(GLEAN_PYENV)/bin/pip install glean_parser~=18.0
$(GLEAN_PYENV)/bin/glean_parser translate --allow-reserved \
-f markdown \
-o ./docs/user/user/collected-metrics \
Expand Down
3 changes: 3 additions & 0 deletions docs/user/reference/metrics/object.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ The allowed types are:
* `boolean`
* `array`
* `object`
* `oneOf`

The `array` type takes an `items` parameter, that does define the element types it can hold.
The `object` type takes a `properties` parameter, that defines the nested object structure.
Expand All @@ -226,6 +227,8 @@ The `object` type takes a `properties` parameter, that defines the nested object
No other schema parameters are allowed.
All fields are optional.

`oneOf` requires a list of allowed subtypes. The available types are `[string, number, boolean]`.

Data is validated against this schema at recording time.
Missing values will not be serialized into the payload.

Expand Down
2 changes: 1 addition & 1 deletion glean-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ include = [
rust-version = "1.82"

[package.metadata.glean]
glean-parser = "17.2.0"
glean-parser = "18.0.1"

[badges]
circle-ci = { repository = "mozilla/glean", branch = "main" }
Expand Down
2 changes: 1 addition & 1 deletion glean-core/build/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "glean-build"
version = "17.2.0"
version = "18.0.1"
edition = "2021"
description = "Glean SDK Rust build helper"
repository = "https://github.com/mozilla/glean"
Expand Down
2 changes: 1 addition & 1 deletion glean-core/build/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ use std::{env, path::PathBuf};

use xshell_venv::{Result, Shell, VirtualEnv};

const GLEAN_PARSER_VERSION: &str = "17.2.0";
const GLEAN_PARSER_VERSION: &str = "18.0.1";

/// A Glean Rust bindings generator.
pub struct Builder {
Expand Down
2 changes: 1 addition & 1 deletion glean-core/ios/sdk_generator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

set -e

GLEAN_PARSER_VERSION=17.2
GLEAN_PARSER_VERSION=18.0

# CMDNAME is used in the usage text below.
# shellcheck disable=SC2034
Expand Down
2 changes: 1 addition & 1 deletion glean-core/python/glean/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
__email__ = "[email protected]"


GLEAN_PARSER_VERSION = "17.2.0"
GLEAN_PARSER_VERSION = "18.0.1"
parser_version = VersionInfo.parse(GLEAN_PARSER_VERSION)
parser_version_next_major = parser_version.bump_major()

Expand Down
6 changes: 5 additions & 1 deletion glean-core/python/glean/_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ def _object_factory(
yield (name, newclass)
yield from _object_factory(f"{name}Item", structure["items"])
elif structure["type"] == "object":
fields = [] # list[tuple[str, type, Any]]
fields: List[Tuple[str, Any, Any]] = []
for itemname, val in structure["properties"].items():
if val["type"] == "object":
fct = _object_factory(f"{name}Item{Camelize(itemname)}Object", val)
Expand All @@ -226,6 +226,10 @@ def _object_factory(
yield n, ty
yield from fct
fields.append((itemname, ty, field(default=None)))
elif val["type"] == "oneof":
# TODO(bug 1992726): We don't actually enforce proper validation here.
# We might want to do some runtime checks.
fields.append((itemname, Any, field(default=None)))
else:
fields.append((itemname, _struct_type(val["type"]), field(default=None)))
newclass = make_dataclass(name, fields, bases=(metrics.ObjectSerialize,))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ abstract class GleanMetricsYamlTransform implements TransformAction<TransformPar
@SuppressWarnings("GrPackage")
class GleanPlugin implements Plugin<Project> {
// The version of glean_parser to install from PyPI.
private String GLEAN_PARSER_VERSION = "17.2"
private String GLEAN_PARSER_VERSION = "18.0"
// The version of Miniconda is explicitly specified.
// Miniconda3-4.5.12 is known to not work on Windows.
private String MINICONDA_VERSION = "24.3.0-0"
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ maintainers = [

dependencies = [
"semver>=2.13.0",
"glean_parser~=17.2",
"glean_parser~=18.0",
]

[project.urls]
Expand Down
30 changes: 30 additions & 0 deletions samples/android/app/metrics.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,8 @@ party:
notification_emails:
- [email protected]
expires: never
send_in_pings:
- sample
structure:
type: array
items:
Expand All @@ -218,7 +220,35 @@ party:
data_sensitivity:
- technical
expires: never
send_in_pings:
- sample
structure:
type: array
items:
type: string

chooser:
type: object
description: |
Array of key-value elements
bugs:
- https://bugzilla.mozilla.org/123456789
data_reviews:
- http://example.com/reviews
notification_emails:
- [email protected]
expires: never
send_in_pings:
- sample
structure:
type: array
items:
type: object
properties:
key:
type: string
value:
oneOf:
- type: string
- type: number
- type: boolean
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import org.mozilla.samples.gleancore.GleanMetrics.Pings
import org.mozilla.samples.gleancore.GleanMetrics.Test
import org.mozilla.samples.gleancore.databinding.ActivityMainBinding

// 42 is magic! It's a test value.
@Suppress("MagicNumber")
open class MainActivity : AppCompatActivity() {
private lateinit var binding: ActivityMainBinding
private lateinit var serviceIntent: Intent
Expand Down Expand Up @@ -54,6 +56,13 @@ open class MainActivity : AppCompatActivity() {
balloons.add(Party.BalloonsObjectItem(colour = "green"))
Party.balloons.set(balloons)

val ch = Party.ChooserObject()
var f = Party.ChooserObjectItem(key = "fortytwo", value = Party.ChooserObjectItemValueEnum.Number(42))
ch.add(f)
f = Party.ChooserObjectItem(key = "to-be", value = Party.ChooserObjectItemValueEnum.Boolean(false))
ch.add(f)
Party.chooser.set(ch)

val animals = Party.AnimalsObject()
animals.add("Dog")
animals.add("Cat")
Expand Down
7 changes: 7 additions & 0 deletions samples/ios/app/glean-sample-app/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,13 @@ class ViewController: UIViewController {
animals.append("Cat")
Party.animals.set(animals)

var ch: Party.ChooserObject = []
var f = Party.ChooserObjectItem(key: "fortytwo", value: .number(42))
ch.append(f)
f = Party.ChooserObjectItem(key: "to-be", value: .boolean(false))
ch.append(f)
Party.chooser.set(ch)

// This is referencing the event ping named 'click' from the metrics.yaml file. In
// order to illustrate adding extra information to the event, it is also adding to the
// 'extras' field a dictionary of values. Note that the dictionary keys must be
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ class ViewControllerTest: XCTestCase {
let objects = metrics["object"] as! [String: Any]
let balloons = objects["party.balloons"] as! [Any]
XCTAssertEqual(balloons.count, 2)

let expectedChooser: [[String: AnyHashable]] = [
["key": "fortytwo", "value": 42],
["key": "to-be", "value": false]
]

let chooser = objects["party.chooser"] as! [[String: AnyHashable]]
XCTAssertEqual(expectedChooser, chooser)
}

func testViewControllerInteraction() {
Expand Down
26 changes: 26 additions & 0 deletions samples/ios/app/metrics.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -215,3 +215,29 @@ party:
type: array
items:
type: string

chooser:
type: object
description: |
Array of key-value elements
bugs:
- https://bugzilla.mozilla.org/123456789
data_reviews:
- http://example.com/reviews
notification_emails:
- [email protected]
expires: never
send_in_pings:
- sample
structure:
type: array
items:
type: object
properties:
key:
type: string
value:
oneOf:
- type: string
- type: number
- type: boolean
3 changes: 1 addition & 2 deletions samples/python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
## Development

```
make dev
. .venv/bin/activate
uv sync
```

## Run the sample app
Expand Down
9 changes: 9 additions & 0 deletions samples/python/glean-sample/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@
# Does not throw an exception, but will record an error
metrics.party.balloons.set([])

ch = metrics.party.ChooserObject()
f = metrics.party.ChooserObjectItem(key="fortywo", value=42)
ch.append(f)
f = metrics.party.ChooserObjectItem(key="to-be", value=False)
ch.append(f)
f = metrics.party.ChooserObjectItem(key="to-be", value=["string"])
ch.append(f)
metrics.party.chooser.set(ch)

pings.prototype.submit()

Glean.shutdown()
26 changes: 26 additions & 0 deletions samples/python/metrics.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,29 @@ party:
type: string
diameter:
type: number

chooser:
type: object
description: |
Array of key-value elements
bugs:
- https://bugzilla.mozilla.org/123456789
data_reviews:
- http://example.com/reviews
notification_emails:
- [email protected]
expires: never
send_in_pings:
- prototype
structure:
type: array
items:
type: object
properties:
key:
type: string
value:
oneOf:
- type: string
- type: number
- type: boolean
24 changes: 24 additions & 0 deletions samples/rust/metrics.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,30 @@ party:
items:
type: string

chooser:
type: object
description: |
Array of key-value elements
bugs:
- https://bugzilla.mozilla.org/123456789
data_reviews:
- http://example.com/reviews
notification_emails:
- [email protected]
expires: never
structure:
type: array
items:
type: object
properties:
key:
type: string
value:
oneOf:
- type: string
- type: number
- type: boolean

glean.attribution:
ext:
type: object
Expand Down
24 changes: 24 additions & 0 deletions samples/rust/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,30 @@ fn main() {
]);
glean_metrics::party::balloons.set(balloons);

use glean_metrics::party::{ChooserObject, ChooserObjectItem, ChooserObjectItemValueEnum};
let mut ch = ChooserObject::new();
let it = ChooserObjectItem {
key: Some("fortytwo".to_string()),
value: Some(ChooserObjectItemValueEnum::Number(42)),
};
ch.push(it);
let it = ChooserObjectItem {
key: Some("to-be".to_string()),
value: Some(ChooserObjectItemValueEnum::Boolean(false)),
};
ch.push(it);
glean_metrics::party::chooser.set(ch);

let exp_chooser = serde_json::json!([
{ "key": "fortytwo", "value": 42 },
{ "key": "to-be", "value": false },
]);

assert_eq!(
Some(exp_chooser),
glean_metrics::party::chooser.test_get_value(None)
);

glean_metrics::test_dual_labeled::static_static
.get("key1", "category1")
.add(1);
Expand Down