Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Add Stats structs #611

Merged
merged 3 commits into from Apr 21, 2019
Merged

WIP: Add Stats structs #611

merged 3 commits into from Apr 21, 2019

Conversation

maxhawkins
Copy link
Contributor

Add structs from rtc-domstats spec so we can begin implementing the GetStats API.

Related to #610

@backkem backkem added the review label Apr 10, 2019
@maxhawkins maxhawkins force-pushed the getstats branch 6 times, most recently from e8adb27 to b29d7e3 Compare April 10, 2019 21:55
@maxhawkins
Copy link
Contributor Author

@Sean-Der Do you think it would be useful or confusing to merge these struct definitions?

I don't have time to implement the stats just yet, but this will make it easier for someone to do it in the future. Alternately I could hang onto this PR until I have time to add a stat.

@Sean-Der
Copy link
Member

@maxhawkins

IMO I would merge them! someone might get interested and finish the work.

Would you mind adding some dumb tests that just assert things exist? just so coverage doesn't drop

@maxhawkins
Copy link
Contributor Author

Will do

@maxhawkins maxhawkins force-pushed the getstats branch 4 times, most recently from 7f65eac to aad5dd3 Compare April 18, 2019 03:43
@maxhawkins
Copy link
Contributor Author

PTAL

// Report (RR) or Extended Report (XR).
type ReceivedRTPStreamStats struct {
// PacketsReceived is the total number of RTP packets received for this SSRC.
PacketsReceived uint32 `json:"packetsReceived"`
Copy link
Member

Choose a reason for hiding this comment

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

NIT -- What do you think of putting a newline after every member? Visually I break chunks apart by newline, so easier to consume when reading

Copy link
Contributor Author

Choose a reason for hiding this comment

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

will do

stats.go Outdated
// StatsReport collects Stats objects indexed by their ID.
type StatsReport map[string]Stats

// StatsBase contains all the fields Stats objects share
Copy link
Member

Choose a reason for hiding this comment

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

Does this need to be public?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

On second thought, let's just delete it.

If I get rid of the Stats methods like I mention below all of these fields can just be duplicated in the base stat objects.

stats.go Outdated

// A Stats object contains a set of statistics copies out of a monitored component
// of the WebRTC stack at a specific time.
type Stats interface {
Copy link
Member

Choose a reason for hiding this comment

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

Does this need to be public?

Copy link
Member

Choose a reason for hiding this comment

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

Not a big deal, but we are putting some implementation details in the users face by having these public.

I don't feel strongly, but would be nice if godoc doesn't show anything we did to make our code shorter

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I do want to keep the type around. Maybe i'll get rid of the methods:

type Stats interface{}

I'm not sure Type() and Timestamp() are so useful anyway. Everyone will end up casting to the base type and they can find those values there.

The initial idea for this had to do with keeping the results of the not-yet-implemented GetStats method typesafe. It returns a map with polymorphic values map[string]Stats.

Copy link
Member

@Sean-Der Sean-Der left a comment

Choose a reason for hiding this comment

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

Damn really nice work @maxhawkins

This is going to be great in the godoc, getting info on stats for WebRTC right now is awful. You have to dig into things at runtime/look at MDN. Really excited to see this go out

@jinleileiking
Copy link
Contributor

Is this done?exciting

@maxhawkins maxhawkins merged commit 3d2c1c2 into master Apr 21, 2019
@maxhawkins maxhawkins deleted the getstats branch April 21, 2019 18:26
@backkem backkem removed the review label Apr 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants