add test to ensure subapps set the correct span name
parent
3fb6df0f0f
commit
fc801ad8d0
|
@ -26,6 +26,13 @@ describe('OpenTelemetry middleware', () => {
|
||||||
throw new Error('error message')
|
throw new Error('error message')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const subapp = new Hono()
|
||||||
|
subapp.get('/hello', (c) => c.text('Hello from subapp!'))
|
||||||
|
subapp.get('*', (c) => c.text('Fallthrough'))
|
||||||
|
|
||||||
|
// mount subapp
|
||||||
|
app.route('/subapp', subapp)
|
||||||
|
|
||||||
it('Should make a span', async () => {
|
it('Should make a span', async () => {
|
||||||
memoryExporter.reset()
|
memoryExporter.reset()
|
||||||
const response = await app.request('http://localhost/foo')
|
const response = await app.request('http://localhost/foo')
|
||||||
|
@ -71,4 +78,13 @@ describe('OpenTelemetry middleware', () => {
|
||||||
expect(span.name).toBe('GET /foo')
|
expect(span.name).toBe('GET /foo')
|
||||||
expect(span.attributes[ATTR_HTTP_ROUTE]).toBe('/foo')
|
expect(span.attributes[ATTR_HTTP_ROUTE]).toBe('/foo')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Issue #1112
|
||||||
|
it('Should set the correct span name for subapp', async () => {
|
||||||
|
memoryExporter.reset()
|
||||||
|
await app.request('http://localhost/subapp/hello')
|
||||||
|
const spans = memoryExporter.getFinishedSpans()
|
||||||
|
const [span] = spans
|
||||||
|
expect(span.name).toBe('GET /subapp/hello')
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue