diff --git a/packages/otel/src/index.test.ts b/packages/otel/src/index.test.ts index 7f73cbab..1908840c 100644 --- a/packages/otel/src/index.test.ts +++ b/packages/otel/src/index.test.ts @@ -26,6 +26,13 @@ describe('OpenTelemetry middleware', () => { 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 () => { memoryExporter.reset() const response = await app.request('http://localhost/foo') @@ -71,4 +78,13 @@ describe('OpenTelemetry middleware', () => { expect(span.name).toBe('GET /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') + }) })