diff --git a/src/plugins/ExpressPlugin.ts b/src/plugins/ExpressPlugin.ts index 3e55e72..cfbd0d2 100644 --- a/src/plugins/ExpressPlugin.ts +++ b/src/plugins/ExpressPlugin.ts @@ -43,8 +43,9 @@ class ExpressPlugin implements SwPlugin { router.handle = function (req: Request, res: ServerResponse, next: any) { const carrier = ContextCarrier.from((req as any).headers || {}); - const operation = (req.originalUrl || req.url || '/').replace(/\?.*/g, ''); - const span = ignoreHttpMethodCheck(req.method ?? 'GET') + const reqMethod = req.method ?? 'GET'; + const operation = reqMethod + ':' + (req.originalUrl || req.url || '/').replace(/\?.*/g, ''); + const span = ignoreHttpMethodCheck(reqMethod) ? DummySpan.create() : ContextManager.current.newEntrySpan(operation, carrier, [Component.HTTP_SERVER, Component.EXPRESS]); diff --git a/src/plugins/HttpPlugin.ts b/src/plugins/HttpPlugin.ts index f4bc793..858833a 100644 --- a/src/plugins/HttpPlugin.ts +++ b/src/plugins/HttpPlugin.ts @@ -159,8 +159,9 @@ class HttpPlugin implements SwPlugin { function _sw_request(this: any, req: IncomingMessage, res: ServerResponse, ...reqArgs: any[]) { const carrier = ContextCarrier.from((req as any).headers || {}); - const operation = (req.url || '/').replace(/\?.*/g, ''); - const span = ignoreHttpMethodCheck(req.method ?? 'GET') + const reqMethod = req.method ?? 'GET'; + const operation = reqMethod + ':' + (req.url || '/').replace(/\?.*/g, ''); + const span = ignoreHttpMethodCheck(reqMethod) ? DummySpan.create() : ContextManager.current.newEntrySpan(operation, carrier); diff --git a/tests/plugins/axios/expected.data.yaml b/tests/plugins/axios/expected.data.yaml index cb0046f..a8bfdc6 100644 --- a/tests/plugins/axios/expected.data.yaml +++ b/tests/plugins/axios/expected.data.yaml @@ -41,7 +41,7 @@ segmentItems: value: '200' - key: http.status.msg value: OK - - operationName: /axios + - operationName: GET:/axios operationId: 0 parentSpanId: -1 spanId: 0 @@ -97,7 +97,7 @@ segmentItems: spanType: Exit peer: server:5000 skipAnalysis: false - - operationName: /axios + - operationName: GET:/axios operationId: 0 parentSpanId: -1 spanId: 0 diff --git a/tests/plugins/express/expected.data.yaml b/tests/plugins/express/expected.data.yaml index b53cbf9..d49d98d 100644 --- a/tests/plugins/express/expected.data.yaml +++ b/tests/plugins/express/expected.data.yaml @@ -21,7 +21,7 @@ segmentItems: segments: - segmentId: not null spans: - - operationName: /express + - operationName: GET:/express operationId: 0 parentSpanId: -1 spanId: 0 @@ -77,7 +77,7 @@ segmentItems: segments: - segmentId: not null spans: - - operationName: /test/express + - operationName: GET:/test/express operationId: 0 parentSpanId: -1 spanId: 0 diff --git a/tests/plugins/http/expected.data.yaml b/tests/plugins/http/expected.data.yaml index a75586c..c20180b 100644 --- a/tests/plugins/http/expected.data.yaml +++ b/tests/plugins/http/expected.data.yaml @@ -21,7 +21,7 @@ segmentItems: segments: - segmentId: not null spans: - - operationName: /test + - operationName: GET:/test operationId: 0 parentSpanId: -1 spanId: 0 @@ -77,7 +77,7 @@ segmentItems: segments: - segmentId: not null spans: - - operationName: /test + - operationName: GET:/test operationId: 0 parentSpanId: -1 spanId: 0 diff --git a/tests/plugins/ioredis/expected.data.yaml b/tests/plugins/ioredis/expected.data.yaml index d527352..352aeaf 100644 --- a/tests/plugins/ioredis/expected.data.yaml +++ b/tests/plugins/ioredis/expected.data.yaml @@ -66,7 +66,7 @@ segmentItems: tags: - { key: db.type, value: Redis } - { key: db.instance, value: "0" } - - operationName: /ioredis + - operationName: GET:/ioredis operationId: 0 parentSpanId: -1 spanId: 0 @@ -96,7 +96,7 @@ segmentItems: segments: - segmentId: not null spans: - - operationName: /ioredis + - operationName: GET:/ioredis operationId: 0 parentSpanId: -1 spanId: 0 diff --git a/tests/plugins/mongodb/expected.data.yaml b/tests/plugins/mongodb/expected.data.yaml index 5180198..83d1fa3 100644 --- a/tests/plugins/mongodb/expected.data.yaml +++ b/tests/plugins/mongodb/expected.data.yaml @@ -51,7 +51,7 @@ segmentItems: - { key: db.type, value: MongoDB } - { key: db.instance, value: admin } - { key: db.statement, value: docs.findOne() } - - operationName: /mongo + - operationName: GET:/mongo operationId: 0 parentSpanId: -1 spanId: 0 @@ -82,7 +82,7 @@ segmentItems: segments: - segmentId: not null spans: - - operationName: /mongo + - operationName: GET:/mongo operationId: 0 parentSpanId: -1 spanId: 0 diff --git a/tests/plugins/mongoose/expected.data.yaml b/tests/plugins/mongoose/expected.data.yaml index bc28d7e..b7a48d0 100644 --- a/tests/plugins/mongoose/expected.data.yaml +++ b/tests/plugins/mongoose/expected.data.yaml @@ -65,7 +65,7 @@ segmentItems: - { key: db.type, value: MongoDB } - { key: db.instance, value: admin } - { key: db.statement, value: 'tests.find({})' } - - operationName: /mongoose + - operationName: GET:/mongoose operationId: 0 parentSpanId: -1 spanId: 0 @@ -96,7 +96,7 @@ segmentItems: segments: - segmentId: not null spans: - - operationName: /mongoose + - operationName: GET:/mongoose operationId: 0 parentSpanId: -1 spanId: 0 diff --git a/tests/plugins/mysql/expected.data.yaml b/tests/plugins/mysql/expected.data.yaml index dd297fb..0fa6998 100644 --- a/tests/plugins/mysql/expected.data.yaml +++ b/tests/plugins/mysql/expected.data.yaml @@ -39,7 +39,7 @@ segmentItems: value: test - key: db.statement value: SELECT * FROM `user` WHERE `name` = "u1" - - operationName: /mysql + - operationName: GET:/mysql operationId: 0 parentSpanId: -1 spanId: 0 @@ -75,7 +75,7 @@ segmentItems: segments: - segmentId: not null spans: - - operationName: /mysql + - operationName: GET:/mysql operationId: 0 parentSpanId: -1 spanId: 0 diff --git a/tests/plugins/mysql2/expected.data.yaml b/tests/plugins/mysql2/expected.data.yaml index dd297fb..0fa6998 100644 --- a/tests/plugins/mysql2/expected.data.yaml +++ b/tests/plugins/mysql2/expected.data.yaml @@ -39,7 +39,7 @@ segmentItems: value: test - key: db.statement value: SELECT * FROM `user` WHERE `name` = "u1" - - operationName: /mysql + - operationName: GET:/mysql operationId: 0 parentSpanId: -1 spanId: 0 @@ -75,7 +75,7 @@ segmentItems: segments: - segmentId: not null spans: - - operationName: /mysql + - operationName: GET:/mysql operationId: 0 parentSpanId: -1 spanId: 0 diff --git a/tests/plugins/pg/expected.data.yaml b/tests/plugins/pg/expected.data.yaml index af77133..2c7bd06 100644 --- a/tests/plugins/pg/expected.data.yaml +++ b/tests/plugins/pg/expected.data.yaml @@ -36,7 +36,7 @@ segmentItems: - { key: db.type, value: PostgreSQL } - { key: db.instance, value: test } - { key: db.statement, value: SELECT * FROM "user" where name = 'u1' } - - operationName: /postgres + - operationName: GET:/postgres operationId: 0 parentSpanId: -1 spanId: 0 @@ -67,7 +67,7 @@ segmentItems: segments: - segmentId: not null spans: - - operationName: /postgres + - operationName: GET:/postgres operationId: 0 parentSpanId: -1 spanId: 0