Skip to content
Open
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Unreleased

- Python server: Support optional metrics ([#828](https://github.com/mozilla/glean_parser/pull/828))
- BUGFIX: Correct event timestamp values in server language templates ([#831](https://github.com/mozilla/glean_parser/pull/831))

## 18.2.0

Expand Down
2 changes: 1 addition & 1 deletion glean_parser/templates/go_server.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ func newGleanEvent(category, name string, extra map[string]string) gleanEvent {
return gleanEvent{
Category: category,
Name: name,
Timestamp: time.Now().UnixMilli(),
Timestamp: 0,
Extra: extra,
}
}
Expand Down
2 changes: 1 addition & 1 deletion glean_parser/templates/javascript_server.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ class {{ ping|event_class_name(metrics_by_type) }} {
const now = new Date();
const timestamp = now.toISOString();
{% if 'event' in metrics_by_type %}
event.timestamp = now.getTime();
event.timestamp = 0;
{% endif %}
const eventPayload = {
metrics: {
Expand Down
2 changes: 1 addition & 1 deletion glean_parser/templates/python_server.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class {{ ping|camelize }}ServerEventLogger:
timestamp = now.isoformat()
events = [] if events is None else events
for event in events:
event["timestamp"] = int(1000.0 * now.timestamp()) # Milliseconds since epoch
event["timestamp"] = 0
event_payload = {
"metrics": {
{% for metric_type, metrics in metrics_by_type.items() %}
Expand Down
2 changes: 1 addition & 1 deletion glean_parser/templates/ruby_server.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ module Glean
{
'category' => '{{ event.category }}',
'name' => '{{ event.name }}',
'timestamp' => (Time.now.utc.to_f * 1000).to_i,
'timestamp' => 0,
'extra' => [
{% for extra, metadata in event.extra_keys.items() %}
['{{ extra }}', {{ extra }}.to_s],
Expand Down
6 changes: 3 additions & 3 deletions glean_parser/templates/rust_server.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ pub fn new_glean_event(
GleanEvent {
category: category.to_owned(),
name: name.to_owned(),
timestamp: Utc::now().timestamp_millis(),
timestamp: 0,
extra,
}
}
Expand Down Expand Up @@ -227,7 +227,7 @@ impl {{ ping|ping_events_type_name }} for {{ event|event_type_name }} {
/// Create a GleanEvent for the above-defined Event struct ({{ event|event_type_name }}).
/// Any metadata `extra` values are passed into the extra HashMap.
fn glean_event(&self) -> GleanEvent {
// Any `extra_keys` will be output below to be inserted into `extra`.
// Any `extra_keys` will be output below to be inserted into `extra`.
// If there are none, an empty, immutable HashMap is created.
{% if event.extra_keys.items()|length == 0 %}
let extra: HashMap<String, String> = HashMap::new();
Expand Down Expand Up @@ -323,7 +323,7 @@ impl GleanEventsLogger {
if let Some(event) = &params.event {
events.push(event.glean_event());
}

{% else %}
let events: Vec<GleanEvent> = Vec::new();
{% endif %}
Expand Down
2 changes: 1 addition & 1 deletion tests/data/server_custom_ping_only_compare.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ func newGleanEvent(category, name string, extra map[string]string) gleanEvent {
return gleanEvent{
Category: category,
Name: name,
Timestamp: time.Now().UnixMilli(),
Timestamp: 0,
Extra: extra,
}
}
Expand Down
6 changes: 3 additions & 3 deletions tests/data/server_custom_ping_only_compare.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ pub fn new_glean_event(
GleanEvent {
category: category.to_owned(),
name: name.to_owned(),
timestamp: Utc::now().timestamp_millis(),
timestamp: 0,
extra,
}
}
Expand Down Expand Up @@ -217,7 +217,7 @@ impl ServerTelemetryScenarioOnePingEvent for BackendSpecialEventEvent {
/// Create a GleanEvent for the above-defined Event struct (BackendSpecialEventEvent).
/// Any metadata `extra` values are passed into the extra HashMap.
fn glean_event(&self) -> GleanEvent {
// Any `extra_keys` will be output below to be inserted into `extra`.
// Any `extra_keys` will be output below to be inserted into `extra`.
// If there are none, an empty, immutable HashMap is created.
let mut extra: HashMap<String, String> = HashMap::new();

Expand Down Expand Up @@ -295,7 +295,7 @@ impl GleanEventsLogger {
if let Some(event) = &params.event {
events.push(event.glean_event());
}

self.record("server-telemetry-scenario-one", request_info, metrics, events);
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/data/server_events_and_custom_ping_compare.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ func newGleanEvent(category, name string, extra map[string]string) gleanEvent {
return gleanEvent{
Category: category,
Name: name,
Timestamp: time.Now().UnixMilli(),
Timestamp: 0,
Extra: extra,
}
}
Expand Down
6 changes: 3 additions & 3 deletions tests/data/server_events_and_custom_ping_compare.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ pub fn new_glean_event(
GleanEvent {
category: category.to_owned(),
name: name.to_owned(),
timestamp: Utc::now().timestamp_millis(),
timestamp: 0,
extra,
}
}
Expand Down Expand Up @@ -217,7 +217,7 @@ impl EventsPingEvent for BackendTestEventEvent {
/// Create a GleanEvent for the above-defined Event struct (BackendTestEventEvent).
/// Any metadata `extra` values are passed into the extra HashMap.
fn glean_event(&self) -> GleanEvent {
// Any `extra_keys` will be output below to be inserted into `extra`.
// Any `extra_keys` will be output below to be inserted into `extra`.
// If there are none, an empty, immutable HashMap is created.
let mut extra: HashMap<String, String> = HashMap::new();

Expand Down Expand Up @@ -295,7 +295,7 @@ impl GleanEventsLogger {
if let Some(event) = &params.event {
events.push(event.glean_event());
}

self.record("events", request_info, metrics, events);
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/data/server_events_compare.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def record(
{{
'category' => 'backend',
'name' => 'object_update',
'timestamp' => (Time.now.utc.to_f * 1000).to_i,
'timestamp' => 0,
'extra' => [
['object_type', object_type.to_s],
['object_state', object_state.to_s],
Expand Down
2 changes: 1 addition & 1 deletion tests/data/server_events_only_compare.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ func newGleanEvent(category, name string, extra map[string]string) gleanEvent {
return gleanEvent{
Category: category,
Name: name,
Timestamp: time.Now().UnixMilli(),
Timestamp: 0,
Extra: extra,
}
}
Expand Down
6 changes: 3 additions & 3 deletions tests/data/server_events_only_compare.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ pub fn new_glean_event(
GleanEvent {
category: category.to_owned(),
name: name.to_owned(),
timestamp: Utc::now().timestamp_millis(),
timestamp: 0,
extra,
}
}
Expand Down Expand Up @@ -217,7 +217,7 @@ impl EventsPingEvent for BackendTestEventEvent {
/// Create a GleanEvent for the above-defined Event struct (BackendTestEventEvent).
/// Any metadata `extra` values are passed into the extra HashMap.
fn glean_event(&self) -> GleanEvent {
// Any `extra_keys` will be output below to be inserted into `extra`.
// Any `extra_keys` will be output below to be inserted into `extra`.
// If there are none, an empty, immutable HashMap is created.
let mut extra: HashMap<String, String> = HashMap::new();

Expand Down Expand Up @@ -295,7 +295,7 @@ impl GleanEventsLogger {
if let Some(event) = &params.event {
events.push(event.glean_event());
}

self.record("events", request_info, metrics, events);
}
}
Expand Down