public async probe()

in src/environment/ECSEnvironment.ts [68:94]


  public async probe(): Promise<boolean> {
    if (!process.env.ECS_CONTAINER_METADATA_URI) {
      return Promise.resolve(false);
    }

    if (process.env.FLUENT_HOST && !config.agentEndpoint) {
      this.fluentBitEndpoint = `tcp://${process.env.FLUENT_HOST}:${Constants.DEFAULT_AGENT_PORT}`;
      config.agentEndpoint = this.fluentBitEndpoint;
      LOG(`Using FluentBit configuration. Endpoint: ${this.fluentBitEndpoint}`);
    }

    try {
      this.metadata = await fetch<IECSMetadataResponse>(process.env.ECS_CONTAINER_METADATA_URI);
      if (this.metadata) {
        this.metadata.FormattedImageName = formatImageName(this.metadata.Image);
        LOG(`Successfully collected ECS Container metadata.`);
      }
    } catch (e) {
      LOG('Failed to collect ECS Container Metadata.');
      LOG(e);
    }

    // return true regardless of whether or not metadata collection
    // succeeded. we know that this is supposed to be an ECS environment
    // just from the environment variable
    return true;
  }