Skip to content

Commit

Permalink
chore: update express example
Browse files Browse the repository at this point in the history
  • Loading branch information
vmihailenco committed Jul 2, 2024
1 parent 5de7b0c commit 1c94eae
Show file tree
Hide file tree
Showing 3 changed files with 3,072 additions and 4 deletions.
14 changes: 11 additions & 3 deletions example/express/main.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
'use strict'

const port = 9999

const { trace, context } = require('@opentelemetry/api')
const { HttpInstrumentation } = require('@opentelemetry/instrumentation-http')
const { ExpressInstrumentation } = require('@opentelemetry/instrumentation-express')
const uptrace = require('@uptrace/node')

uptrace.configureOpentelemetry({
Expand All @@ -11,6 +11,13 @@ uptrace.configureOpentelemetry({

serviceName: 'myservice',
serviceVersion: '1.0.0',

instrumentations: [
new HttpInstrumentation({}),
new ExpressInstrumentation({
ignoreLayersType: ['middleware'],
}),
],
})

const otel = require('@opentelemetry/api')
Expand All @@ -21,7 +28,8 @@ const tracer = otel.trace.getTracer('express-example')
app.get('/', indexHandler)
app.get('/hello/:username', helloHandler)

app.listen(9999, () => {
const port = 9999
app.listen(port, () => {
console.log(`listening at http://localhost:${port}`)
})

Expand Down
Loading

0 comments on commit 1c94eae

Please sign in to comment.