You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: site/content/guides/canary-deploys.md
+37-9Lines changed: 37 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,21 +20,21 @@ One final note, canary deployments are sometimes called blue-green deployments,
20
20
21
21
Our site, is releasing major new features and we're running a canary deployment to make sure everything's working. Visitors to the site are randomly assigned to a canary group, and receive an additional header on their page requests that activates the new features. Essentially our canary deploy is setting this feature flag to 'true' for a number of users.
22
22
23
-
We're already monitoring the site with Checkly's browser and API synthetics monitors, and using uptime monitoring to make sure that every URL is available. If we change nothing about our Checkly configuration, some check runs will be randomly assigned to the canary group, and the rest will run with the same set of features as most visitors. We'd like to enhance this experience during our canary deployment. Here are the requirements:
23
+
We're already monitoring the site with Checkly's browser and API synthetics monitors, and using uptime monitoring to make sure that every URL is available. If we change nothing about our Checkly configuration, some check runs will be randomly assigned to the canary group, and the rest will run with the same set of features as most visitors. We'd like to enhance this experience during our canary deployment. Here are three use cases to better support canary deployments:
24
24
25
-
* For better reliability, we want active control whether a check runs as a user that can see the canary deployment.
25
+
* For better reliability, we want active control over whether a check runs as a user that can see the canary deployment.
26
26
27
27
* Our engineers want to integrate our Checkly monitors into their deploy process, letting us roll back deployments if monitors fail.
28
28
29
-
* For some checks, we want a version that reports separate data for just this canary deployment, with a chart on our Checkly dashboard showing how checks in the canary group are performing.
29
+
* For some checks, we want a version that reports separate data for just this canary deployment, with a chart on our Checkly web UI showing how checks in the canary group are performing.
30
30
31
31
At Checkly, we're on a mission to empower developers, making it easier to detect, communicate, and resolve problems before they affect users.
32
32
33
33
These improvements will help us better **detect** problems with our canary deployment, with clearer ways to **communicate** the results of checks and their context to our team. With clear results information, our team can **resolve** issues faster, making every canary deployment a smoother experience for engineers and users.
34
34
35
35
## 1. Set Feature Flags With Headers & User Agents
36
36
37
-
In our scenario, we can control whether we get the canary version of our service with a feature flag. By control a request's headers, we can set the user agent or add arbitrary header values to our requests. Let's set some headers in an API check, a browser check, and a more complex Multistep API check.
37
+
In our scenario, we can control whether we get the canary version of our service with a feature flag. By control a request's headers, we can set the user agent or add arbitrary header values to our requests. Let's set some headers in an API check, a Browser check, and a more complex Multistep API check.
38
38
39
39
### A. Set Headers for an API Check
40
40
When running API checks, headers are part of your configuration. You can add [HTTP headers](https://www.checklyhq.com/docs/api-checks/request-settings/#headers) in the Checkly web UI when setting up your API checks, but since we developers prefer to use monitoring as code, here's how to control API checks' headers right from your IDE. API checks are created as a [Checkly construct](https://www.checklyhq.com/docs/cli/constructs-reference/#apicheck), and we can create a new one by creating a new file in our Checkly Project (if you haven't set up a Checkly Project or used monitoring as code before, check out our [getting started tutorial](https://www.checklyhq.com/guides/startup-guide-detect-communiate-resolve/) before returning here to start modifying headers):
@@ -72,7 +72,7 @@ Since headers are part of the basic configuration of your check, you can populat
72
72
73
73
### B. Set Headers in a Browser Check
74
74
75
-
Headers for request are not part of the basic configuration of browser checks. In part because an automated browser will make many checks as part of a single run, and it wouldn't be clear exactly which requests should have an additional header. It's quite easy to add headers to some or all requests from a check written in playwright, with a specialized version of [request interception](https://www.checklyhq.com/learn/playwright/intercept-requests/). In this example we only want to modify requests for SVG files with our new header:
75
+
Headers for request are not part of the basic configuration of Browser checks. In part because an automated browser will make many checks as part of a single run, and it wouldn't be clear exactly which requests should have an additional header. It's quite easy to add headers to some or all requests from a check written in playwright, with a specialized version of [request interception](https://www.checklyhq.com/learn/playwright/intercept-requests/). In this example we only want to modify requests for SVG files with our new header:
76
76
77
77
```ts {title="book-listing-canary.spec.ts"}
78
78
import { test, expect } from'@playwright/test'
@@ -100,7 +100,7 @@ The example above filters for all requests with a route ending in `.svg` but you
100
100
101
101
102
102
### C. Set Headers in a Multistep API Check
103
-
A multistep check uses Playwright scripting to perform a series of API requests with more complex evaluation of the response. Since we're only making API requests, we can feed in new headers as a property.
103
+
A Multistep check uses Playwright scripting to perform a series of API requests with more complex evaluation of the response. Since we're only making API requests, we can feed in new headers as a property.
104
104
105
105
In this example we are making a pair of sequential API checks, the second test step relying on the results of the first step. Both requests use our header settings.
106
106
@@ -172,13 +172,13 @@ At the unique link provided we can see all our check runs succeeded.
And you can click on each to view the report on the check run. Our browser check will show a full trace, and we can look at our request headers on the network tab:
175
+
And you can click on each to view the report on the check run. Our Browser check will show a full trace, and we can look at our request headers on the network tab:
Now we can run this same monitor against both our main line production environments and our canary deployments, with its behavior determined by environment variables.
259
+
Now we can run this same monitor against both our Production environments and our canary deployments, with its behavior determined by environment variables.
260
+
261
+
For our API checks and other monitors that don't run Playwright, we can only control their behavior by setting environment variables at the group level, and we can't follow a 'multi-pathed' approach like we do above in our Browser check. The next section will cover using Groups to set environment variables in more detail.
262
+
263
+
### 3. Generate Canary Deployment Data With a Separate Check Group
264
+
265
+
If we can run a set of Checks such that they always 'see' the version of our service in a canary deployment, it would be nice to generate data for just that deployment. To create separate data in our Checkly web UI, and to manage the environment variables of these checks all at once, we can use a [Checkly Group](https://www.checklyhq.com/docs/groups/).
266
+
267
+
We'll start by defining our Group, and setting some default values for checks in that group:
0 commit comments