Created
July 27, 2019 00:31
-
-
Save kjin/3b86f1eaf6c8ee9c458df8708e77ae53 to your computer and use it in GitHub Desktop.
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
const tracer = require('@google-cloud/trace-agent').start({ | |
// Settings recommended for Cloud Functions. | |
samplingRate: 0, | |
bufferSize: 1 | |
}); | |
app.get('/', (req, res) => { | |
tracer.runInRootSpan({ | |
name: 'outer', // Your function name here | |
traceContext: tracer.propagation.extract(key => req.headers[key]), | |
}, (span) => { | |
// Your logic here. Just be sure to call endSpan() after sending a response. | |
span.endSpan(); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment