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
$ npm ls | |
trace-pin-sms@1.0.0 /Users/kelvinjin/src/experiments/trace-pin-sms | |
├─┬ @google-cloud/trace-agent@4.2.2 | |
│ ├─┬ @google-cloud/common@2.2.3 | |
│ │ ├── @google-cloud/projectify@1.0.1 | |
│ │ ├── @google-cloud/promisify@1.0.2 | |
│ │ ├── arrify@2.0.1 | |
│ │ ├─┬ duplexify@3.7.1 | |
│ │ │ ├─┬ end-of-stream@1.4.4 | |
│ │ │ │ └─┬ once@1.4.0 |
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(); | |
const express = require('express'); | |
const app = express(); | |
// Middleware that just adds a label to each trace. | |
app.use((req, res, next) => { | |
tracer.getCurrentRootSpan().addLabel('key', 'value'); | |
next(); |
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 propagation = require('@opencensus/propagation-b3'); | |
const tracer = require('@google-cloud/trace-agent').start({ | |
rootSpanNameOverride: ((path) => `http://helloworld${path}`), | |
ignoreUrls: ['/metrics', '/api_version'], | |
samplingRate: 0.1, | |
propagation: new propagation.B3Format(), | |
disableUntracedModulesWarning: true | |
}); |
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]), |
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
// Plugin for superagent@5 | |
module.exports = [ | |
{ | |
file: '', | |
patch: (superagent, tracer) => { | |
const UnpatchedRequest = superagent.Request; | |
superagent.Request = Object.assign(function Request(...args) { | |
const result = UnpatchedRequest.apply(this, args); | |
// Request#end sends the actual request. | |
// It's called within a custom thenable's `then` implementation which, |
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 trace = require('@google-cloud/trace-agent'); | |
trace.start({ | |
spansPerTraceSoftLimit: 1000, | |
// ... other options | |
}); |
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
let stackdriverLoggingWinston = null; | |
try { | |
stackdriverLoggingWinston = require('@google-cloud/logging-winston'); | |
} catch (e) {} | |
const agent = global._google_trace_agent; | |
const enableThunkTimestamp = !!stackdriverLoggingWinston; | |
const enableThunkAgent = !!(stackdriverLoggingWinston | |
&& stackdriverLoggingWinston.LOGGING_TRACE_KEY |
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 ah = require('async_hooks'); | |
const express = require('express'); | |
const { createLogger } = require('winston'); | |
const TransportStream = require('winston-transport'); | |
// Activate async hooks. | |
let requestIdHighWater = 0; | |
const requestIdTable = {}; | |
ah.createHook({ | |
init: (child, resource, parent) => { |
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 { default: axios } = require('axios'); | |
const num = Number(process.argv[2]); | |
for (let i = 0; i < num; i++) { | |
setTimeout(() => axios.get('http://localhost:3000'), Math.floor(Math.random() * 200)); | |
} |
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
// Client for https://github.com/grpc/grpc-go/blob/master/examples/helloworld/greeter_server/main.go. | |
// 'helloworld.proto' is https://github.com/grpc/grpc-go/blob/master/examples/helloworld/helloworld/helloworld.proto. | |
const tracer = require('@google-cloud/trace-agent').start({ bufferSize: 1, samplingRate: 0 }); | |
const grpc = require('grpc'); | |
const bluebird = require('bluebird'); | |
const protoFile = __dirname + '/helloworld.proto'; | |
const proto = grpc.load(protoFile).helloworld; |
NewerOlder