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

Updated the metrics reporting url #36

Merged
merged 8 commits into from
Sep 8, 2022
Merged

Conversation

clacladev
Copy link
Contributor

Description

Updated the metrics reporting url for the video player.

Additional Information

  • I updated the base url as per discussion
  • Updated the code that generates the final metrics reporting url
  • Added a log in case it fails to generate a metrics reporting url
  • Added unit tests

@vercel
Copy link

vercel bot commented Sep 8, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
livepeerjs ✅ Ready (Inspect) Visit Preview Sep 8, 2022 at 5:22PM (UTC)

@vercel vercel bot temporarily deployed to Preview September 8, 2022 15:12 Inactive
@clacladev clacladev linked an issue Sep 8, 2022 that may be closed by this pull request
Copy link
Member

@0xcadams 0xcadams left a comment

Choose a reason for hiding this comment

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

LGTM! Just some clarifying questions but looks great.

Also, in the future, try using expect(url).toMatchInlineSnapshot('...') - when you run the tests locally and the snapshot is out of date, it makes it easy to update (press u and the value is automatically updated). Makes it a bit easier to maintain tests.

@@ -1,14 +1,28 @@
// Temporarily hardcoded catalyst node
const METRICS_REPORTING_BASE_URL = 'wss://sao-canary-catalyst-0.livepeer.fun';
// Temporarily hardcoded catalyst node, in production we need to point to .studio
Copy link
Member

Choose a reason for hiding this comment

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

Should this be pointing to .studio then? Or is this waiting on something? The discussion was a bit confusing to me. This library should only be used in "production" or very similar, production-like environments.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@victorges Are you able to clarify? Is livepeer.fun another staging environment or is it production?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My understanding from the conversation is that .studio does not exists yet. It will eventually.

Copy link
Member

Choose a reason for hiding this comment

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

Reporting URL should have the same TLD as the playback URL. If playback is from .studio, use studio, etc.

Canary (.fun) is a second staging environment created for multi-node catalyst development. Regular staging is under .monster.

When multi-node goes to production, we will have studio, monster and fun URLs.

.fun is the closest we will have to that, since it is the only multi-node deployment we have right now. Although, the SDK here could just keep the same TLD anyway (maybe with a list of allowed ones) and that should be future-proof.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We could already implement this to keep the same tld as the sourceUrl, but if they are not live yet, then we would not be actually be reporting any metrics right?

Copy link
Member

Choose a reason for hiding this comment

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

Right! But we cannot deploy/use this on any environment before multi-node is deployed (which is what enables this API). Unless we want to release a version that only works on the canary environment anyway. We cannot use metrics from canary (fun) for production (studio) streams anyway, it's a separate timeseries database. So sending them to canary or not sending at all (like trying to send to playback.livepeer.studio) does not make any difference in practice.

// Given
const sourceUrls = [
'https://livepeercdn.com/static/c34af47b-bbf2-40ed-ad2d-77abd43860c9/index.m3u8',
'https://livepeercdn.com/recordings/c34af47b-bbf2-40ed-ad2d-77abd43860c9/master.m3u8',
Copy link
Member

Choose a reason for hiding this comment

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

Should we deliberately not handle this case? I am not sure what the playlist names look like, or why we'd want to ignore master over index.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My thought is that if this is not an agreed livepeer url, we end processing some random string as playbackID. Then we try to connect a WS to an incorrect URL. So it's going to fail anyway.

If we want it to be more elastic, I can just check that the last parameter contains .m3u8 and not the specific playlist name.

What are your thoughts?

Copy link
Member

Choose a reason for hiding this comment

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

IMO we should ignore anything that doesn't look like a Livepeer URL. We don't want to end up sending metrics about non-existing streams when people use the player for non-Livepeer resources (which we should support).

@vercel vercel bot temporarily deployed to Preview September 8, 2022 15:47 Inactive
@0xcadams 0xcadams enabled auto-merge (squash) September 8, 2022 17:15
@vercel vercel bot temporarily deployed to Preview September 8, 2022 17:16 Inactive
@0xcadams
Copy link
Member

0xcadams commented Sep 8, 2022

Added #38 to track future work on productionizing metrics reporting.

@vercel vercel bot temporarily deployed to Preview September 8, 2022 17:22 Inactive
@0xcadams 0xcadams merged commit 3284d85 into main Sep 8, 2022
@0xcadams 0xcadams deleted the clacladev/metrics-reporting-url branch September 8, 2022 17:24
@clacladev
Copy link
Contributor Author

Thanks Chase to get this merged

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.

Fix metrics reporting URL
4 participants