Closed Bug 2052175 Opened 2 months ago Closed 2 months ago

Ensure reproducibility with metric date expires by using SOURCE_DATE_EPOCH when set

Categories

(Data Platform and Tools :: Glean: SDK, enhancement, P1)

enhancement

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: pierov, Assigned: janerik)

References

Details

Attachments

(1 file)

glean_parser checks if a metric is expired at build time by comparing its expires with datetime.datetime.now() in glean_parser/util.py.
This contributes to break the reproducibility of the builds.
It would be nice to be able to set an environment variable like SOURCE_DATE_EPOCH and use it instead of now when defined.
This would be helpful for us downstream at The Tor Project ☺️.

All metrics in the Firefox source tree should check expiry against a version number, not against the date.
Can you point out where in the current build that breaks?

Regardless the problem might still be worth fixing for other code.

Flags: needinfo?(pierov)

I found the problem in Glean 67.3.1.
glean-core/metrics.yaml there contains:

  event_timestamp_clamped:
    type: counter
    description: |
      The number of times we had to clamp an event timestamp
      for exceeding the range of a signed 64-bit integer (9223372036854775807).
    send_in_pings:
      - health
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1873482
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1873482
    data_sensitivity:
      - technical
    notification_emails:
      - glean-team@mozilla.com
      - jrediger@mozilla.com
    expires: 2026-06-30

In the glean-67.3.1-sources.jar file that is generated, I can see GleanError.kt:

/*
 * AUTOGENERATED BY glean_parser v19.0.0. DO NOT EDIT. DO NOT COMMIT.
 */

// ...

    @get:JvmName("eventTimestampClamped")
    val eventTimestampClamped: CounterMetricType by lazy { // generated from glean.error.event_timestamp_clamped
        CounterMetricType(
            CommonMetricData(
                category = "glean.error",
                name = "event_timestamp_clamped",
                sendInPings = listOf("health"),
                lifetime = Lifetime.PING,
                disabled = false
            ))
    }

I built it before yesterday, and I got disabled = false. But a colleague of mine who built yesterday got disabled = true, and that ended up in the final APKs.

Flags: needinfo?(pierov)

Ah, yes. That's in Glean itself, so that of course breaks when building Glean from source at a later point (we should probably switch that to version expiry too).
Supporting SOURCE_DATE_EPOCH should be possible.

Summary: glean_parser breaks build reproducibility → Ensure reproducibility with metric date expires by using SOURCE_DATE_EPOCH when set
Assignee: nobody → jrediger
Status: NEW → ASSIGNED
Priority: P3 → P1
Whiteboard: [telemetry:glean-rs:m?]
Status: ASSIGNED → RESOLVED
Closed: 2 months ago
Resolution: --- → FIXED
Blocks: 2055168
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: