bug(experimenter): make glean writes to stdout more atomic#13905
Merged
Conversation
Contributor
Author
|
if this works, we should move the change upstream to glean-parser, and revert it here when we pick up the change |
55eeeba to
265d2b2
Compare
relud
commented
Nov 4, 2025
Comment on lines
+17
to
+25
| def emit_record(now: datetime, ping: dict[str, Any]): | ||
| ping_envelope = { | ||
| "Timestamp": now.isoformat(), | ||
| "Logger": "glean", | ||
| "Type": GLEAN_EVENT_MOZLOG_TYPE, | ||
| "Fields": ping, | ||
| } | ||
| ping_envelope_serialized = f"{json.dumps(ping_envelope)}\n" | ||
| stdout.write(ping_envelope_serialized) |
Contributor
Author
There was a problem hiding this comment.
the original method is:
def emit_record(self, now: datetime, ping:dict[str, Any]) -> None:
"""Log the ping to STDOUT.
Applications might want to override this method to use their own logging.
If doing so, make sure to log the ping as JSON, and to include the
`Type: GLEAN_EVENT_MOZLOG_TYPE`."""
ping_envelope = {
"Timestamp": now.isoformat(),
"Logger": "glean",
"Type": GLEAN_EVENT_MOZLOG_TYPE,
"Fields": ping,
}
ping_envelope_serialized = json.dumps(ping_envelope)
print(ping_envelope_serialized)265d2b2 to
4ada34e
Compare
4ada34e to
3a56370
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Because
{ping}{ping}\n\ninstead of{ping}\n{ping}\nand markh suggested this might fix itThis commit
stdout.write(f"{ping}\n")instead ofprint(ping)Fixes #13893