Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes to prepare GA Spring Monitor #41909

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@

<!-- Identity and opentelemetry tracing are plugin packages and shouldn't be referenced -->
<suppress checks="IllegalImport" files=".*[/\\]com[/\\]azure[/\\]monitor[/\\]opentelemetry[/\\]exporter[/\\]*"/>
<suppress checks="IllegalImport" files=".*[/\\]com[/\\]azure[/\\]monitor[/\\]applicationinsights[/\\]spring[/\\]*"/>
<suppress checks="IllegalImport" files=".*[/\\]com[/\\]azure[/\\]spring[/\\]cloud[/\\]autoconfigure[/\\]monitor[/\\]*"/>
<suppress checks="IllegalImport" files=".*[/\\]com[/\\]azure[/\\]identity[/\\]*"/>
<suppress checks="IllegalImport" files="com.azure.messaging.servicebus.IntegrationTestBase.java"/>
<suppress checks="IllegalImport" files="com.azure.messaging.servicebus.TracingIntegrationTests.java"/>
Expand All @@ -85,16 +85,6 @@
<suppress checks="IllegalImport" files="com.azure.messaging.eventhubs.PublishEventsTracingWithCustomContextSample.java"/>
<suppress checks="IllegalImport" files="com.azure.messaging.eventhubs.EventProcessorWithTracingClientSample.java"/>

<!-- AzureSpringMonitorConfig defines Spring bean used in https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/main/instrumentation/spring/spring-boot-autoconfigure/src/main/java/io/opentelemetry/instrumentation/spring/autoconfigure/OpenTelemetryAutoConfiguration.java-->
<suppress checks="com.azure.tools.checkstyle.checks.ExternalDependencyExposedCheck"
files="com.azure.monitor.applicationinsights.spring.AzureSpringMonitorAutoConfig.java"/>
<!-- To be able to return a configured loggger for self-diagnostics and use it as a Spring bean-->
<suppress checks="com.azure.tools.checkstyle.checks.ExternalDependencyExposedCheck"
files="com.azure.monitor.applicationinsights.spring.selfdiagnostics.*Log.*Config.*.java"/>

<!-- For the Application Insights Spring Boot starter for Spring native, users have only to declare the starter dependency. Users won't manipulate the Java classes of this Spring Boot starter. -->
<suppress checks="Javadoc" files=".*[/\\]com[/\\]azure[/\\]monitor[/\\]applicationinsights[/\\]spring[/\\]*"/>

<!-- Suppress external dependency Checkstyle on Event Hubs Stress Test packages as it use spring framework and may directly use external dependencies -->
<suppress checks="com.azure.tools.checkstyle.checks.ExternalDependencyExposedCheck"
files="com.azure.messaging.eventhubs.stress.*\.java"/>
Expand Down Expand Up @@ -312,9 +302,6 @@ the main ServiceBusClientBuilder. -->
<!-- GoodLoggingCheck: Spring as a framework, will not directly use ClientLogger-->
<suppress checks="com.azure.tools.checkstyle.checks.(GoodLoggingCheck|ThrowFromClientLoggerCheck|UseCaughtExceptionCauseCheck)" files=".*[/\\]com[/\\]azure[/\\]spring[/\\].*"/>

<!-- Can be removed after https://github.com/Azure/azure-sdk-for-java/issues/36609 -->
<suppress checks="com.azure.tools.checkstyle.checks.(GoodLoggingCheck|ThrowFromClientLoggerCheck|UseCaughtExceptionCauseCheck)" files="com.azure.monitor.applicationinsights.spring.*.java"/>

<!-- ExternalDependencyExposedCheck: Spring will directly use classes from spring dependencies in methods-->
<suppress checks="com.azure.tools.checkstyle.checks.ExternalDependencyExposedCheck" files=".*[/\\]com[/\\]azure[/\\]spring[/\\].*"/>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
package com.azure.monitor.applicationinsights.spring;
package com.azure.spring.cloud.autoconfigure.monitor;

import com.azure.core.http.HttpPipelineCallContext;
import com.azure.core.http.HttpPipelineNextPolicy;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
package com.azure.monitor.applicationinsights.spring;
package com.azure.spring.cloud.autoconfigure.monitor;

import com.azure.Application;
import com.azure.Controller;
Expand All @@ -10,11 +10,10 @@
import com.azure.core.http.policy.HttpPipelinePolicy;
import com.azure.json.JsonProviders;
import com.azure.json.JsonReader;
import com.azure.monitor.applicationinsights.spring.selfdiagnostics.SelfDiagnosticsLevel;
import com.azure.spring.cloud.autoconfigure.monitor.selfdiagnostics.SelfDiagnosticsLevel;
import com.azure.monitor.opentelemetry.exporter.implementation.models.*;
import io.opentelemetry.sdk.common.internal.OtelVersion;
import org.jetbrains.annotations.NotNull;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.azure.monitor.applicationinsights.spring;
package com.azure.spring.cloud.autoconfigure.monitor;

import com.azure.core.http.HttpPipeline;
import com.azure.monitor.opentelemetry.exporter.AzureMonitorExporterBuilder;
Expand All @@ -24,14 +24,14 @@
import java.util.function.Function;

/**
* Auto config for Azure Spring Monitor
* Auto-configuration for Azure Monitor OpenTelemetry Distro / Application Insights in Spring Boot native image Java application.
*/
@Configuration(proxyBeanMethods = false)
@AutoConfigureBefore(OpenTelemetryAutoConfiguration.class)
@ConditionalOnProperty(name = "otel.sdk.disabled", havingValue = "false", matchIfMissing = true)
public class AzureSpringMonitorAutoConfig {
class AzureSpringMonitorAutoConfiguration {

private static final Logger LOG = LoggerFactory.getLogger(AzureSpringMonitorAutoConfig.class);
private static final Logger LOG = LoggerFactory.getLogger(AzureSpringMonitorAutoConfiguration.class);

private static final Function<ConfigProperties, Map<String, String>> OTEL_DISABLE_CONFIG = configProperties -> {
Map<String, String> properties = new HashMap<>();
Expand All @@ -57,7 +57,7 @@ public class AzureSpringMonitorAutoConfig {
* @param connectionString connection string system property
* @param httpPipeline an instance of HttpPipeline
*/
AzureSpringMonitorAutoConfig(@Value("${applicationinsights.connection.string:}") String connectionString, ObjectProvider<HttpPipeline> httpPipeline) {
AzureSpringMonitorAutoConfiguration(@Value("${applicationinsights.connection.string:}") String connectionString, ObjectProvider<HttpPipeline> httpPipeline) {
this.connectionString = connectionString;
this.httpPipeline = httpPipeline;
if (!isNativeRuntimeExecution()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
package com.azure.monitor.applicationinsights.spring;
package com.azure.spring.cloud.autoconfigure.monitor;

import java.util.Comparator;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
package com.azure.monitor.applicationinsights.spring;
package com.azure.spring.cloud.autoconfigure.monitor;

import io.opentelemetry.sdk.common.internal.OtelVersion;
import org.slf4j.Logger;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.azure.monitor.applicationinsights.spring;
package com.azure.spring.cloud.autoconfigure.monitor;

class WrongConnectionStringException extends RuntimeException {

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

/**
* Package containing classes for Azure Monitor OpenTelemetry Distro / Application Insights in Spring Boot native image Java application.
*/
package com.azure.spring.cloud.autoconfigure.monitor;
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.azure.monitor.applicationinsights.spring.selfdiagnostics;
package com.azure.spring.cloud.autoconfigure.monitor.selfdiagnostics;

/**
* This enum allows you to define a self-diagnostics level.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.azure.monitor.applicationinsights.spring.selfdiagnostics.implementation;
package com.azure.spring.cloud.autoconfigure.monitor.selfdiagnostics.implementation;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.azure.monitor.applicationinsights.spring.selfdiagnostics.implementation;
package com.azure.spring.cloud.autoconfigure.monitor.selfdiagnostics.implementation;

import org.slf4j.Logger;
import org.springframework.boot.CommandLineRunner;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.azure.monitor.applicationinsights.spring.selfdiagnostics.implementation;
package com.azure.spring.cloud.autoconfigure.monitor.selfdiagnostics.implementation;

import ch.qos.logback.classic.Level;
import com.azure.monitor.applicationinsights.spring.selfdiagnostics.SelfDiagnosticsLevel;
import com.azure.spring.cloud.autoconfigure.monitor.selfdiagnostics.SelfDiagnosticsLevel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.azure.monitor.applicationinsights.spring.selfdiagnostics.implementation;
package com.azure.spring.cloud.autoconfigure.monitor.selfdiagnostics.implementation;

import io.opentelemetry.api.OpenTelemetry;
import io.opentelemetry.instrumentation.spring.autoconfigure.OpenTelemetryAutoConfiguration;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.azure.monitor.applicationinsights.spring.selfdiagnostics.implementation;
package com.azure.spring.cloud.autoconfigure.monitor.selfdiagnostics.implementation;

import com.azure.monitor.applicationinsights.spring.selfdiagnostics.SelfDiagnosticsLevel;
import com.azure.spring.cloud.autoconfigure.monitor.selfdiagnostics.SelfDiagnosticsLevel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.azure.monitor.applicationinsights.spring.selfdiagnostics.implementation;
package com.azure.spring.cloud.autoconfigure.monitor.selfdiagnostics.implementation;

// Class used for logging
final class SelfDiagnostics {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

/**
* Package containing the self-diagnostics for Azure Monitor OpenTelemetry Distro / Application Insights in Spring Boot native image Java application.
*/
package com.azure.spring.cloud.autoconfigure.monitor.selfdiagnostics;
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
com.azure.monitor.applicationinsights.spring.AzureSpringMonitorAutoConfig
com.azure.monitor.applicationinsights.spring.selfdiagnostics.implementation.SelfDiagAutoConfig
com.azure.spring.cloud.autoconfigure.monitor.AzureSpringMonitorAutoConfiguration
com.azure.spring.cloud.autoconfigure.monitor.selfdiagnostics.implementation.SelfDiagAutoConfig
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
package com.azure.monitor.applicationinsights.spring;
package com.azure.spring.cloud.autoconfigure.monitor;

import org.junit.jupiter.api.Test;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
package com.azure.monitor.applicationinsights.spring;
package com.azure.spring.cloud.autoconfigure.monitor;

import com.azure.monitor.applicationinsights.spring.selfdiagnostics.implementation.SelfDiagAutoConfig;
import com.azure.spring.cloud.autoconfigure.monitor.selfdiagnostics.implementation.SelfDiagAutoConfig;
import org.junit.jupiter.api.Test;
import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
Expand All @@ -14,7 +14,7 @@ class SpringContextTest {
// The tests of the Spring Monitor features are done in the spring-cloud-azure-starter-monitor-test Maven module
@Test
void loadContext() {
this.contextRunner.withConfiguration(AutoConfigurations.of(AzureSpringMonitorAutoConfig.class, SelfDiagAutoConfig.class)).run(context -> {
this.contextRunner.withConfiguration(AutoConfigurations.of(AzureSpringMonitorAutoConfiguration.class, SelfDiagAutoConfig.class)).run(context -> {
});
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
package com.azure.monitor.applicationinsights.spring;
package com.azure.spring.cloud.autoconfigure.monitor;

import com.azure.core.util.CoreUtils;
import org.junit.jupiter.api.Test;
Expand Down
Loading