Compare commits
No commits in common. 'main' and '3.1.x' have entirely different histories.
@ -1,18 +1,18 @@
|
||||
version=3.2.0-SNAPSHOT
|
||||
version=3.1.5-SNAPSHOT
|
||||
|
||||
org.gradle.caching=true
|
||||
org.gradle.parallel=true
|
||||
org.gradle.jvmargs=-Xmx2g -Dfile.encoding=UTF-8
|
||||
|
||||
assertjVersion=3.24.2
|
||||
commonsCodecVersion=1.16.0
|
||||
commonsCodecVersion=1.15
|
||||
hamcrestVersion=2.2
|
||||
jacksonVersion=2.15.2
|
||||
junitJupiterVersion=5.10.0
|
||||
kotlinVersion=1.9.10
|
||||
junitJupiterVersion=5.9.3
|
||||
kotlinVersion=1.8.22
|
||||
mavenVersion=3.9.4
|
||||
nativeBuildToolsVersion=0.9.27
|
||||
springFrameworkVersion=6.1.0-SNAPSHOT
|
||||
springFrameworkVersion=6.0.13-SNAPSHOT
|
||||
tomcatVersion=10.1.13
|
||||
|
||||
kotlin.stdlib.default.dependency=false
|
||||
|
@ -1,6 +1,6 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.3-bin.zip
|
||||
networkTimeout=10000
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
@ -1,60 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.actuate.autoconfigure.metrics;
|
||||
|
||||
import io.micrometer.core.aop.CountedAspect;
|
||||
import io.micrometer.core.aop.MeterTagAnnotationHandler;
|
||||
import io.micrometer.core.aop.TimedAspect;
|
||||
import io.micrometer.core.instrument.MeterRegistry;
|
||||
import org.aspectj.weaver.Advice;
|
||||
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
|
||||
/**
|
||||
* {@link EnableAutoConfiguration Auto-configuration} for Micrometer-based metrics
|
||||
* aspects.
|
||||
*
|
||||
* @author Jonatan Ivanov
|
||||
* @since 3.2.0
|
||||
*/
|
||||
@AutoConfiguration(after = { MetricsAutoConfiguration.class, CompositeMeterRegistryAutoConfiguration.class })
|
||||
@ConditionalOnClass({ MeterRegistry.class, Advice.class })
|
||||
@ConditionalOnBean(MeterRegistry.class)
|
||||
public class MetricsAspectsAutoConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
CountedAspect countedAspect(MeterRegistry registry) {
|
||||
return new CountedAspect(registry);
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
TimedAspect timedAspect(MeterRegistry registry,
|
||||
ObjectProvider<MeterTagAnnotationHandler> meterTagAnnotationHandler) {
|
||||
TimedAspect timedAspect = new TimedAspect(registry);
|
||||
meterTagAnnotationHandler.ifAvailable(timedAspect::setMeterTagAnnotationHandler);
|
||||
return timedAspect;
|
||||
}
|
||||
|
||||
}
|
@ -1,35 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.actuate.autoconfigure.metrics.export.otlp;
|
||||
|
||||
import org.springframework.boot.autoconfigure.service.connection.ConnectionDetails;
|
||||
|
||||
/**
|
||||
* Details required to establish a connection to a OpenTelemetry Collector service.
|
||||
*
|
||||
* @author Eddú Meléndez
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public interface OtlpMetricsConnectionDetails extends ConnectionDetails {
|
||||
|
||||
/**
|
||||
* Address to where metrics will be published.
|
||||
* @return the address to where metrics will be published
|
||||
*/
|
||||
String getUrl();
|
||||
|
||||
}
|
@ -1,83 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.actuate.autoconfigure.observation;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import io.micrometer.common.KeyValues;
|
||||
import io.micrometer.observation.Observation.Context;
|
||||
import io.micrometer.observation.ObservationFilter;
|
||||
import io.micrometer.observation.ObservationPredicate;
|
||||
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* {@link ObservationFilter} to apply settings from {@link ObservationProperties}.
|
||||
*
|
||||
* @author Moritz Halbritter
|
||||
*/
|
||||
class PropertiesObservationFilterPredicate implements ObservationFilter, ObservationPredicate {
|
||||
|
||||
private final ObservationFilter commonKeyValuesFilter;
|
||||
|
||||
private final ObservationProperties properties;
|
||||
|
||||
PropertiesObservationFilterPredicate(ObservationProperties properties) {
|
||||
this.properties = properties;
|
||||
this.commonKeyValuesFilter = createCommonKeyValuesFilter(properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Context map(Context context) {
|
||||
return this.commonKeyValuesFilter.map(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(String name, Context context) {
|
||||
return lookupWithFallbackToAll(this.properties.getEnable(), name, true);
|
||||
}
|
||||
|
||||
private static <T> T lookupWithFallbackToAll(Map<String, T> values, String name, T defaultValue) {
|
||||
if (values.isEmpty()) {
|
||||
return defaultValue;
|
||||
}
|
||||
return doLookup(values, name, () -> values.getOrDefault("all", defaultValue));
|
||||
}
|
||||
|
||||
private static <T> T doLookup(Map<String, T> values, String name, Supplier<T> defaultValue) {
|
||||
while (StringUtils.hasLength(name)) {
|
||||
T result = values.get(name);
|
||||
if (result != null) {
|
||||
return result;
|
||||
}
|
||||
int lastDot = name.lastIndexOf('.');
|
||||
name = (lastDot != -1) ? name.substring(0, lastDot) : "";
|
||||
}
|
||||
return defaultValue.get();
|
||||
}
|
||||
|
||||
private static ObservationFilter createCommonKeyValuesFilter(ObservationProperties properties) {
|
||||
if (properties.getKeyValues().isEmpty()) {
|
||||
return (context) -> context;
|
||||
}
|
||||
KeyValues keyValues = KeyValues.of(properties.getKeyValues().entrySet(), Entry::getKey, Entry::getValue);
|
||||
return (context) -> context.addLowCardinalityKeyValues(keyValues);
|
||||
}
|
||||
|
||||
}
|
@ -1,72 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.actuate.autoconfigure.observation.jms;
|
||||
|
||||
import io.micrometer.jakarta9.instrument.jms.JmsPublishObservationContext;
|
||||
import io.micrometer.observation.Observation;
|
||||
import io.micrometer.observation.ObservationRegistry;
|
||||
import jakarta.jms.Message;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
import org.springframework.beans.factory.config.BeanPostProcessor;
|
||||
import org.springframework.boot.actuate.autoconfigure.observation.ObservationAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.boot.autoconfigure.jms.JmsAutoConfiguration;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.jms.core.JmsTemplate;
|
||||
|
||||
/**
|
||||
* {@link EnableAutoConfiguration Auto-configuration} for instrumenting
|
||||
* {@link JmsTemplate} beans for Observability.
|
||||
*
|
||||
* @author Brian Clozel
|
||||
* @since 3.2.0
|
||||
*/
|
||||
@AutoConfiguration(after = { JmsAutoConfiguration.class, ObservationAutoConfiguration.class })
|
||||
@ConditionalOnBean({ ObservationRegistry.class, JmsTemplate.class })
|
||||
@ConditionalOnClass({ Observation.class, Message.class, JmsTemplate.class, JmsPublishObservationContext.class })
|
||||
public class JmsTemplateObservationAutoConfiguration {
|
||||
|
||||
@Bean
|
||||
static JmsTemplateObservationPostProcessor jmsTemplateObservationPostProcessor(
|
||||
ObjectProvider<ObservationRegistry> observationRegistry) {
|
||||
return new JmsTemplateObservationPostProcessor(observationRegistry);
|
||||
}
|
||||
|
||||
static class JmsTemplateObservationPostProcessor implements BeanPostProcessor {
|
||||
|
||||
private final ObjectProvider<ObservationRegistry> observationRegistry;
|
||||
|
||||
JmsTemplateObservationPostProcessor(ObjectProvider<ObservationRegistry> observationRegistry) {
|
||||
this.observationRegistry = observationRegistry;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
|
||||
if (bean instanceof JmsTemplate jmsTemplate) {
|
||||
this.observationRegistry.ifAvailable(jmsTemplate::setObservationRegistry);
|
||||
}
|
||||
return bean;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Auto-configuration for JMS observations.
|
||||
*/
|
||||
package org.springframework.boot.actuate.autoconfigure.observation.jms;
|
@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.actuate.autoconfigure.observation.web.client;
|
||||
|
||||
import io.micrometer.common.KeyValues;
|
||||
import io.micrometer.core.instrument.Tag;
|
||||
|
||||
import org.springframework.boot.actuate.metrics.web.client.RestTemplateExchangeTagsProvider;
|
||||
import org.springframework.http.client.observation.ClientRequestObservationContext;
|
||||
import org.springframework.http.client.observation.ClientRequestObservationConvention;
|
||||
|
||||
/**
|
||||
* Adapter class that applies {@link RestTemplateExchangeTagsProvider} tags as a
|
||||
* {@link ClientRequestObservationConvention}.
|
||||
*
|
||||
* @author Brian Clozel
|
||||
*/
|
||||
@SuppressWarnings({ "removal" })
|
||||
class ClientHttpObservationConventionAdapter implements ClientRequestObservationConvention {
|
||||
|
||||
private final String metricName;
|
||||
|
||||
private final RestTemplateExchangeTagsProvider tagsProvider;
|
||||
|
||||
ClientHttpObservationConventionAdapter(String metricName, RestTemplateExchangeTagsProvider tagsProvider) {
|
||||
this.metricName = metricName;
|
||||
this.tagsProvider = tagsProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public KeyValues getLowCardinalityKeyValues(ClientRequestObservationContext context) {
|
||||
Iterable<Tag> tags = this.tagsProvider.getTags(context.getUriTemplate(), context.getCarrier(),
|
||||
context.getResponse());
|
||||
return KeyValues.of(tags, Tag::getKey, Tag::getValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public KeyValues getHighCardinalityKeyValues(ClientRequestObservationContext context) {
|
||||
return KeyValues.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.metricName;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,76 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.actuate.autoconfigure.observation.web.client;
|
||||
|
||||
import io.micrometer.common.KeyValues;
|
||||
import io.micrometer.core.instrument.Tag;
|
||||
import io.micrometer.observation.Observation;
|
||||
|
||||
import org.springframework.boot.actuate.metrics.web.reactive.client.WebClientExchangeTagsProvider;
|
||||
import org.springframework.core.Conventions;
|
||||
import org.springframework.web.reactive.function.client.ClientRequest;
|
||||
import org.springframework.web.reactive.function.client.ClientRequestObservationContext;
|
||||
import org.springframework.web.reactive.function.client.ClientRequestObservationConvention;
|
||||
import org.springframework.web.reactive.function.client.WebClient;
|
||||
|
||||
/**
|
||||
* Adapter class that applies {@link WebClientExchangeTagsProvider} tags as a
|
||||
* {@link ClientRequestObservationConvention}.
|
||||
*
|
||||
* @author Brian Clozel
|
||||
*/
|
||||
@SuppressWarnings("removal")
|
||||
class ClientObservationConventionAdapter implements ClientRequestObservationConvention {
|
||||
|
||||
private static final String URI_TEMPLATE_ATTRIBUTE = Conventions.getQualifiedAttributeName(WebClient.class,
|
||||
"uriTemplate");
|
||||
|
||||
private final String metricName;
|
||||
|
||||
private final WebClientExchangeTagsProvider tagsProvider;
|
||||
|
||||
ClientObservationConventionAdapter(String metricName, WebClientExchangeTagsProvider tagsProvider) {
|
||||
this.metricName = metricName;
|
||||
this.tagsProvider = tagsProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsContext(Observation.Context context) {
|
||||
return context instanceof ClientRequestObservationContext;
|
||||
}
|
||||
|
||||
@Override
|
||||
public KeyValues getLowCardinalityKeyValues(ClientRequestObservationContext context) {
|
||||
ClientRequest request = context.getRequest();
|
||||
if (request == null) {
|
||||
request = context.getCarrier().attribute(URI_TEMPLATE_ATTRIBUTE, context.getUriTemplate()).build();
|
||||
}
|
||||
Iterable<Tag> tags = this.tagsProvider.tags(request, context.getResponse(), context.getError());
|
||||
return KeyValues.of(tags, Tag::getKey, Tag::getValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public KeyValues getHighCardinalityKeyValues(ClientRequestObservationContext context) {
|
||||
return KeyValues.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.metricName;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,79 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.actuate.autoconfigure.observation.web.reactive;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.micrometer.common.KeyValues;
|
||||
import io.micrometer.core.instrument.Tag;
|
||||
|
||||
import org.springframework.boot.actuate.metrics.web.reactive.server.DefaultWebFluxTagsProvider;
|
||||
import org.springframework.boot.actuate.metrics.web.reactive.server.WebFluxTagsContributor;
|
||||
import org.springframework.boot.actuate.metrics.web.reactive.server.WebFluxTagsProvider;
|
||||
import org.springframework.http.codec.ServerCodecConfigurer;
|
||||
import org.springframework.http.server.reactive.observation.ServerRequestObservationContext;
|
||||
import org.springframework.http.server.reactive.observation.ServerRequestObservationConvention;
|
||||
import org.springframework.web.server.adapter.DefaultServerWebExchange;
|
||||
import org.springframework.web.server.i18n.AcceptHeaderLocaleContextResolver;
|
||||
import org.springframework.web.server.i18n.LocaleContextResolver;
|
||||
import org.springframework.web.server.session.DefaultWebSessionManager;
|
||||
import org.springframework.web.server.session.WebSessionManager;
|
||||
|
||||
/**
|
||||
* Adapter class that applies {@link WebFluxTagsProvider} tags as a
|
||||
* {@link ServerRequestObservationConvention}.
|
||||
*
|
||||
* @author Brian Clozel
|
||||
*/
|
||||
@SuppressWarnings("removal")
|
||||
@Deprecated(since = "3.0.0", forRemoval = true)
|
||||
class ServerRequestObservationConventionAdapter implements ServerRequestObservationConvention {
|
||||
|
||||
private final WebSessionManager webSessionManager = new DefaultWebSessionManager();
|
||||
|
||||
private final ServerCodecConfigurer serverCodecConfigurer = ServerCodecConfigurer.create();
|
||||
|
||||
private final LocaleContextResolver localeContextResolver = new AcceptHeaderLocaleContextResolver();
|
||||
|
||||
private final String name;
|
||||
|
||||
private final WebFluxTagsProvider tagsProvider;
|
||||
|
||||
ServerRequestObservationConventionAdapter(String name, WebFluxTagsProvider tagsProvider) {
|
||||
this.name = name;
|
||||
this.tagsProvider = tagsProvider;
|
||||
}
|
||||
|
||||
ServerRequestObservationConventionAdapter(String name, List<WebFluxTagsContributor> contributors) {
|
||||
this(name, new DefaultWebFluxTagsProvider(contributors));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public KeyValues getLowCardinalityKeyValues(ServerRequestObservationContext context) {
|
||||
DefaultServerWebExchange serverWebExchange = new DefaultServerWebExchange(context.getCarrier(),
|
||||
context.getResponse(), this.webSessionManager, this.serverCodecConfigurer, this.localeContextResolver);
|
||||
serverWebExchange.getAttributes().putAll(context.getAttributes());
|
||||
Iterable<Tag> tags = this.tagsProvider.httpRequestTags(serverWebExchange, context.getError());
|
||||
return KeyValues.of(tags, Tag::getKey, Tag::getValue);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,76 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.actuate.autoconfigure.observation.web.servlet;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.micrometer.common.KeyValues;
|
||||
import io.micrometer.core.instrument.Tag;
|
||||
import io.micrometer.observation.Observation;
|
||||
|
||||
import org.springframework.boot.actuate.metrics.web.servlet.DefaultWebMvcTagsProvider;
|
||||
import org.springframework.boot.actuate.metrics.web.servlet.WebMvcTagsContributor;
|
||||
import org.springframework.boot.actuate.metrics.web.servlet.WebMvcTagsProvider;
|
||||
import org.springframework.http.server.observation.ServerRequestObservationContext;
|
||||
import org.springframework.http.server.observation.ServerRequestObservationConvention;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.web.servlet.HandlerMapping;
|
||||
|
||||
/**
|
||||
* Adapter class that applies {@link WebMvcTagsProvider} tags as a
|
||||
* {@link ServerRequestObservationConvention}.
|
||||
*
|
||||
* @author Brian Clozel
|
||||
*/
|
||||
@SuppressWarnings("removal")
|
||||
@Deprecated(since = "3.0.0", forRemoval = true)
|
||||
class ServerRequestObservationConventionAdapter implements ServerRequestObservationConvention {
|
||||
|
||||
private final String observationName;
|
||||
|
||||
private final WebMvcTagsProvider tagsProvider;
|
||||
|
||||
ServerRequestObservationConventionAdapter(String observationName, WebMvcTagsProvider tagsProvider,
|
||||
List<WebMvcTagsContributor> contributors) {
|
||||
Assert.state((tagsProvider != null) || (contributors != null),
|
||||
"adapter should adapt to a WebMvcTagsProvider or a list of contributors");
|
||||
this.observationName = observationName;
|
||||
this.tagsProvider = (tagsProvider != null) ? tagsProvider : new DefaultWebMvcTagsProvider(contributors);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.observationName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsContext(Observation.Context context) {
|
||||
return context instanceof ServerRequestObservationContext;
|
||||
}
|
||||
|
||||
@Override
|
||||
public KeyValues getLowCardinalityKeyValues(ServerRequestObservationContext context) {
|
||||
Iterable<Tag> tags = this.tagsProvider.getTags(context.getCarrier(), context.getResponse(), getHandler(context),
|
||||
context.getError());
|
||||
return KeyValues.of(tags, Tag::getKey, Tag::getValue);
|
||||
}
|
||||
|
||||
private Object getHandler(ServerRequestObservationContext context) {
|
||||
return context.getCarrier().getAttribute(HandlerMapping.BEST_MATCHING_HANDLER_ATTRIBUTE);
|
||||
}
|
||||
|
||||
}
|
@ -1,86 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.actuate.autoconfigure.opentelemetry;
|
||||
|
||||
import io.opentelemetry.api.OpenTelemetry;
|
||||
import io.opentelemetry.api.common.AttributeKey;
|
||||
import io.opentelemetry.api.common.Attributes;
|
||||
import io.opentelemetry.context.propagation.ContextPropagators;
|
||||
import io.opentelemetry.sdk.OpenTelemetrySdk;
|
||||
import io.opentelemetry.sdk.OpenTelemetrySdkBuilder;
|
||||
import io.opentelemetry.sdk.logs.SdkLoggerProvider;
|
||||
import io.opentelemetry.sdk.metrics.SdkMeterProvider;
|
||||
import io.opentelemetry.sdk.resources.Resource;
|
||||
import io.opentelemetry.sdk.resources.ResourceBuilder;
|
||||
import io.opentelemetry.sdk.trace.SdkTracerProvider;
|
||||
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.core.env.Environment;
|
||||
|
||||
/**
|
||||
* {@link EnableAutoConfiguration Auto-configuration} for OpenTelemetry.
|
||||
*
|
||||
* @author Moritz Halbritter
|
||||
* @since 3.2.0
|
||||
*/
|
||||
@AutoConfiguration
|
||||
@ConditionalOnClass(OpenTelemetrySdk.class)
|
||||
@EnableConfigurationProperties(OpenTelemetryProperties.class)
|
||||
public class OpenTelemetryAutoConfiguration {
|
||||
|
||||
/**
|
||||
* Default value for application name if {@code spring.application.name} is not set.
|
||||
*/
|
||||
private static final String DEFAULT_APPLICATION_NAME = "application";
|
||||
|
||||
static final AttributeKey<String> ATTRIBUTE_KEY_SERVICE_NAME = AttributeKey.stringKey("service.name");
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(OpenTelemetry.class)
|
||||
OpenTelemetrySdk openTelemetry(ObjectProvider<SdkTracerProvider> tracerProvider,
|
||||
ObjectProvider<ContextPropagators> propagators, ObjectProvider<SdkLoggerProvider> loggerProvider,
|
||||
ObjectProvider<SdkMeterProvider> meterProvider) {
|
||||
OpenTelemetrySdkBuilder builder = OpenTelemetrySdk.builder();
|
||||
tracerProvider.ifAvailable(builder::setTracerProvider);
|
||||
propagators.ifAvailable(builder::setPropagators);
|
||||
loggerProvider.ifAvailable(builder::setLoggerProvider);
|
||||
meterProvider.ifAvailable(builder::setMeterProvider);
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
Resource openTelemetryResource(Environment environment, OpenTelemetryProperties properties) {
|
||||
String applicationName = environment.getProperty("spring.application.name", DEFAULT_APPLICATION_NAME);
|
||||
return Resource.getDefault()
|
||||
.merge(Resource.create(Attributes.of(ATTRIBUTE_KEY_SERVICE_NAME, applicationName)))
|
||||
.merge(toResource(properties));
|
||||
}
|
||||
|
||||
private static Resource toResource(OpenTelemetryProperties properties) {
|
||||
ResourceBuilder builder = Resource.builder();
|
||||
properties.getResourceAttributes().forEach(builder::put);
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
}
|
@ -1,46 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.actuate.autoconfigure.opentelemetry;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
/**
|
||||
* Configuration properties for OpenTelemetry.
|
||||
*
|
||||
* @author Moritz Halbritter
|
||||
* @since 3.2.0
|
||||
*/
|
||||
@ConfigurationProperties(prefix = "management.opentelemetry")
|
||||
public class OpenTelemetryProperties {
|
||||
|
||||
/**
|
||||
* Resource attributes.
|
||||
*/
|
||||
private Map<String, String> resourceAttributes = new HashMap<>();
|
||||
|
||||
public Map<String, String> getResourceAttributes() {
|
||||
return this.resourceAttributes;
|
||||
}
|
||||
|
||||
public void setResourceAttributes(Map<String, String> resourceAttributes) {
|
||||
this.resourceAttributes = resourceAttributes;
|
||||
}
|
||||
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Auto-configuration for OpenTelemetry.
|
||||
*/
|
||||
package org.springframework.boot.actuate.autoconfigure.opentelemetry;
|
@ -1,87 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.actuate.autoconfigure.r2dbc;
|
||||
|
||||
import io.micrometer.observation.ObservationRegistry;
|
||||
import io.r2dbc.proxy.ProxyConnectionFactory;
|
||||
import io.r2dbc.proxy.observation.ObservationProxyExecutionListener;
|
||||
import io.r2dbc.proxy.observation.QueryObservationConvention;
|
||||
import io.r2dbc.proxy.observation.QueryParametersTagProvider;
|
||||
import io.r2dbc.spi.ConnectionFactory;
|
||||
import io.r2dbc.spi.ConnectionFactoryOptions;
|
||||
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
import org.springframework.boot.actuate.autoconfigure.observation.ObservationAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.boot.r2dbc.ConnectionFactoryDecorator;
|
||||
import org.springframework.boot.r2dbc.OptionsCapableConnectionFactory;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
|
||||
/**
|
||||
* {@link EnableAutoConfiguration Auto-configuration} for R2DBC observability support.
|
||||
*
|
||||
* @author Moritz Halbritter
|
||||
* @since 3.2.0
|
||||
*/
|
||||
@AutoConfiguration(after = ObservationAutoConfiguration.class)
|
||||
@ConditionalOnClass({ ConnectionFactory.class, ProxyConnectionFactory.class })
|
||||
@EnableConfigurationProperties(R2dbcObservationProperties.class)
|
||||
public class R2dbcObservationAutoConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnBean(ObservationRegistry.class)
|
||||
ConnectionFactoryDecorator connectionFactoryDecorator(R2dbcObservationProperties properties,
|
||||
ObservationRegistry observationRegistry,
|
||||
ObjectProvider<QueryObservationConvention> queryObservationConvention,
|
||||
ObjectProvider<QueryParametersTagProvider> queryParametersTagProvider) {
|
||||
return (connectionFactory) -> {
|
||||
HostAndPort hostAndPort = extractHostAndPort(connectionFactory);
|
||||
ObservationProxyExecutionListener listener = new ObservationProxyExecutionListener(observationRegistry,
|
||||
connectionFactory, hostAndPort.host(), hostAndPort.port());
|
||||
listener.setIncludeParameterValues(properties.isIncludeParameterValues());
|
||||
queryObservationConvention.ifAvailable(listener::setQueryObservationConvention);
|
||||
queryParametersTagProvider.ifAvailable(listener::setQueryParametersTagProvider);
|
||||
return ProxyConnectionFactory.builder(connectionFactory).listener(listener).build();
|
||||
};
|
||||
}
|
||||
|
||||
private HostAndPort extractHostAndPort(ConnectionFactory connectionFactory) {
|
||||
OptionsCapableConnectionFactory optionsCapableConnectionFactory = OptionsCapableConnectionFactory
|
||||
.unwrapFrom(connectionFactory);
|
||||
if (optionsCapableConnectionFactory == null) {
|
||||
return HostAndPort.empty();
|
||||
}
|
||||
ConnectionFactoryOptions options = optionsCapableConnectionFactory.getOptions();
|
||||
Object host = options.getValue(ConnectionFactoryOptions.HOST);
|
||||
Object port = options.getValue(ConnectionFactoryOptions.PORT);
|
||||
if (!(host instanceof String hostAsString) || !(port instanceof Integer portAsInt)) {
|
||||
return HostAndPort.empty();
|
||||
}
|
||||
return new HostAndPort(hostAsString, portAsInt);
|
||||
}
|
||||
|
||||
private record HostAndPort(String host, Integer port) {
|
||||
static HostAndPort empty() {
|
||||
return new HostAndPort(null, null);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,43 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.actuate.autoconfigure.r2dbc;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
/**
|
||||
* Configuration properties for R2DBC observability.
|
||||
*
|
||||
* @author Moritz Halbritter
|
||||
* @since 3.2.0
|
||||
*/
|
||||
@ConfigurationProperties("management.observations.r2dbc")
|
||||
public class R2dbcObservationProperties {
|
||||
|
||||
/**
|
||||
* Whether to tag actual query parameter values.
|
||||
*/
|
||||
private boolean includeParameterValues;
|
||||
|
||||
public boolean isIncludeParameterValues() {
|
||||
return this.includeParameterValues;
|
||||
}
|
||||
|
||||
public void setIncludeParameterValues(boolean includeParameterValues) {
|
||||
this.includeParameterValues = includeParameterValues;
|
||||
}
|
||||
|
||||
}
|
@ -1,63 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.actuate.autoconfigure.scheduling;
|
||||
|
||||
import io.micrometer.observation.ObservationRegistry;
|
||||
|
||||
import org.springframework.boot.actuate.autoconfigure.observation.ObservationAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.scheduling.annotation.SchedulingConfigurer;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
|
||||
import org.springframework.scheduling.config.ScheduledTaskRegistrar;
|
||||
|
||||
/**
|
||||
* {@link EnableAutoConfiguration Auto-configuration} to enable observability for
|
||||
* scheduled tasks.
|
||||
*
|
||||
* @author Moritz Halbritter
|
||||
* @since 3.2.0
|
||||
*/
|
||||
@AutoConfiguration(after = ObservationAutoConfiguration.class)
|
||||
@ConditionalOnBean(ObservationRegistry.class)
|
||||
@ConditionalOnClass(ThreadPoolTaskScheduler.class)
|
||||
public class ScheduledTasksObservabilityAutoConfiguration {
|
||||
|
||||
@Bean
|
||||
ObservabilitySchedulingConfigurer observabilitySchedulingConfigurer(ObservationRegistry observationRegistry) {
|
||||
return new ObservabilitySchedulingConfigurer(observationRegistry);
|
||||
}
|
||||
|
||||
static final class ObservabilitySchedulingConfigurer implements SchedulingConfigurer {
|
||||
|
||||
private final ObservationRegistry observationRegistry;
|
||||
|
||||
ObservabilitySchedulingConfigurer(ObservationRegistry observationRegistry) {
|
||||
this.observationRegistry = observationRegistry;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
|
||||
taskRegistrar.setObservationRegistry(this.observationRegistry);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,69 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.actuate.autoconfigure.tracing;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.env.EnvironmentPostProcessor;
|
||||
import org.springframework.boot.logging.LoggingSystem;
|
||||
import org.springframework.core.env.ConfigurableEnvironment;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.core.env.PropertySource;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
/**
|
||||
* {@link EnvironmentPostProcessor} to add a {@link PropertySource} to support log
|
||||
* correlation IDs when Micrometer Tracing is present. Adds support for the
|
||||
* {@value LoggingSystem#EXPECT_CORRELATION_ID_PROPERTY} property by delegating to
|
||||
* {@code management.tracing.enabled}.
|
||||
*
|
||||
* @author Jonatan Ivanov
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
class LogCorrelationEnvironmentPostProcessor implements EnvironmentPostProcessor {
|
||||
|
||||
@Override
|
||||
public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) {
|
||||
if (ClassUtils.isPresent("io.micrometer.tracing.Tracer", application.getClassLoader())) {
|
||||
environment.getPropertySources().addLast(new LogCorrelationPropertySource(this, environment));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Log correlation {@link PropertySource}.
|
||||
*/
|
||||
private static class LogCorrelationPropertySource extends PropertySource<Object> {
|
||||
|
||||
private static final String NAME = "logCorrelation";
|
||||
|
||||
private final Environment environment;
|
||||
|
||||
LogCorrelationPropertySource(Object source, Environment environment) {
|
||||
super(NAME, source);
|
||||
this.environment = environment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getProperty(String name) {
|
||||
if (name.equals(LoggingSystem.EXPECT_CORRELATION_ID_PROPERTY)) {
|
||||
return this.environment.getProperty("management.tracing.enabled", Boolean.class, Boolean.TRUE);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,76 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.actuate.autoconfigure.tracing;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Spliterator;
|
||||
|
||||
import io.opentelemetry.sdk.trace.export.SpanExporter;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* A collection of {@link SpanExporter span exporters}.
|
||||
*
|
||||
* @author Moritz Halbritter
|
||||
* @since 3.2.0
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface SpanExporters extends Iterable<SpanExporter> {
|
||||
|
||||
/**
|
||||
* Returns the list of {@link SpanExporter span exporters}.
|
||||
* @return the list of span exporters
|
||||
*/
|
||||
List<SpanExporter> list();
|
||||
|
||||
@Override
|
||||
default Iterator<SpanExporter> iterator() {
|
||||
return list().iterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
default Spliterator<SpanExporter> spliterator() {
|
||||
return list().spliterator();
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a {@link SpanExporters} instance with the given {@link SpanExporter span
|
||||
* exporters}.
|
||||
* @param spanExporters the span exporters
|
||||
* @return the constructed {@link SpanExporters} instance
|
||||
*/
|
||||
static SpanExporters of(SpanExporter... spanExporters) {
|
||||
return of(Arrays.asList(spanExporters));
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a {@link SpanExporters} instance with the given list of
|
||||
* {@link SpanExporter span exporters}.
|
||||
* @param spanExporters the list of span exporters
|
||||
* @return the constructed {@link SpanExporters} instance
|
||||
*/
|
||||
static SpanExporters of(Collection<? extends SpanExporter> spanExporters) {
|
||||
Assert.notNull(spanExporters, "SpanExporters must not be null");
|
||||
List<SpanExporter> copy = List.copyOf(spanExporters);
|
||||
return () -> copy;
|
||||
}
|
||||
|
||||
}
|
@ -1,76 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.actuate.autoconfigure.tracing;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Spliterator;
|
||||
|
||||
import io.opentelemetry.sdk.trace.SpanProcessor;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* A collection of {@link SpanProcessor span processors}.
|
||||
*
|
||||
* @author Moritz Halbritter
|
||||
* @since 3.2.0
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface SpanProcessors extends Iterable<SpanProcessor> {
|
||||
|
||||
/**
|
||||
* Returns the list of {@link SpanProcessor span processors}.
|
||||
* @return the list of span processors
|
||||
*/
|
||||
List<SpanProcessor> list();
|
||||
|
||||
@Override
|
||||
default Iterator<SpanProcessor> iterator() {
|
||||
return list().iterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
default Spliterator<SpanProcessor> spliterator() {
|
||||
return list().spliterator();
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a {@link SpanProcessors} instance with the given {@link SpanProcessor
|
||||
* span processors}.
|
||||
* @param spanProcessors the span processors
|
||||
* @return the constructed {@link SpanProcessors} instance
|
||||
*/
|
||||
static SpanProcessors of(SpanProcessor... spanProcessors) {
|
||||
return of(Arrays.asList(spanProcessors));
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a {@link SpanProcessors} instance with the given list of
|
||||
* {@link SpanProcessor span processors}.
|
||||
* @param spanProcessors the list of span processors
|
||||
* @return the constructed {@link SpanProcessors} instance
|
||||
*/
|
||||
static SpanProcessors of(Collection<? extends SpanProcessor> spanProcessors) {
|
||||
Assert.notNull(spanProcessors, "SpanProcessors must not be null");
|
||||
List<SpanProcessor> copy = List.copyOf(spanProcessors);
|
||||
return () -> copy;
|
||||
}
|
||||
|
||||
}
|
@ -1,93 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.actuate.autoconfigure.tracing.otlp;
|
||||
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import io.opentelemetry.exporter.otlp.http.trace.OtlpHttpSpanExporter;
|
||||
import io.opentelemetry.exporter.otlp.http.trace.OtlpHttpSpanExporterBuilder;
|
||||
|
||||
import org.springframework.boot.actuate.autoconfigure.tracing.ConditionalOnEnabledTracing;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* Configurations imported by {@link OtlpAutoConfiguration}.
|
||||
*
|
||||
* @author Moritz Halbritter
|
||||
*/
|
||||
final class OtlpTracingConfigurations {
|
||||
|
||||
private OtlpTracingConfigurations() {
|
||||
}
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
static class ConnectionDetails {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(OtlpTracingConnectionDetails.class)
|
||||
@ConditionalOnProperty(prefix = "management.otlp.tracing", name = "endpoint")
|
||||
OtlpTracingConnectionDetails otlpTracingConnectionDetails(OtlpProperties properties) {
|
||||
return new PropertiesOtlpTracingConnectionDetails(properties);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adapts {@link OtlpProperties} to {@link OtlpTracingConnectionDetails}.
|
||||
*/
|
||||
static class PropertiesOtlpTracingConnectionDetails implements OtlpTracingConnectionDetails {
|
||||
|
||||
private final OtlpProperties properties;
|
||||
|
||||
PropertiesOtlpTracingConnectionDetails(OtlpProperties properties) {
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUrl() {
|
||||
return this.properties.getEndpoint();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
static class Exporters {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(value = OtlpHttpSpanExporter.class,
|
||||
type = "io.opentelemetry.exporter.otlp.trace.OtlpGrpcSpanExporter")
|
||||
@ConditionalOnBean(OtlpTracingConnectionDetails.class)
|
||||
@ConditionalOnEnabledTracing
|
||||
OtlpHttpSpanExporter otlpHttpSpanExporter(OtlpProperties properties,
|
||||
OtlpTracingConnectionDetails connectionDetails) {
|
||||
OtlpHttpSpanExporterBuilder builder = OtlpHttpSpanExporter.builder()
|
||||
.setEndpoint(connectionDetails.getUrl())
|
||||
.setTimeout(properties.getTimeout())
|
||||
.setCompression(properties.getCompression().name().toLowerCase());
|
||||
for (Entry<String, String> header : properties.getHeaders().entrySet()) {
|
||||
builder.addHeader(header.getKey(), header.getValue());
|
||||
}
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,35 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.actuate.autoconfigure.tracing.otlp;
|
||||
|
||||
import org.springframework.boot.autoconfigure.service.connection.ConnectionDetails;
|
||||
|
||||
/**
|
||||
* Details required to establish a connection to a OpenTelemetry service.
|
||||
*
|
||||
* @author Eddú Meléndez
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public interface OtlpTracingConnectionDetails extends ConnectionDetails {
|
||||
|
||||
/**
|
||||
* Address to where metrics will be published.
|
||||
* @return the address to where metrics will be published
|
||||
*/
|
||||
String getUrl();
|
||||
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.actuate.autoconfigure.health;
|
||||
|
||||
import org.springframework.boot.actuate.autoconfigure.health.CompositeHealthContributorConfigurationReflectionTests.TestHealthIndicator;
|
||||
import org.springframework.boot.actuate.health.AbstractHealthIndicator;
|
||||
import org.springframework.boot.actuate.health.Health.Builder;
|
||||
import org.springframework.boot.actuate.health.HealthContributor;
|
||||
|
||||
/**
|
||||
* Tests for {@link CompositeHealthContributorConfiguration} using reflection to create
|
||||
* indicator instances.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
@SuppressWarnings("removal")
|
||||
@Deprecated(since = "3.0.0", forRemoval = true)
|
||||
class CompositeHealthContributorConfigurationReflectionTests
|
||||
extends AbstractCompositeHealthContributorConfigurationTests<HealthContributor, TestHealthIndicator> {
|
||||
|
||||
@Override
|
||||
protected AbstractCompositeHealthContributorConfiguration<HealthContributor, TestHealthIndicator, TestBean> newComposite() {
|
||||
return new ReflectiveTestCompositeHealthContributorConfiguration();
|
||||
}
|
||||
|
||||
static class ReflectiveTestCompositeHealthContributorConfiguration
|
||||
extends CompositeHealthContributorConfiguration<TestHealthIndicator, TestBean> {
|
||||
|
||||
}
|
||||
|
||||
static class TestHealthIndicator extends AbstractHealthIndicator {
|
||||
|
||||
TestHealthIndicator(TestBean testBean) {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doHealthCheck(Builder builder) throws Exception {
|
||||
builder.up();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.actuate.autoconfigure.health;
|
||||
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import org.springframework.boot.actuate.autoconfigure.health.CompositeReactiveHealthContributorConfigurationReflectionTests.TestReactiveHealthIndicator;
|
||||
import org.springframework.boot.actuate.health.AbstractReactiveHealthIndicator;
|
||||
import org.springframework.boot.actuate.health.Health;
|
||||
import org.springframework.boot.actuate.health.Health.Builder;
|
||||
import org.springframework.boot.actuate.health.ReactiveHealthContributor;
|
||||
|
||||
/**
|
||||
* Tests for {@link CompositeReactiveHealthContributorConfiguration} using reflection to
|
||||
* create indicator instances.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
@SuppressWarnings("removal")
|
||||
@Deprecated(since = "3.0.0", forRemoval = true)
|
||||
class CompositeReactiveHealthContributorConfigurationReflectionTests extends
|
||||
AbstractCompositeHealthContributorConfigurationTests<ReactiveHealthContributor, TestReactiveHealthIndicator> {
|
||||
|
||||
@Override
|
||||
protected AbstractCompositeHealthContributorConfiguration<ReactiveHealthContributor, TestReactiveHealthIndicator, TestBean> newComposite() {
|
||||
return new TestCompositeReactiveHealthContributorConfiguration();
|
||||
}
|
||||
|
||||
static class TestCompositeReactiveHealthContributorConfiguration
|
||||
extends CompositeReactiveHealthContributorConfiguration<TestReactiveHealthIndicator, TestBean> {
|
||||
|
||||
}
|
||||
|
||||
static class TestReactiveHealthIndicator extends AbstractReactiveHealthIndicator {
|
||||
|
||||
TestReactiveHealthIndicator(TestBean testBean) {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Mono<Health> doHealthCheck(Builder builder) {
|
||||
return Mono.just(builder.up().build());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue