port: Number()

in src/sinks/AgentSink.ts [60:92]


      port: Number(parsedUrl.port),
      protocol: parsedUrl.protocol,
    };
  } catch (e) {
    LOG('Failed to parse the provided agent endpoint', e);
    return defaultTcpEndpoint;
  }
};

/**
 * A sink that flushes to the CW Agent.
 * This sink instance should be re-used to avoid
 * leaking connections.
 */
export class AgentSink implements ISink {
  public readonly name: string = 'AgentSink';
  private readonly serializer: ISerializer;
  private readonly endpoint: IEndpoint;
  private readonly logGroupName: string;
  private readonly logStreamName: string | undefined;
  private readonly socketClient: ISocketClient;

  constructor(logGroupName: string, logStreamName?: string, serializer?: ISerializer) {
    this.logGroupName = logGroupName;
    this.logStreamName = logStreamName;
    this.serializer = serializer || new LogSerializer();
    this.endpoint = parseEndpoint(Configuration.agentEndpoint);
    this.socketClient = this.getSocketClient(this.endpoint);
    LOG('Using socket client', this.socketClient.constructor.name);
  }

  public async accept(context: MetricsContext): Promise<void> {
    if (this.logGroupName) {