Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions samples/broken-links-ok/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Overview

This sample uses the `@google-cloud/synthetics-sdk-broken-links` to create a Google Cloud Function that can be used with Google Cloud Monitoring Synthetics.

## Installation

```
# from root of repo, build all packages
npm install
```

Update the `options` variable in the `index.js` to the desired `origin_uri` along with any other (optional) fields.

## Running

The following command runs this sample locally
```
npx functions-framework --target=BrokenLinkChecker
```

The following command deploys this sample to gcp as a cloud function.
```
gcloud functions deploy broken-links-http --gen2 --runtime=nodejs18 --region=us-east4 --source=. --entry-point=BrokenLinkChecker --trigger-http --timeout=60 --memory=2048M
```

## Running Local Synthetics SDK Changes

Use the following instructions to run the version of the synthetics-sdk-broken-links package that has local changes. *The instructions should start from the root directory for the `synthetics-sdk` workspace.*

1. Pack "@google-cloud/synthetics-sdk-api" into tar file, output to synthetics-sdk-broken-links
```
npm pack --workspace="@google-cloud/synthetics-sdk-api" --pack-destination=packages/synthetics-sdk-broken-links/
cd packages/synthetics-sdk-broken-links/
```

2. Open package.json, update synthetics-sdk-broken-links dependency for "@google-cloud/synthetics-sdk-api" to use tar file.

```
"dependencies": {
...
"@google-cloud/synthetics-sdk-api": "google-cloud-synthetics-sdk-api-0.5.0.tgz"
...
}
```

3. Go back to root directory of synthetics-sdk
```
cd ../..
```

4. Pack all workspace packages into tar files, output to samples/broken-links-ok
```
npm pack --workspaces --pack-destination=samples/broken-links-ok/
cd samples/broken-links-ok/
```

5. Open package.json, update broken-links-ok dependency for "@google-cloud/synthetics-sdk-broken-links" and "@google-cloud/synthetics-sdk-api" to use tar file.
```
"dependencies": {
...
"@google-cloud/synthetics-sdk-broken-links": "google-cloud-synthetics-sdk-broken-links-0.1.2.tgz",
"@google-cloud/synthetics-sdk-api": "google-cloud-synthetics-sdk-api-0.5.0.tgz"
...
}
```

Proceed back to steps in [RUNNING](#Running)
4 changes: 4 additions & 0 deletions samples/broken-links-ok/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

// [START monitoring_synthetic_monitoring_broken_links_invocation]

const functions = require('@google-cloud/functions-framework');
const GcmSynthetics = require('@google-cloud/synthetics-sdk-broken-links');

Expand Down Expand Up @@ -40,3 +42,5 @@ const options = {
};

functions.http('BrokenLinkChecker', GcmSynthetics.runBrokenLinksHandler(options));

// [END monitoring_synthetic_monitoring_broken_links_invocation]