Skip to content

Commit

Permalink
Allow metadata to configure precise timestamps
Browse files Browse the repository at this point in the history
  • Loading branch information
badboy committed Jul 12, 2023
1 parent 91d4c81 commit 1053036
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 1 deletion.
2 changes: 2 additions & 0 deletions glean_parser/pings.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def __init__(
if metadata is None:
metadata = {}
self.metadata = metadata
self.precise_timestamps = self.metadata.get("precise_timestamps", True)
if data_reviews is None:
data_reviews = []
self.data_reviews = data_reviews
Expand Down Expand Up @@ -88,6 +89,7 @@ def serialize(self) -> Dict[str, util.JSONType]:
def _serialize_input(self) -> Dict[str, util.JSONType]:
d = self.serialize()
modified_dict = util.remove_output_params(d, "defined_in")
modified_dict = util.remove_output_params(modified_dict, "precise_timestamps")
return modified_dict

def identifier(self) -> str:
Expand Down
9 changes: 9 additions & 0 deletions glean_parser/schemas/pings.2-0-0.schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,15 @@ additionalProperties:
items:
type: string
maxLength: 80
precise_timestamps:
title: Precise Timestamps
description: |
When `true` Glean uses millisecond-precise timestamps for
the ping's start/end time (the default).
When `false` Glean uses minute-precise timestamps for
the ping's start/end time.
type: boolean

default: {}

include_client_id:
Expand Down
2 changes: 1 addition & 1 deletion glean_parser/templates/rust.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ impl ExtraKeys for {{ obj.name|Camelize }}{{ suffix }} {
/// {{ obj.description|wordwrap() | replace('\n', '\n/// ') }}
#[rustfmt::skip]
pub static {{ obj.name|snake_case }}: ::glean::private::__export::Lazy<::glean::private::PingType> =
::glean::private::__export::Lazy::new(|| ::glean::private::PingType::new("{{ obj.name }}", {{ obj.include_client_id|rust }}, {{ obj.send_if_empty|rust }}, {{ obj.reason_codes|rust }}));
::glean::private::__export::Lazy::new(|| ::glean::private::PingType::new("{{ obj.name }}", {{ obj.include_client_id|rust }}, {{ obj.send_if_empty|rust }}, {{ obj.precise_timestamps|rust }}, {{ obj.reason_codes|rust }}));
{% endfor %}
{% else %}
pub mod {{ category.name|snake_case }} {
Expand Down
1 change: 1 addition & 0 deletions glean_parser/templates/swift.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ extension {{ namespace }} {
name: {{ obj.name|swift }},
includeClientId: {{obj.include_client_id|swift}},
sendIfEmpty: {{obj.send_if_empty|swift}},
preciseTimestamps: {{obj.precise_timestamps|swift}},
reasonCodes: {{obj.reason_codes|swift}}
)

Expand Down
1 change: 1 addition & 0 deletions glean_parser/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,7 @@ def remove_output_params(d, output_params):
"name",
"include_client_id",
"send_if_empty",
"precise_timestamps",
"reason_codes",
]

Expand Down

0 comments on commit 1053036

Please # to comment.