Skip to content

Instantly share code, notes, and snippets.

@kjin
Created October 9, 2019 18:15
Show Gist options
  • Save kjin/61bdac2f5cd1c6ef1a13efb2765a69a4 to your computer and use it in GitHub Desktop.
Save kjin/61bdac2f5cd1c6ef1a13efb2765a69a4 to your computer and use it in GitHub Desktop.
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();
});
app.get('/', async (req, res) => {
res.send('hello world!');
});
app.listen(process.env.PORT || 8080);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment