@@ -44,30 +44,8 @@ public class InferredSpansAutoConfig implements AutoConfigurationCustomizerProvi
44
44
public void customize (AutoConfigurationCustomizer config ) {
45
45
config .addTracerProviderCustomizer (
46
46
(providerBuilder , properties ) -> {
47
- if (properties .getBoolean (ENABLED_OPTION , false )) {
48
- InferredSpansProcessorBuilder builder = InferredSpansProcessor .builder ();
49
-
50
- PropertiesApplier applier = new PropertiesApplier (properties );
51
-
52
- applier .applyBool (LOGGING_OPTION , builder ::profilerLoggingEnabled );
53
- applier .applyBool (DIAGNOSTIC_FILES_OPTION , builder ::backupDiagnosticFiles );
54
- applier .applyInt (SAFEMODE_OPTION , builder ::asyncProfilerSafeMode );
55
- applier .applyBool (POSTPROCESSING_OPTION , builder ::postProcessingEnabled );
56
- applier .applyDuration (SAMPLING_INTERVAL_OPTION , builder ::samplingInterval );
57
- applier .applyDuration (MIN_DURATION_OPTION , builder ::inferredSpansMinDuration );
58
- applier .applyWildcards (INCLUDED_CLASSES_OPTION , builder ::includedClasses );
59
- applier .applyWildcards (EXCLUDED_CLASSES_OPTION , builder ::excludedClasses );
60
- applier .applyDuration (INTERVAL_OPTION , builder ::profilerInterval );
61
- applier .applyDuration (DURATION_OPTION , builder ::profilingDuration );
62
- applier .applyString (LIB_DIRECTORY_OPTION , builder ::profilerLibDirectory );
63
-
64
- String parentOverrideHandlerName = properties .getString (PARENT_OVERRIDE_HANDLER_OPTION );
65
- if (parentOverrideHandlerName != null && !parentOverrideHandlerName .isEmpty ()) {
66
- builder .parentOverrideHandler (
67
- constructParentOverrideHandler (parentOverrideHandlerName ));
68
- }
69
-
70
- providerBuilder .addSpanProcessor (builder .build ());
47
+ if (isEnabled (properties )) {
48
+ providerBuilder .addSpanProcessor (create (properties ));
71
49
} else {
72
50
log .finest (
73
51
"Not enabling inferred spans processor because " + ENABLED_OPTION + " is not set" );
@@ -76,6 +54,36 @@ public void customize(AutoConfigurationCustomizer config) {
76
54
});
77
55
}
78
56
57
+ static InferredSpansProcessor create (ConfigProperties properties ) {
58
+ InferredSpansProcessorBuilder builder = InferredSpansProcessor .builder ();
59
+
60
+ PropertiesApplier applier = new PropertiesApplier (properties );
61
+
62
+ applier .applyBool (LOGGING_OPTION , builder ::profilerLoggingEnabled );
63
+ applier .applyBool (DIAGNOSTIC_FILES_OPTION , builder ::backupDiagnosticFiles );
64
+ applier .applyInt (SAFEMODE_OPTION , builder ::asyncProfilerSafeMode );
65
+ applier .applyBool (POSTPROCESSING_OPTION , builder ::postProcessingEnabled );
66
+ applier .applyDuration (SAMPLING_INTERVAL_OPTION , builder ::samplingInterval );
67
+ applier .applyDuration (MIN_DURATION_OPTION , builder ::inferredSpansMinDuration );
68
+ applier .applyWildcards (INCLUDED_CLASSES_OPTION , builder ::includedClasses );
69
+ applier .applyWildcards (EXCLUDED_CLASSES_OPTION , builder ::excludedClasses );
70
+ applier .applyDuration (INTERVAL_OPTION , builder ::profilerInterval );
71
+ applier .applyDuration (DURATION_OPTION , builder ::profilingDuration );
72
+ applier .applyString (LIB_DIRECTORY_OPTION , builder ::profilerLibDirectory );
73
+
74
+ String parentOverrideHandlerName = properties .getString (PARENT_OVERRIDE_HANDLER_OPTION );
75
+ if (parentOverrideHandlerName != null && !parentOverrideHandlerName .isEmpty ()) {
76
+ builder .parentOverrideHandler (constructParentOverrideHandler (parentOverrideHandlerName ));
77
+ }
78
+
79
+ InferredSpansProcessor spanProcessor = builder .build ();
80
+ return spanProcessor ;
81
+ }
82
+
83
+ static boolean isEnabled (ConfigProperties properties ) {
84
+ return properties .getBoolean (ENABLED_OPTION , false );
85
+ }
86
+
79
87
@ SuppressWarnings ("unchecked" )
80
88
private static BiConsumer <SpanBuilder , SpanContext > constructParentOverrideHandler (String name ) {
81
89
try {
0 commit comments