-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into bluebird-patch
- Loading branch information
Showing
43 changed files
with
1,334 additions
and
880 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
node_modules/* | ||
samples/node_modules/* | ||
**/node_modules | ||
src/**/doc/* | ||
build/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.gcloudignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Stackdriver Trace for Node.js Sample Application | ||
|
||
This sample demonstrates using [Stackdriver Trace][trace] with Node.js. | ||
|
||
> Node 8+ is required for this sample. | ||
* [Setup](#setup) | ||
* [Running locally](#running-locally) | ||
* [Deploying to App Engine](#deploying-to-app-engine) | ||
* [Viewing Traces](#viewing-traces) | ||
|
||
## Setup | ||
|
||
Before you can run or deploy the sample, you need to do the following: | ||
|
||
1. Refer to the [this README file][readme] for instructions on | ||
running and deploying. | ||
1. Install dependencies: | ||
|
||
npm install | ||
|
||
## Running locally | ||
|
||
npm start | ||
|
||
## Deploying to App Engine | ||
|
||
Ensure that you have an up-to-date `gcloud` (run `gcloud components update`), and then: | ||
|
||
npm run deploy | ||
|
||
## Viewing Traces | ||
|
||
Use the [Stackdriver Trace dashboard](https://console.cloud.google.com/traces/traces) to inspect recorded traces. | ||
|
||
[trace]: https://cloud.google.com/trace/ | ||
[readme]: https://github.com/GoogleCloudPlatform/nodejs-docs-samples/blob/master/appengine/README.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/** | ||
* Copyright 2017, Google, Inc. | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
'use strict'; | ||
|
||
// [START trace_app] | ||
if (process.env.NODE_ENV === 'production') { | ||
// [START trace_setup_implicit] | ||
require('@google-cloud/trace-agent').start(); | ||
// [END trace_setup_implicit] | ||
} | ||
|
||
const express = require('express'); | ||
const got = require('got'); | ||
|
||
const app = express(); | ||
const DISCOVERY_URL = 'https://www.googleapis.com/discovery/v1/apis'; | ||
|
||
// This incoming HTTP request should be captured by Trace | ||
app.get('/', (req, res) => { | ||
// This outgoing HTTP request should be captured by Trace | ||
got(DISCOVERY_URL, { json: true }) | ||
.then((response) => { | ||
const names = response.body.items.map((item) => item.name); | ||
|
||
res | ||
.status(200) | ||
.send(names.join('\n')) | ||
.end(); | ||
}) | ||
.catch((err) => { | ||
console.error(err); | ||
res | ||
.status(500) | ||
.end(); | ||
}); | ||
}); | ||
|
||
// Start the server | ||
const PORT = process.env.PORT || 8080; | ||
app.listen(PORT, () => { | ||
console.log(`App listening on port ${PORT}`); | ||
console.log('Press Ctrl+C to quit.'); | ||
}); | ||
// [END trace_app] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Copyright 2016, Google, Inc. | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
# [START app_yaml] | ||
runtime: nodejs10 | ||
# [END app_yaml] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"name": "cloud-trace-nodejs-samples", | ||
"description": "Sample for Google Stackdriver Trace on Google App Engine Standard Environment.", | ||
"version": "0.0.0", | ||
"private": true, | ||
"license": "Apache-2.0", | ||
"author": "Google Inc.", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/googleapis/cloud-trace-nodejs.git" | ||
}, | ||
"engines": { | ||
"node": ">=8" | ||
}, | ||
"scripts": { | ||
"deploy": "gcloud app deploy", | ||
"start": "node app.js" | ||
}, | ||
"dependencies": { | ||
"@google-cloud/trace-agent": "^3.3.1", | ||
"express": "^4.16.4", | ||
"got": "^9.3.2" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/** | ||
* Copyright 2017, Google, Inc. | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
'use strict'; | ||
|
||
// [START trace_setup_explicit] | ||
require('@google-cloud/trace-agent').start({ | ||
projectId: 'your-project-id', | ||
keyFilename: '/path/to/key.json' | ||
}); | ||
// [END trace_setup_explicit] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.