microsoft / azure-spring-boot

Spring Boot Starters for Azure services
MIT License
374 stars 460 forks source link

Spring boot app won't start without instrumentation key even when metrics publishing is disabled #785

Closed ghost closed 3 years ago

ghost commented 5 years ago

Environment

Summary

When disabling the publishing of metrics the instrumentation-key becomes irrelevant and shouldn't cause the app not to start when it's missing. As it stands you have to provide a dummy instrumentation key when you for example, are working on a development version of an app and don't want to publish any metrics.

Reproduce steps

Add metrics by adding in the following dependencies and setting:

azure.application-insights.trackingDisabled=true

NB

azure.application-insights.instrumentation-key is not set.

com.microsoft.azure:applicationinsights-spring-boot-starter:2.5.1 com.microsoft.azure:azure-spring-boot-metrics-starter:2.2.0

Expected Results

App should start with no metrics published

Actual Results

App fails to start, throws exception via this code in ApplicationInsightsTelemetryAutoConfiguration

  if (StringUtils.isEmpty(telemetryConfiguration.getInstrumentationKey())) {
        throw new IllegalStateException("Could not find instrumentation key or connection string");
    }
saragluna commented 5 years ago

Thanks for reaching out. It seems like the property azure.application-insights.instrumentation-key is introduced by applicationinsights-spring-boot-starter. So perhaps this is the right place to report this issue.

One more thing as I find in their doc, is it possible the wrong configuration is used?

# Enable/Disable tracking. Default value: true.
azure.application-insights.enabled=true
saragluna commented 5 years ago

Any update on this issue?

chenrujun commented 3 years ago

Closing this issue. Because it's not active for a long time. If anyone have similar issue, please create issue in new repo: https://github.com/Azure/azure-sdk-for-java/issues