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

feat: extend stats object #10

Merged
merged 3 commits into from
Dec 15, 2017
Merged

feat: extend stats object #10

merged 3 commits into from
Dec 15, 2017

Conversation

forbesjo
Copy link
Contributor

@forbesjo forbesjo commented Dec 5, 2017

Description

This adds a few more properties to the hls.stats object as well as uses the new debug logging level.

TODO

  • Add more stats
  • Add and use debug logging from video.js

Requirements Checklist

  • Feature implemented / Bug fixed
  • Reviewed by Two Core Contributors

@forbesjo forbesjo mentioned this pull request Dec 5, 2017
6 tasks
@mjneil
Copy link
Contributor

mjneil commented Dec 11, 2017

Do we want this as a plugin on the player? or should it be apart of the player.vhs api?

currentSource: player.currentSource(),
master: player.tech_.hls.masterPlaylistController_.masterPlaylistLoader_.master,
currentTech: player.tech_.name_,
// TODO: filter by VHS logging only
Copy link
Contributor

Choose a reason for hiding this comment

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

How do we want to go about this? Currently videojs doesn't do any type of filtering or bucketing of the history, just a single array that all logging args get dumped into.

Some options I can think of:

  • prefix all log messages we add with a VHS specific string so we can filter on that
  • send only objects into the logs e.g. { vhs: true, message: 'log message' } Downside to this is if the debug log is enabled, videojs will console log objects for all of our messages instead of just the message
  • extend videojs.log to seperate history by type or allow a way of requesting logs in history of a specific type. Downside to this would be not being available on previous versions of videojs

@forbesjo
Copy link
Contributor Author

Perhaps this should be on player.vhs since this API only applies to this project.

@forbesjo
Copy link
Contributor Author

Then again we have not yet exposed player.vhs yet. Those changes are in #8

currentTime: player.currentTime(),
timestamp: Date.now(),
currentSource: player.currentSource(),
master: player.tech_.hls.masterPlaylistController_.masterPlaylistLoader_.master,
Copy link
Contributor

Choose a reason for hiding this comment

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

could use the shortcut player.tech_.hls.playlists.master

return {
videoPlaybackQuality: player.getVideoPlaybackQuality(),
playerDimensions: player.currentDimensions(),
hlsStats: player.tech_.hls.stats,
Copy link
Contributor

Choose a reason for hiding this comment

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

do we want to call this hlsStats since the stats apply to dash sources as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This should probably be renamed vhsStats since it would be the vhs.stats object

return videojs.log.debug.bind(videojs, '[VHS]', `${source} >`);
}

return function() {};
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we want to fall back to videojs.log when videojs.log.debug does not exist?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That would then print out the logging by default

Copy link
Contributor

Choose a reason for hiding this comment

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

ah ya we don't want that

Copy link
Contributor

@gesinger gesinger left a comment

Choose a reason for hiding this comment

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

Would be good to have tests for logger and getPlaybackStats

@@ -672,27 +671,17 @@ export default class SegmentLoader extends videojs.EventTarget {
return null;
}

this.logger_('checkBuffer_',
Copy link
Contributor

Choose a reason for hiding this comment

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

Any specific reason for removing this and other logs that currently exist?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mjneil was removing some excessive logging

return {
videoPlaybackQuality: this.tech_.getVideoPlaybackQuality(),
playerDimensions: this.tech_.currentDimensions(),
vhsStats: this.stats,
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems a bit ambiguous in naming considering we have vhsStats as a sub property of playbackStats

Copy link
Contributor Author

@forbesjo forbesjo Dec 13, 2017

Choose a reason for hiding this comment

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

Do we want to merge with stats or perhaps just extend stats?

@forbesjo forbesjo changed the title feat: include a stats plugin feat: extend stats object Dec 13, 2017
@@ -0,0 +1,11 @@
import videojs from 'video.js';

const logger = (source) => {
Copy link
Contributor

@mjneil mjneil Dec 13, 2017

Choose a reason for hiding this comment

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

This will not allow us the ability to turn debug logging on mid session via videojs.log.level('debug') . If we want to support that, we will need something like this

const logger = (source) => (...args) => {
  if (videojs.log.level() === 'debug') {
    videojs.log.debug('VHS:', `${source} >`, ...args);
  }
};

Copy link
Member

Choose a reason for hiding this comment

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

you don't even need the .call(videojs, in your way @mjneil.

Copy link
Contributor

Choose a reason for hiding this comment

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

oh right, good call!

Copy link
Contributor

Choose a reason for hiding this comment

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

oops this is checking if debug api is available, not if the mode is debug

import videojs from 'video.js';

const logger = (source) => {
if (videojs.log.debug) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I know we discussed how the history object might get crowded by the debug logging once it's available. Do we know about how many logs per minute of video we'll be generating?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looks like around ~35 items per minute with what's being logged at the moment

Copy link
Contributor

Choose a reason for hiding this comment

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

If that's pretty standard (and we can't get into a case where the log messages explode), that seems pretty good (to not have to hide behind another config flag). We should be careful to look at some of the cases in case any could spew messages though, and test some scenarios to make sure we don't kill a browser tab from memory consumptions.

@@ -377,6 +377,20 @@ class HlsHandler extends Component {
}
});

const getTimeRanges = (player, type) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Since player and type are only used once to get the time ranges, it might be simpler and clearer to only pass in the time ranges themselves. The function may also be better served as being called timeRangesToArray and if we put it outside of the function we can add some tests for it.

@forbesjo forbesjo merged commit ae6a53a into master Dec 15, 2017
@forbesjo forbesjo deleted the feat/stats branch December 15, 2017 20:36
forbesjo pushed a commit to forbesjo/http-streaming that referenced this pull request Jan 30, 2018
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.

4 participants