Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

[android] added performance event #13795

Merged
merged 1 commit into from
Jan 30, 2019
Merged

[android] added performance event #13795

merged 1 commit into from
Jan 30, 2019

Conversation

osana
Copy link
Contributor

@osana osana commented Jan 25, 2019

added performance event for measuring latency and tracing download failures

@osana osana requested review from tobrun and langsmith January 25, 2019 00:22
@osana osana added Android Mapbox Maps SDK for Android performance Speed, stability, CPU usage, memory usage, or power usage labels Jan 25, 2019
@osana osana requested a review from zugaldia January 25, 2019 00:26
@SerializedName("sessionId")
private final String sessionId;

@SerializedName("data")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI if the field name matches the serialized variant, there is no need to declare @SerializedName

@SerializedName("data")
private final Bundle data;

private static final SimpleDateFormat dateFormat =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when using static final, make field name uppercase

* Register performance event.
* @param data performance event data
*/
void onPerformanceEvent(Bundle data);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While we are introducing a performance event that can be reused for multiple purposes, I would prefer keeping the TelemetryDefinition interface to be as concrete as possible. Some users swap out our telemetry with their own and wouldn't know how to implement onPerformanceEvent(Bundle data). Having a method with tile latency and adding a long duration parameter would make it more clear and easier for those users to integrate.

@Override
public void onPerformanceEvent(Bundle data) {
if (data != null && !data.isEmpty()) {
telemetry.push(new PerformanceEvent("What is session?", data));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"What is session?" -> SessionIdentifier.java

import java.util.Date;
import java.util.Locale;

public class PerformanceEvent extends Event {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing class javadoc

@@ -0,0 +1,69 @@
package com.mapbox.mapboxsdk.module.telemetry;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you are adding this class to the public API of telemetry defintion, you should place it under module as these files are removed by some clients to roll their own.

Note however that in a another comment, I'm indicating to remove this class from the public API so no action should be taken, just an FYI.

Copy link
Contributor Author

@osana osana Jan 25, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tobrun I felt that PerformanceEvent constructor should not be public and either:

  • I should add public PerformanceEventFactory that creates those events
  • or keep it together with the impl classes. (i.e. in the module).


/**
* Register performance event.
* @param data performance event data
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing whitespace in javadoc

Bundle data = new Bundle();
data.putString("metrics_name", "metrics_latency");
data.putLong("latency", response.receivedResponseAtMillis() - response.sentRequestAtMillis());
telemetry.onPerformanceEvent(data);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of pushing out an event with each tile load, we could batch them?

@osana osana force-pushed the osana-telem branch 4 times, most recently from 99e9713 to 954a5ed Compare January 28, 2019 16:04
@osana osana requested a review from andrlee January 28, 2019 16:04

private final String event;

private final String created;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
private final String created;
private final String eventCreationDate;

Maybe rename this variable so it's a little clearer? By its name only, it's not obvious that this variable ends up being a date and is set equal to DATE_FORMAT.format(new Date()) in the PerformanceEvent constructor. Even though String is next to the name, it sounds like it could represent some sort of boolean about whether the event is created or not.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@langsmith I think this is what we use in other events . Also this matches the name on the backend so we do not have to add a serialization annotation.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ahh, ok. Got it.

@tobrun tobrun added this to the android-v7.2.0 milestone Jan 30, 2019
@osana osana merged commit ce37879 into master Jan 30, 2019
@osana osana deleted the osana-telem branch January 30, 2019 15:18
Copy link
Contributor

@andrlee andrlee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@osana Quick question: how did we test this code? i don't see any integration tests, did we do manual tests with staging to make sure a valid json payload is generated?

@osana
Copy link
Contributor Author

osana commented Jan 31, 2019

@andrlee @langsmith I think the plan is to test it in the demo app.

@LukasPaczos LukasPaczos modified the milestones: android-v7.2.0, release-k Feb 4, 2019
* Customer measurements can be added to the bundle.
*/
public class PerformanceEvent extends Event {
private static final String PERFORMANCE_TRACE = "performance.trace";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noting that this has changed to mobile.performance_trace and we should cut a new PR fixing it cc @osana @zugaldia @andrlee

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Android Mapbox Maps SDK for Android performance Speed, stability, CPU usage, memory usage, or power usage
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants