public static Configuration create()

in agent/agent-tooling/src/main/java/com/microsoft/applicationinsights/agent/internal/configuration/ConfigurationBuilder.java [112:175]


  public static Configuration create(Path agentJarPath, RpConfiguration rpConfiguration)
      throws IOException {
    Configuration config = loadConfigurationFile(agentJarPath);
    if (config.instrumentation.micrometer.reportingIntervalSeconds != 60) {
      configurationLogger.warn(
          "micrometer \"reportingIntervalSeconds\" setting leaked out previously"
              + " as an undocumented testing detail,"
              + " please use \"preview\": { \"metricIntervalSeconds\" } instead now"
              + " (and note that metricIntervalSeconds applies to all auto-collected metrics,"
              + " not only micrometer)");
    }
    if (config.preview.httpMethodInOperationName) {
      configurationLogger.warn(
          "\"httpMethodInOperationName\" is no longer in preview and it is now the"
              + " (one and only) default behavior");
    }
    if (config.preview.openTelemetryApiSupport) {
      configurationLogger.warn(
          "\"openTelemetryApiSupport\" is no longer in preview and it is now the"
              + " (one and only) default behavior");
    }
    if (config.preview.instrumentation.azureSdk.enabled) {
      configurationLogger.warn(
          "\"azureSdk\" instrumentation is no longer in preview"
              + " and it is now enabled by default,"
              + " so no need to enable it under preview configuration");
    }
    if (config.preview.instrumentation.javaHttpClient.enabled) {
      configurationLogger.warn(
          "\"javaHttpClient\" instrumentation is no longer in preview"
              + " and it is now enabled by default,"
              + " so no need to enable it under preview configuration");
    }
    if (config.preview.instrumentation.jaxws.enabled) {
      configurationLogger.warn(
          "\"jaxws\" instrumentation is no longer in preview"
              + " and it is now enabled by default,"
              + " so no need to enable it under preview configuration");
    }
    if (config.preview.instrumentation.rabbitmq.enabled) {
      configurationLogger.warn(
          "\"rabbitmq\" instrumentation is no longer in preview"
              + " and it is now enabled by default,"
              + " so no need to enable it under preview configuration");
    }

    overlayFromEnv(config);
    config.sampling.percentage = roundToNearest(config.sampling.percentage, true);
    for (SamplingOverride override : config.preview.sampling.overrides) {
      override.percentage = roundToNearest(override.percentage, true);
    }
    // rp configuration should always be last (so it takes precedence)
    // currently applicationinsights-rp.json is only used by Azure Spring Cloud
    if (rpConfiguration != null) {
      overlayFromEnv(rpConfiguration);
      overlayRpConfiguration(config, rpConfiguration);
    }
    // only set role instance to host name as a last resort
    if (config.role.instance == null) {
      String hostname = HostName.get();
      config.role.instance = hostname == null ? "unknown" : hostname;
    }
    return config;
  }