WEBVTT

NOTE Created by CaptionSync from Automatic Sync Technologies www.automaticsync.com

00:00:01.136 --> 00:00:06.186 align:middle
Head back to https://blackfire.io,
click "Environments" and click into our

00:00:06.326 --> 00:00:09.086 align:middle
"Sasquatch Sightings Production" environment.

00:00:10.236 --> 00:00:11.126 align:middle
Interesting.

00:00:11.616 --> 00:00:15.546 align:middle
By default, it takes us not
to the profiles tab...

00:00:15.796 --> 00:00:18.396 align:middle
but to a tab called "Builds".

00:00:19.016 --> 00:00:25.326 align:middle
And, look on the right: "Periodic Builds":
"Builds are started every 6 hours"...

00:00:25.666 --> 00:00:27.716 align:middle
which we could change to a different interval.

00:00:27.716 --> 00:00:32.806 align:middle
Further below, there are a
bunch of "notification channels"

00:00:33.046 --> 00:00:38.356 align:middle
where you can tell Blackfire that you
want to be notified - like via Slack -

00:00:38.686 --> 00:00:41.856 align:middle
of the results of this "build" thingy.

00:00:42.836 --> 00:00:46.316 align:middle
Ok, what the heck is a build anyways?

00:00:46.316 --> 00:00:52.056 align:middle
To find out, let's trigger one manually,
then stand back and see what happens.

00:00:52.606 --> 00:00:53.766 align:middle
Click "Start a Build".

00:00:54.936 --> 00:00:57.416 align:middle
The form pre-fills the URL to our site...

00:00:57.616 --> 00:01:01.416 align:middle
cool... and we can apparently
give it a title if we want.

00:01:02.016 --> 00:01:03.806 align:middle
Let's... just start the build.

00:01:04.976 --> 00:01:07.136 align:middle
This takes us to a new page where....

00:01:07.416 --> 00:01:11.706 align:middle
interesting: it's running
an "Untitled Scenario"...

00:01:12.546 --> 00:01:15.566 align:middle
then it looks like it went to the homepage...

00:01:15.616 --> 00:01:17.726 align:middle
and created a profile?

00:01:21.706 --> 00:01:26.466 align:middle
Let's... back up: there are a lot
of interesting things going on.

00:01:26.886 --> 00:01:28.866 align:middle
And I love interesting things!

00:01:28.866 --> 00:01:33.796 align:middle
First, we've seen this word "scenario" before!

00:01:34.696 --> 00:01:37.616 align:middle
Earlier, we used the blackfire-player:

00:01:38.296 --> 00:01:41.806 align:middle
a command-line tool that's
made by the Blackfire people...

00:01:42.056 --> 00:01:45.806 align:middle
but can be used totally outside
of the profiling tool.

00:01:46.826 --> 00:01:51.486 align:middle
We created a scenario.bkf file
where we defined a scenario

00:01:51.696 --> 00:01:56.276 align:middle
and used the special blackfire-player
language to tell it to go to the homepage,

00:01:56.526 --> 00:02:00.886 align:middle
assert a few things, then click on the
"Log In" link and check something else.

00:02:01.806 --> 00:02:07.636 align:middle
At that time, this was a nice way to
"crawl" a site and test some things on it.

00:02:08.266 --> 00:02:11.416 align:middle
The "build" used the same "scenario" word.

00:02:12.076 --> 00:02:13.956 align:middle
That's not an accident.

00:02:14.346 --> 00:02:15.476 align:middle
More on that soon.

00:02:16.346 --> 00:02:20.606 align:middle
The second important thing is that
this profiled the homepage because,

00:02:20.846 --> 00:02:27.606 align:middle
when we created our environment, we
configured one "URL to test": the homepage.

00:02:28.296 --> 00:02:33.156 align:middle
That's what the build is doing:
"testing" - meaning profiling - that page.

00:02:34.286 --> 00:02:35.806 align:middle
Let's add a second URL.

00:02:36.216 --> 00:02:43.766 align:middle
One other page we've been working on a lot is
/api/github-organization: this JSON endpoint.

00:02:44.616 --> 00:02:49.176 align:middle
Copy that URL and add it
as a second "URL to test".

00:02:50.286 --> 00:02:50.916 align:middle
Click save...

00:02:51.256 --> 00:02:53.676 align:middle
then manually create a second build.

00:02:57.176 --> 00:03:01.236 align:middle
Like before, it creates this
"Untitled Scenario" thing.

00:03:03.736 --> 00:03:07.996 align:middle
Ah! But this time it profiled both pages!

00:03:08.726 --> 00:03:13.766 align:middle
The build also shows up as
green: the build "passed".

00:03:14.696 --> 00:03:17.526 align:middle
This is a critical thing about builds.

00:03:18.196 --> 00:03:23.936 align:middle
It's not simply that a build is an automated
way to create a profile for a few pages.

00:03:24.636 --> 00:03:26.206 align:middle
That would be pretty worthless.

00:03:26.816 --> 00:03:34.186 align:middle
The real value is that you can write performance
tests that cause a build to pass or fail.

00:03:35.226 --> 00:03:37.946 align:middle
Check it out "1 successful constraint" -

00:03:38.466 --> 00:03:43.256 align:middle
which is that "HTTP Requests
should be limited to 1 per page".

00:03:43.876 --> 00:03:48.856 align:middle
Hey! That's the "test" that we
set up inside .blackfire.yaml!

00:03:49.606 --> 00:03:54.946 align:middle
The real beauty of tests is not that
the "Assertions" tab will look red

00:03:55.086 --> 00:03:57.036 align:middle
when you're looking inside a profile.

00:03:57.746 --> 00:04:02.386 align:middle
The real beauty is that you can
configure performance constraints

00:04:02.526 --> 00:04:05.866 align:middle
that should pass whenever these builds happen.

00:04:06.386 --> 00:04:12.816 align:middle
If a build fails - maybe because you
introduced some slow code - you can be notified.

00:04:13.636 --> 00:04:15.876 align:middle
But there's even more cool stuff going on.

00:04:16.686 --> 00:04:19.666 align:middle
Near the bottom, click to
see the "Player output".

00:04:20.916 --> 00:04:26.086 align:middle
Woh! It shows us how builds
work behind-the-scenes:

00:04:26.646 --> 00:04:30.296 align:middle
the Blackfire server uses the blackfire-player!

00:04:31.736 --> 00:04:39.566 align:middle
Look closer: it's running a
scenario: visit url(), method 'GET',

00:04:39.786 --> 00:04:44.126 align:middle
then visit url() of /api/github-organization.

00:04:44.996 --> 00:04:52.016 align:middle
It's a bit hard to read, but this converted
our 2 "URLs to test" into a scenario -

00:04:52.186 --> 00:04:58.786 align:middle
using the same format as the scenario.bkf
file - then passed that to blackfire-player.

00:04:59.596 --> 00:05:04.876 align:middle
You can even see it reloading both
pages multiple times to get 10 samples.

00:05:05.676 --> 00:05:08.286 align:middle
That's one of the options
it added in the scenario.

00:05:09.006 --> 00:05:11.796 align:middle
So with just a tiny bit of configuration,

00:05:12.166 --> 00:05:15.976 align:middle
Blackfire is now creating
a build every six hours.

00:05:16.606 --> 00:05:21.666 align:middle
Each time, it profiles these two
pages and, thanks to our one test,

00:05:21.946 --> 00:05:27.496 align:middle
if either page makes more than one
HTTP request, the build will fail.

00:05:28.036 --> 00:05:31.026 align:middle
By setting up a notification,
we'll know about it.

00:05:31.026 --> 00:05:36.686 align:middle
The fact that the build system uses
blackfire-player makes me wonder:

00:05:37.126 --> 00:05:39.716 align:middle
instead of configuring these URLs,

00:05:40.086 --> 00:05:45.566 align:middle
could we instead have the build
system run our custom scenario file?

00:05:46.166 --> 00:05:53.396 align:middle
I mean, it's a lot more powerful: we can visit
pages, but also click links and fill out forms.

00:05:54.256 --> 00:05:59.606 align:middle
We can also add specific
assertions to each page...

00:06:00.146 --> 00:06:05.116 align:middle
in addition to our one "global"
test about HTTP requests.

00:06:06.086 --> 00:06:07.616 align:middle
The answer to this question is...

00:06:08.026 --> 00:06:09.296 align:middle
of course!

00:06:09.766 --> 00:06:12.786 align:middle
And it's where the build
system really starts to shine.

00:06:13.346 --> 00:06:14.606 align:middle
We'll talk about that next.

00:06:14.856 --> 00:06:20.396 align:middle
But before we do, I want you to see what the
build page looks like once it's had enough time

00:06:20.396 --> 00:06:22.836 align:middle
to execute a few automated builds.

00:06:24.036 --> 00:06:26.396 align:middle
Let's check out the SymfonyCasts environment.

00:06:27.326 --> 00:06:29.506 align:middle
Woh! It's graph time!

00:06:30.426 --> 00:06:33.556 align:middle
Because this environment has
a history of automated builds,

00:06:33.866 --> 00:06:42.066 align:middle
Blackfire creates some super cool graphs: like
our cache hit percentage and our cache levels.

00:06:42.776 --> 00:06:47.376 align:middle
You can see that my OPcache Interned
Strings Buffer cache is full.

00:06:47.376 --> 00:06:50.436 align:middle
I really need to tweak some
config to increase that.

00:06:50.486 --> 00:06:56.856 align:middle
I can also see how the different URLs are
performing over time for wall time, I/O, CPU,

00:06:56.856 --> 00:07:00.396 align:middle
Memory &amp; network as well as other stuff.

00:07:00.566 --> 00:07:02.936 align:middle
We can click to see more
details about any build...

00:07:03.336 --> 00:07:06.066 align:middle
and even look at any of its profiles.

00:07:07.136 --> 00:07:13.166 align:middle
Anyways, next: let's make the build system
smarter by executing our custom scenario.

