Added deprecation warning messages for baggage

This commit is contained in:
Marcin Grzejszczak
2020-06-17 11:46:53 +02:00
parent b31c0fe18f
commit fcee4fd424
3 changed files with 47 additions and 3 deletions

View File

@@ -20,9 +20,9 @@
|spring.sleuth.integration.websockets.enabled | true | Enable tracing for WebSockets.
|spring.sleuth.keys.http.headers | | Additional headers that should be added as tags if they exist. If the header value is multi-valued, the tag value will be a comma-separated, single-quoted list.
|spring.sleuth.keys.http.prefix | http. | Prefix for header names if they are added as tags.
|spring.sleuth.local-keys | | Same as {@link #propagationKeys} except that this field is not propagated to remote services. @see brave.propagation.ExtraFieldPropagation.FactoryBuilder#addRedactedField(String)
|spring.sleuth.local-keys | | Same as {@link #propagationKeys} except that this field is not propagated to remote services. @see brave.propagation.ExtraFieldPropagation.FactoryBuilder#addRedactedField(String) @deprecated use {@code spring.sleuth.baggage.local-fields} property
|spring.sleuth.log.slf4j.enabled | true | Enable a {@link Slf4jScopeDecorator} that prints tracing information in the logs.
|spring.sleuth.log.slf4j.whitelisted-mdc-keys | | A list of keys to be put from baggage to MDC.
|spring.sleuth.log.slf4j.whitelisted-mdc-keys | | A list of keys to be put from baggage to MDC. @deprecated use spring.sleuth.baggage.correlation-fields property
|spring.sleuth.messaging.enabled | false | Should messaging be turned on.
|spring.sleuth.messaging.jms.enabled | true | Enable tracing of JMS.
|spring.sleuth.messaging.jms.remote-service-name | jms |
@@ -32,7 +32,7 @@
|spring.sleuth.messaging.rabbit.enabled | true | Enable tracing of RabbitMQ.
|spring.sleuth.messaging.rabbit.remote-service-name | rabbitmq |
|spring.sleuth.opentracing.enabled | true |
|spring.sleuth.propagation-keys | | List of fields that are referenced the same in-process as it is on the wire. For example, the name "x-vcap-request-id" would be set as-is including the prefix. <p> Note: {@code fieldName} will be implicitly lower-cased. @see brave.propagation.ExtraFieldPropagation.FactoryBuilder#addField(String)
|spring.sleuth.propagation-keys | | List of fields that are referenced the same in-process as it is on the wire. For example, the name "x-vcap-request-id" would be set as-is including the prefix. <p> Note: {@code fieldName} will be implicitly lower-cased. @see brave.propagation.ExtraFieldPropagation.FactoryBuilder#addField(String) @deprecated use {@code spring.sleuth.baggage.remote-fields} property
|spring.sleuth.propagation.tag.enabled | true | Enables a {@link TagPropagationFinishedSpanHandler} that adds extra propagated fields to span tags.
|spring.sleuth.propagation.tag.whitelisted-keys | | A list of keys to be put from extra propagation fields to span tags.
|spring.sleuth.reactor.decorate-on-each | true | When true decorates on each operator, will be less performing, but logging will always contain the tracing entries in each operator. When false decorates on last operator, will be more performing, but logging might not always contain the tracing entries.

View File

@@ -19,6 +19,10 @@ package org.springframework.cloud.sleuth.autoconfig;
import java.util.ArrayList;
import java.util.List;
import brave.baggage.BaggagePropagationConfig;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.boot.context.properties.ConfigurationProperties;
/**
@@ -31,6 +35,8 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
// TODO: Hide in 3.x, if it isn't already deleted
public class SleuthProperties {
private static final Log log = LogFactory.getLog(SleuthProperties.class);
private boolean enabled = true;
/** When true, generate 128-bit trace IDs instead of 64-bit ones. */
@@ -50,6 +56,7 @@ public class SleuthProperties {
* @see brave.propagation.ExtraFieldPropagation.FactoryBuilder#addPrefixedFields(String,
* java.util.Collection)
*/
@Deprecated
private List<String> baggageKeys = new ArrayList<>();
/**
@@ -60,7 +67,9 @@ public class SleuthProperties {
* Note: {@code fieldName} will be implicitly lower-cased.
*
* @see brave.propagation.ExtraFieldPropagation.FactoryBuilder#addField(String)
* @deprecated use {@code spring.sleuth.baggage.remote-fields} property
*/
@Deprecated
private List<String> propagationKeys = new ArrayList<>();
/**
@@ -68,7 +77,9 @@ public class SleuthProperties {
* services.
*
* @see brave.propagation.ExtraFieldPropagation.FactoryBuilder#addRedactedField(String)
* @deprecated use {@code spring.sleuth.baggage.local-fields} property
*/
@Deprecated
private List<String> localKeys = new ArrayList<>();
public boolean isEnabled() {
@@ -100,6 +111,14 @@ public class SleuthProperties {
}
public void setBaggageKeys(List<String> baggageKeys) {
log.warn("[spring.sleuth.baggage-keys] will be removed in a future release."
+ "To change header names define a @Bean of type "
+ BaggagePropagationConfig.SingleBaggageField.class.getName()
+ ". The preferable approach is to migrate "
+ "to using [spring.sleuth.baggage.remote-keys]. The [spring.sleuth.baggage-keys] would prefix the headers "
+ "with [baggage_] and [baggage-] so unless all of your applications migrate, to remain backward compatible "
+ "you would have to add e.g. for [spring.sleuth.baggage-keys=foo] an entry "
+ "[spring.sleuth.baggage.remote-keys=foo,baggage-foo,baggage_foo] and eventually migrate to [spring.sleuth.baggage.remote-keys=foo]");
this.baggageKeys = baggageKeys;
}
@@ -108,6 +127,7 @@ public class SleuthProperties {
}
public void setPropagationKeys(List<String> propagationKeys) {
warning("spring.sleuth.propagation-keys", "spring.sleuth.baggage.remote-fields");
this.propagationKeys = propagationKeys;
}
@@ -116,7 +136,14 @@ public class SleuthProperties {
}
public void setLocalKeys(List<String> localKeys) {
warning("spring.sleuth.local-keys", "spring.sleuth.baggage.local-fields");
this.localKeys = localKeys;
}
private void warning(String currentKey, String newKey) {
log.warn("The [" + currentKey
+ "] property is deprecated and is removed in the next major release version of Sleuth. Please use ["
+ newKey + "]");
}
}

View File

@@ -19,6 +19,9 @@ package org.springframework.cloud.sleuth.log;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.boot.context.properties.ConfigurationProperties;
/**
@@ -31,6 +34,8 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
// TODO: Hide in 3.x, if it isn't already deleted
public class SleuthSlf4jProperties {
private static final Log log = LogFactory.getLog(SleuthSlf4jProperties.class);
/**
* Enable a {@link Slf4jScopeDecorator} that prints tracing information in the logs.
*/
@@ -38,10 +43,14 @@ public class SleuthSlf4jProperties {
/**
* A list of keys to be put from baggage to MDC.
* @deprecated use spring.sleuth.baggage.correlation-fields property
*/
@Deprecated
private List<String> whitelistedMdcKeys = new ArrayList<>();
public boolean isEnabled() {
warning("spring.sleuth.log.slf4j.enabled",
"spring.sleuth.baggage.correlation-enabled");
return this.enabled;
}
@@ -54,7 +63,15 @@ public class SleuthSlf4jProperties {
}
public void setWhitelistedMdcKeys(List<String> whitelistedMdcKeys) {
warning("spring.sleuth.log.slf4j.whitelisted-mdc-keys",
"spring.sleuth.baggage.correlation-fields");
this.whitelistedMdcKeys = whitelistedMdcKeys;
}
private void warning(String currentKey, String newKey) {
log.warn("The [" + currentKey
+ "] property is deprecated and is removed in the next major release version of Sleuth. Please use ["
+ newKey + "]");
}
}