module.Server.prototype.addListener = module.Server.prototype.on = function()

in src/plugins/HttpPlugin.ts [154:175]


    module.Server.prototype.addListener = module.Server.prototype.on = function (
      event: any,
      handler: any,
      ...addArgs: any[]
    ) {
      return _addListener.call(this, event, event === 'request' ? _sw_request : handler, ...addArgs);

      function _sw_request(this: any, req: IncomingMessage, res: ServerResponse, ...reqArgs: any[]) {
        const carrier = ContextCarrier.from((req as any).headers || {});
        const reqMethod = req.method ?? 'GET';
        const operation = reqMethod + ':' + (req.url || '/').replace(/\?.*/g, '');
        const span = ignoreHttpMethodCheck(reqMethod)
          ? DummySpan.create()
          : ContextManager.current.newEntrySpan(operation, carrier);

        span.component = Component.HTTP_SERVER;

        span.tag(Tag.httpURL(protocol + '://' + (req.headers.host || '') + req.url));

        return plugin.wrapHttpResponse(span, req, res, () => handler.call(this, req, res, ...reqArgs));
      }
    };