This commit is contained in:
Phillip Webb 2023-09-27 20:17:44 -07:00
parent 3591f4d614
commit 052757c2d8
9 changed files with 43 additions and 60 deletions

View File

@ -75,18 +75,17 @@ class OtlpPropertiesConfigAdapter extends StepRegistryPropertiesConfigAdapter<Ot
@Override @Override
@SuppressWarnings("removal") @SuppressWarnings("removal")
public Map<String, String> resourceAttributes() { public Map<String, String> resourceAttributes() {
Map<String, String> result; Map<String, String> resourceAttributes = this.openTelemetryProperties.getResourceAttributes();
if (!CollectionUtils.isEmpty(this.openTelemetryProperties.getResourceAttributes())) { Map<String, String> result = new HashMap<>((!CollectionUtils.isEmpty(resourceAttributes)) ? resourceAttributes
result = new HashMap<>(this.openTelemetryProperties.getResourceAttributes()); : get(OtlpProperties::getResourceAttributes, OtlpConfig.super::resourceAttributes));
} result.computeIfAbsent("service.name", (key) -> getApplicationName());
else {
result = new HashMap<>(get(OtlpProperties::getResourceAttributes, OtlpConfig.super::resourceAttributes));
}
result.computeIfAbsent("service.name",
(ignore) -> this.environment.getProperty("spring.application.name", DEFAULT_APPLICATION_NAME));
return Collections.unmodifiableMap(result); return Collections.unmodifiableMap(result);
} }
private String getApplicationName() {
return this.environment.getProperty("spring.application.name", DEFAULT_APPLICATION_NAME);
}
@Override @Override
public Map<String, String> headers() { public Map<String, String> headers() {
return get(OtlpProperties::getHeaders, OtlpConfig.super::headers); return get(OtlpProperties::getHeaders, OtlpConfig.super::headers);

View File

@ -16,8 +16,6 @@
package org.springframework.boot.actuate.autoconfigure.opentelemetry; package org.springframework.boot.actuate.autoconfigure.opentelemetry;
import java.util.Map.Entry;
import io.opentelemetry.api.OpenTelemetry; import io.opentelemetry.api.OpenTelemetry;
import io.opentelemetry.api.common.Attributes; import io.opentelemetry.api.common.Attributes;
import io.opentelemetry.context.propagation.ContextPropagators; import io.opentelemetry.context.propagation.ContextPropagators;
@ -80,9 +78,7 @@ public class OpenTelemetryAutoConfiguration {
private static Resource toResource(OpenTelemetryProperties properties) { private static Resource toResource(OpenTelemetryProperties properties) {
ResourceBuilder builder = Resource.builder(); ResourceBuilder builder = Resource.builder();
for (Entry<String, String> entry : properties.getResourceAttributes().entrySet()) { properties.getResourceAttributes().forEach(builder::put);
builder.put(entry.getKey(), entry.getValue());
}
return builder.build(); return builder.build();
} }

View File

@ -22,6 +22,7 @@ import jakarta.jms.ConnectionFactory;
import jakarta.jms.ExceptionListener; import jakarta.jms.ExceptionListener;
import org.springframework.boot.autoconfigure.jms.JmsProperties.Listener.Session; import org.springframework.boot.autoconfigure.jms.JmsProperties.Listener.Session;
import org.springframework.boot.context.properties.PropertyMapper;
import org.springframework.jms.config.DefaultJmsListenerContainerFactory; import org.springframework.jms.config.DefaultJmsListenerContainerFactory;
import org.springframework.jms.support.converter.MessageConverter; import org.springframework.jms.support.converter.MessageConverter;
import org.springframework.jms.support.destination.DestinationResolver; import org.springframework.jms.support.destination.DestinationResolver;
@ -103,37 +104,21 @@ public final class DefaultJmsListenerContainerFactoryConfigurer {
Assert.notNull(connectionFactory, "ConnectionFactory must not be null"); Assert.notNull(connectionFactory, "ConnectionFactory must not be null");
factory.setConnectionFactory(connectionFactory); factory.setConnectionFactory(connectionFactory);
factory.setPubSubDomain(this.jmsProperties.isPubSubDomain()); factory.setPubSubDomain(this.jmsProperties.isPubSubDomain());
JmsProperties.Listener listener = this.jmsProperties.getListener(); JmsProperties.Listener listenerProperties = this.jmsProperties.getListener();
Session session = listener.getSession(); Session sessionProperties = listenerProperties.getSession();
Boolean sessionTransacted = session.getTransacted(); PropertyMapper map = PropertyMapper.get().alwaysApplyingWhenNonNull();
if (this.transactionManager != null) { map.from(this.transactionManager).to(factory::setTransactionManager);
factory.setTransactionManager(this.transactionManager); map.from(this.destinationResolver).to(factory::setDestinationResolver);
} map.from(this.messageConverter).to(factory::setMessageConverter);
else if (sessionTransacted == null) { map.from(this.exceptionListener).to(factory::setExceptionListener);
map.from(sessionProperties.getAcknowledgeMode()::getMode).to(factory::setSessionAcknowledgeMode);
if (this.transactionManager == null && sessionProperties.getTransacted() == null) {
factory.setSessionTransacted(true); factory.setSessionTransacted(true);
} }
if (sessionTransacted != null) { map.from(sessionProperties::getTransacted).to(factory::setSessionTransacted);
factory.setSessionTransacted(sessionTransacted); map.from(listenerProperties::isAutoStartup).to(factory::setAutoStartup);
} map.from(listenerProperties::formatConcurrency).to(factory::setConcurrency);
if (this.destinationResolver != null) { map.from(listenerProperties::getReceiveTimeout).as(Duration::toMillis).to(factory::setReceiveTimeout);
factory.setDestinationResolver(this.destinationResolver);
}
if (this.messageConverter != null) {
factory.setMessageConverter(this.messageConverter);
}
if (this.exceptionListener != null) {
factory.setExceptionListener(this.exceptionListener);
}
factory.setAutoStartup(listener.isAutoStartup());
factory.setSessionAcknowledgeMode(session.getAcknowledgeMode().getMode());
String concurrency = listener.formatConcurrency();
if (concurrency != null) {
factory.setConcurrency(concurrency);
}
Duration receiveTimeout = listener.getReceiveTimeout();
if (receiveTimeout != null) {
factory.setReceiveTimeout(receiveTimeout.toMillis());
}
} }
} }

View File

@ -28,6 +28,7 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnSingleCandidate; import org.springframework.boot.autoconfigure.condition.ConditionalOnSingleCandidate;
import org.springframework.boot.autoconfigure.jms.JmsProperties.AcknowledgeMode;
import org.springframework.boot.autoconfigure.jms.JmsProperties.DeliveryMode; import org.springframework.boot.autoconfigure.jms.JmsProperties.DeliveryMode;
import org.springframework.boot.autoconfigure.jms.JmsProperties.Template; import org.springframework.boot.autoconfigure.jms.JmsProperties.Template;
import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties;
@ -88,23 +89,18 @@ public class JmsAutoConfiguration {
} }
private void mapTemplateProperties(Template properties, JmsTemplate template) { private void mapTemplateProperties(Template properties, JmsTemplate template) {
PropertyMapper map = PropertyMapper.get(); PropertyMapper map = PropertyMapper.get().alwaysApplyingWhenNonNull();
map.from(properties.getSession()::getAcknowledgeMode) map.from(properties.getSession()::getAcknowledgeMode)
.to((acknowledgeMode) -> template.setSessionAcknowledgeMode(acknowledgeMode.getMode())); .asInt(AcknowledgeMode::getMode)
.to(template::setSessionAcknowledgeMode);
map.from(properties.getSession()::isTransacted).to(template::setSessionTransacted); map.from(properties.getSession()::isTransacted).to(template::setSessionTransacted);
map.from(properties::getDefaultDestination).whenNonNull().to(template::setDefaultDestinationName); map.from(properties::getDefaultDestination).whenNonNull().to(template::setDefaultDestinationName);
map.from(properties::getDeliveryDelay).whenNonNull().as(Duration::toMillis).to(template::setDeliveryDelay); map.from(properties::getDeliveryDelay).whenNonNull().as(Duration::toMillis).to(template::setDeliveryDelay);
map.from(properties::determineQosEnabled).to(template::setExplicitQosEnabled); map.from(properties::determineQosEnabled).to(template::setExplicitQosEnabled);
map.from(properties::getDeliveryMode) map.from(properties::getDeliveryMode).as(DeliveryMode::getValue).to(template::setDeliveryMode);
.whenNonNull()
.as(DeliveryMode::getValue)
.to(template::setDeliveryMode);
map.from(properties::getPriority).whenNonNull().to(template::setPriority); map.from(properties::getPriority).whenNonNull().to(template::setPriority);
map.from(properties::getTimeToLive).whenNonNull().as(Duration::toMillis).to(template::setTimeToLive); map.from(properties::getTimeToLive).whenNonNull().as(Duration::toMillis).to(template::setTimeToLive);
map.from(properties::getReceiveTimeout) map.from(properties::getReceiveTimeout).as(Duration::toMillis).to(template::setReceiveTimeout);
.whenNonNull()
.as(Duration::toMillis)
.to(template::setReceiveTimeout);
} }
} }

View File

@ -739,6 +739,7 @@ Auto-configuration enables the instrumentation of all available `ThreadPoolTaskE
Metrics are tagged by the name of the executor, which is derived from the bean name. Metrics are tagged by the name of the executor, which is derived from the bean name.
[[actuator.metrics.supported.jms]] [[actuator.metrics.supported.jms]]
==== JMS Metrics ==== JMS Metrics
Auto-configuration enables the instrumentation of all available `JmsTemplate` beans. Auto-configuration enables the instrumentation of all available `JmsTemplate` beans.

View File

@ -52,6 +52,8 @@ For example, if you want to configure the issuer url for the `AuthenticationOAut
If you use other forms, such as `issuerurl` or `issuer-url`, the setting will not be applied to the plugin. If you use other forms, such as `issuerurl` or `issuer-url`, the setting will not be applied to the plugin.
==== ====
[[messaging.pulsar.connecting.ssl]] [[messaging.pulsar.connecting.ssl]]
==== SSL ==== SSL
By default, Pulsar clients communicate with Pulsar services in plain text. By default, Pulsar clients communicate with Pulsar services in plain text.

View File

@ -79,7 +79,6 @@ class OpenTelemetryMetricsConnectionDetailsFactoryIntegrationTests {
Gauge.builder("test.gauge", () -> 12).register(this.meterRegistry); Gauge.builder("test.gauge", () -> 12).register(this.meterRegistry);
Timer.builder("test.timer").register(this.meterRegistry).record(Duration.ofMillis(123)); Timer.builder("test.timer").register(this.meterRegistry).record(Duration.ofMillis(123));
DistributionSummary.builder("test.distributionsummary").register(this.meterRegistry).record(24); DistributionSummary.builder("test.distributionsummary").register(this.meterRegistry).record(24);
Awaitility.await() Awaitility.await()
.atMost(Duration.ofSeconds(5)) .atMost(Duration.ofSeconds(5))
.pollDelay(Duration.ofMillis(100)) .pollDelay(Duration.ofMillis(100))
@ -88,19 +87,14 @@ class OpenTelemetryMetricsConnectionDetailsFactoryIntegrationTests {
.statusCode(200) .statusCode(200)
.contentType(OPENMETRICS_001) .contentType(OPENMETRICS_001)
.body(endsWith("# EOF\n"))); .body(endsWith("# EOF\n")));
whenPrometheusScraped().then() whenPrometheusScraped().then()
.body(containsString( .body(containsString(
"{job=\"test\",service_name=\"test\",telemetry_sdk_language=\"java\",telemetry_sdk_name=\"io.micrometer\""), "{job=\"test\",service_name=\"test\",telemetry_sdk_language=\"java\",telemetry_sdk_name=\"io.micrometer\""),
matchesPattern("(?s)^.*test_counter\\{.+} 42\\.0\\n.*$"), matchesPattern("(?s)^.*test_counter\\{.+} 42\\.0\\n.*$"),
matchesPattern("(?s)^.*test_gauge\\{.+} 12\\.0\\n.*$"), matchesPattern("(?s)^.*test_gauge\\{.+} 12\\.0\\n.*$"),
matchesPattern("(?s)^.*test_timer_count\\{.+} 1\\n.*$"), matchesPattern("(?s)^.*test_timer_count\\{.+} 1\\n.*$"),
matchesPattern("(?s)^.*test_timer_sum\\{.+} 123\\.0\\n.*$"), matchesPattern("(?s)^.*test_timer_sum\\{.+} 123\\.0\\n.*$"),
matchesPattern("(?s)^.*test_timer_bucket\\{.+,le=\"\\+Inf\"} 1\\n.*$"), matchesPattern("(?s)^.*test_timer_bucket\\{.+,le=\"\\+Inf\"} 1\\n.*$"),
matchesPattern("(?s)^.*test_distributionsummary_count\\{.+} 1\\n.*$"), matchesPattern("(?s)^.*test_distributionsummary_count\\{.+} 1\\n.*$"),
matchesPattern("(?s)^.*test_distributionsummary_sum\\{.+} 24\\.0\\n.*$"), matchesPattern("(?s)^.*test_distributionsummary_sum\\{.+} 24\\.0\\n.*$"),
matchesPattern("(?s)^.*test_distributionsummary_bucket\\{.+,le=\"\\+Inf\"} 1\\n.*$")); matchesPattern("(?s)^.*test_distributionsummary_bucket\\{.+,le=\"\\+Inf\"} 1\\n.*$"));

View File

@ -349,6 +349,7 @@ public class BuildRequest {
* Return a new {@link BuildRequest} with an updated build workspace. * Return a new {@link BuildRequest} with an updated build workspace.
* @param buildWorkspace the build workspace * @param buildWorkspace the build workspace
* @return an updated build request * @return an updated build request
* @since 3.2.0
*/ */
public BuildRequest withBuildWorkspace(Cache buildWorkspace) { public BuildRequest withBuildWorkspace(Cache buildWorkspace) {
Assert.notNull(buildWorkspace, "BuildWorkspace must not be null"); Assert.notNull(buildWorkspace, "BuildWorkspace must not be null");
@ -426,6 +427,7 @@ public class BuildRequest {
* Return a new {@link BuildRequest} with an updated security options. * Return a new {@link BuildRequest} with an updated security options.
* @param securityOptions the security options * @param securityOptions the security options
* @return an updated build request * @return an updated build request
* @since 3.2.0
*/ */
public BuildRequest withSecurityOptions(List<String> securityOptions) { public BuildRequest withSecurityOptions(List<String> securityOptions) {
Assert.notNull(securityOptions, "SecurityOption must not be null"); Assert.notNull(securityOptions, "SecurityOption must not be null");
@ -552,6 +554,11 @@ public class BuildRequest {
return this.tags; return this.tags;
} }
/**
* Return the build workspace that should be used by the lifecycle.
* @return the build workspace or {@code null}
* @since 3.2.0
*/
public Cache getBuildWorkspace() { public Cache getBuildWorkspace() {
return this.buildWorkspace; return this.buildWorkspace;
} }
@ -590,7 +597,8 @@ public class BuildRequest {
/** /**
* Return the security options that should be used by the lifecycle. * Return the security options that should be used by the lifecycle.
* @return the security options * @return the security options or {@code null}
* @since 3.2.0
*/ */
public List<String> getSecurityOptions() { public List<String> getSecurityOptions() {
return this.securityOptions; return this.securityOptions;

View File

@ -228,6 +228,7 @@ public abstract class BootBuildImage extends DefaultTask {
/** /**
* Returns the build temporary workspace that will be used when building the image. * Returns the build temporary workspace that will be used when building the image.
* @return the cache * @return the cache
* @since 3.2.0
*/ */
@Nested @Nested
@Optional @Optional
@ -239,6 +240,7 @@ public abstract class BootBuildImage extends DefaultTask {
* Customizes the {@link CacheSpec} for the build temporary workspace using the given * Customizes the {@link CacheSpec} for the build temporary workspace using the given
* {@code action}. * {@code action}.
* @param action the action * @param action the action
* @since 3.2.0
*/ */
public void buildWorkspace(Action<CacheSpec> action) { public void buildWorkspace(Action<CacheSpec> action) {
action.execute(this.buildWorkspace); action.execute(this.buildWorkspace);