Created
January 16, 2022 14:22
-
-
Save ganny26/726861a88589c2f145746a61dc8f1486 to your computer and use it in GitHub Desktop.
service.js
This file contains hidden or 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 { init } = require('./tracer') | |
| const api = require('@opentelemetry/api') | |
| init('demo-node-service', 'development') | |
| const express = require('express') | |
| const axios = require('axios') | |
| const app = express() | |
| app.use(express.json()) | |
| app.use(express.urlencoded({ extended: false })) | |
| app.get('/hello', async (req, res) => { | |
| const apiResponse = await axios.get('https://randomuser.me/api/') | |
| const activeSpan = api.trace.getSpan(api.context.active()) | |
| activeSpan.addEvent('Hello API Called', { randomIndex: 1 }) | |
| res.status(200).send({ | |
| success: true, | |
| result: apiResponse.data, | |
| }) | |
| }) | |
| app.listen(3000, (req, res) => { | |
| console.log('server started') | |
| }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment