Merge branch '2.6.x' into 2.7.x

Closes gh-30433
This commit is contained in:
Andy Wilkinson 2022-03-25 12:03:24 +00:00
commit 64888b0deb
7 changed files with 22 additions and 19 deletions

View File

@ -33,7 +33,6 @@ import io.micrometer.core.instrument.Tag;
import io.micrometer.core.instrument.Timer; import io.micrometer.core.instrument.Timer;
import org.springframework.boot.actuate.metrics.AutoTimer; import org.springframework.boot.actuate.metrics.AutoTimer;
import org.springframework.lang.Nullable;
/** /**
* Micrometer-based {@link SimpleInstrumentation}. * Micrometer-based {@link SimpleInstrumentation}.
@ -117,7 +116,7 @@ public class GraphQlMetricsInstrumentation extends SimpleInstrumentation {
} }
private void recordDataFetcherMetric(Timer.Sample sample, DataFetcher<?> dataFetcher, private void recordDataFetcherMetric(Timer.Sample sample, DataFetcher<?> dataFetcher,
InstrumentationFieldFetchParameters parameters, @Nullable Throwable throwable) { InstrumentationFieldFetchParameters parameters, Throwable throwable) {
Timer.Builder timer = this.autoTimer.builder("graphql.datafetcher"); Timer.Builder timer = this.autoTimer.builder("graphql.datafetcher");
timer.tags(this.tagsProvider.getDataFetchingTags(dataFetcher, parameters, throwable)); timer.tags(this.tagsProvider.getDataFetchingTags(dataFetcher, parameters, throwable));
sample.stop(timer.register(this.registry)); sample.stop(timer.register(this.registry));

View File

@ -27,7 +27,6 @@ import graphql.execution.instrumentation.parameters.InstrumentationFieldFetchPar
import graphql.schema.GraphQLObjectType; import graphql.schema.GraphQLObjectType;
import io.micrometer.core.instrument.Tag; import io.micrometer.core.instrument.Tag;
import org.springframework.lang.Nullable;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
/** /**
@ -48,7 +47,7 @@ public final class GraphQlTags {
} }
public static Tag executionOutcome(ExecutionResult result, @Nullable Throwable exception) { public static Tag executionOutcome(ExecutionResult result, Throwable exception) {
if (exception == null && result.getErrors().isEmpty()) { if (exception == null && result.getErrors().isEmpty()) {
return OUTCOME_SUCCESS; return OUTCOME_SUCCESS;
} }
@ -84,7 +83,7 @@ public final class GraphQlTags {
return Tag.of("errorPath", builder.toString()); return Tag.of("errorPath", builder.toString());
} }
public static Tag dataFetchingOutcome(@Nullable Throwable exception) { public static Tag dataFetchingOutcome(Throwable exception) {
return (exception != null) ? OUTCOME_ERROR : OUTCOME_SUCCESS; return (exception != null) ? OUTCOME_ERROR : OUTCOME_SUCCESS;
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2020-2021 the original author or authors. * Copyright 2020-2022 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -23,8 +23,6 @@ import graphql.execution.instrumentation.parameters.InstrumentationFieldFetchPar
import graphql.schema.DataFetcher; import graphql.schema.DataFetcher;
import io.micrometer.core.instrument.Tag; import io.micrometer.core.instrument.Tag;
import org.springframework.lang.Nullable;
/** /**
* A contributor of {@link Tag Tags} for Spring GraphQL-based request handling. Typically, * A contributor of {@link Tag Tags} for Spring GraphQL-based request handling. Typically,
* used by a {@link GraphQlTagsProvider} to provide tags in addition to its defaults. * used by a {@link GraphQlTagsProvider} to provide tags in addition to its defaults.
@ -35,11 +33,11 @@ import org.springframework.lang.Nullable;
public interface GraphQlTagsContributor { public interface GraphQlTagsContributor {
Iterable<Tag> getExecutionTags(InstrumentationExecutionParameters parameters, ExecutionResult result, Iterable<Tag> getExecutionTags(InstrumentationExecutionParameters parameters, ExecutionResult result,
@Nullable Throwable exception); Throwable exception);
Iterable<Tag> getErrorTags(InstrumentationExecutionParameters parameters, GraphQLError error); Iterable<Tag> getErrorTags(InstrumentationExecutionParameters parameters, GraphQLError error);
Iterable<Tag> getDataFetchingTags(DataFetcher<?> dataFetcher, InstrumentationFieldFetchParameters parameters, Iterable<Tag> getDataFetchingTags(DataFetcher<?> dataFetcher, InstrumentationFieldFetchParameters parameters,
@Nullable Throwable exception); Throwable exception);
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2020-2021 the original author or authors. * Copyright 2020-2022 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -23,8 +23,6 @@ import graphql.execution.instrumentation.parameters.InstrumentationFieldFetchPar
import graphql.schema.DataFetcher; import graphql.schema.DataFetcher;
import io.micrometer.core.instrument.Tag; import io.micrometer.core.instrument.Tag;
import org.springframework.lang.Nullable;
/** /**
* Provides {@link Tag Tags} for Spring GraphQL-based request handling. * Provides {@link Tag Tags} for Spring GraphQL-based request handling.
* *
@ -34,11 +32,11 @@ import org.springframework.lang.Nullable;
public interface GraphQlTagsProvider { public interface GraphQlTagsProvider {
Iterable<Tag> getExecutionTags(InstrumentationExecutionParameters parameters, ExecutionResult result, Iterable<Tag> getExecutionTags(InstrumentationExecutionParameters parameters, ExecutionResult result,
@Nullable Throwable exception); Throwable exception);
Iterable<Tag> getErrorTags(InstrumentationExecutionParameters parameters, GraphQLError error); Iterable<Tag> getErrorTags(InstrumentationExecutionParameters parameters, GraphQLError error);
Iterable<Tag> getDataFetchingTags(DataFetcher<?> dataFetcher, InstrumentationFieldFetchParameters parameters, Iterable<Tag> getDataFetchingTags(DataFetcher<?> dataFetcher, InstrumentationFieldFetchParameters parameters,
@Nullable Throwable exception); Throwable exception);
} }

View File

@ -27,8 +27,6 @@ import java.util.Enumeration;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import org.jetbrains.annotations.NotNull;
import org.springframework.core.io.UrlResource; import org.springframework.core.io.UrlResource;
import org.springframework.util.Assert; import org.springframework.util.Assert;
@ -54,7 +52,6 @@ public final class ImportCandidates implements Iterable<String> {
this.candidates = Collections.unmodifiableList(candidates); this.candidates = Collections.unmodifiableList(candidates);
} }
@NotNull
@Override @Override
public Iterator<String> iterator() { public Iterator<String> iterator() {
return this.candidates.iterator(); return this.candidates.iterator();

View File

@ -13,7 +13,8 @@
name="com.puppycrawl.tools.checkstyle.checks.imports.IllegalImportCheck"> name="com.puppycrawl.tools.checkstyle.checks.imports.IllegalImportCheck">
<property name="regexp" value="true" /> <property name="regexp" value="true" />
<property name="illegalPkgs" <property name="illegalPkgs"
value="^sun.*, ^org\.apache\.commons\.(?!compress|dbcp2|logging|pool2).*, ^com\.datastax\.oss\.driver\.shaded.*, ^com\.google\.common.*, ^io\.micrometer\.shaded.*, ^org\.testcontainers\.shaded.*" /> value="^sun.*, ^org\.apache\.commons\.(?!compress|dbcp2|logging|pool2).*, ^com\.datastax\.oss\.driver\.shaded.*, ^com\.google\.common.*, ^io\.micrometer\.shaded.*,
^org\.jetbrains\.annotations.*, ^org\.testcontainers\.shaded.*" />
<property name="illegalClasses" <property name="illegalClasses"
value="^com\.hazelcast\.util\.Base64, ^org\.junit\.rules\.ExpectedException, ^org\.mockito\.InjectMocks, ^org\.slf4j\.LoggerFactory, ^org.springframework.context.annotation.ScannedGenericBeanDefinition, ^reactor\.core\.support\.Assert"/> value="^com\.hazelcast\.util\.Base64, ^org\.junit\.rules\.ExpectedException, ^org\.mockito\.InjectMocks, ^org\.slf4j\.LoggerFactory, ^org.springframework.context.annotation.ScannedGenericBeanDefinition, ^reactor\.core\.support\.Assert"/>
</module> </module>

View File

@ -2,6 +2,7 @@
<!DOCTYPE import-control PUBLIC "-//Checkstyle//DTD ImportControl Configuration 1.4//EN" "https://checkstyle.org/dtds/import_control_1_4.dtd"> <!DOCTYPE import-control PUBLIC "-//Checkstyle//DTD ImportControl Configuration 1.4//EN" "https://checkstyle.org/dtds/import_control_1_4.dtd">
<import-control pkg="org.springframework.boot"> <import-control pkg="org.springframework.boot">
<disallow pkg="io.micrometer" /> <disallow pkg="io.micrometer" />
<disallow pkg="org.springframework.lang" />
<allow pkg=".*" regex="true" /> <allow pkg=".*" regex="true" />
<subpackage name="autoconfigure"> <subpackage name="autoconfigure">
<disallow class="org.springframework.boot.autoconfigure.jdbc.DataSourceProperties"/> <disallow class="org.springframework.boot.autoconfigure.jdbc.DataSourceProperties"/>
@ -45,6 +46,13 @@
<subpackage name="endpoint"> <subpackage name="endpoint">
<disallow pkg="org.springframework.http" /> <disallow pkg="org.springframework.http" />
<disallow pkg="org.springframework.web" /> <disallow pkg="org.springframework.web" />
<subpackage name="invoke">
<subpackage name="reflect">
<file name="OperationMethodParameter">
<allow pkg="org.springframework.lang"/>
</file>
</subpackage>
</subpackage>
<subpackage name="web"> <subpackage name="web">
<allow pkg="org.springframework.http" /> <allow pkg="org.springframework.http" />
<allow pkg="org.springframework.web" /> <allow pkg="org.springframework.web" />
@ -56,6 +64,9 @@
</subpackage> </subpackage>
</subpackage> </subpackage>
</subpackage> </subpackage>
<file name=".*Endpoint(WebExtension)?" regex="true">
<allow pkg="org.springframework.lang"/>
</file>
</subpackage> </subpackage>
<subpackage name="docs"> <subpackage name="docs">