Skip to content

new http.Agent() is created for each socket in collector exporter instead of using single agent for all requests #1840

@blumamir

Description

@blumamir

What version of OpenTelemetry are you using?

v0.14.0

What version of Node are you using?

12

This code from collector exporter creates a new Agent for each HTTP export request via the collector exporter:

export function sendWithHttp<ExportItem, ServiceRequest>(...): void {

  ...

  const request = parsedUrl.protocol === 'http:' ? http.request : https.request;
  const Agent = parsedUrl.protocol === 'http:' ? http.Agent : https.Agent;
  if (collector.keepAlive) {
    options.agent = new Agent({
      ...collector.httpAgentOptions,
      keepAlive: true,
    });
  }

  const req = request(options, (res: http.IncomingMessage) => {

I might be missing something, but shouldn't all the HTTP requests reuse the same Agent, in order to benefit from its connection persistence and reuse?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions