File tree 3 files changed +20
-0
lines changed
apm-agent-core/src/main/java/co/elastic/apm/agent
apm-agent-tracer/src/main/java/co/elastic/apm/agent/tracer/configuration
3 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -883,6 +883,14 @@ public String toSafeString(List<WildcardMatcher> value) {
883
883
.dynamic (true )
884
884
.buildWithDefault (Arrays .asList (WildcardMatcher .valueOf ("*" )));
885
885
886
+ private final ConfigurationOption <Boolean > captureThreadOnStart = ConfigurationOption .booleanOption ()
887
+ .key ("capture_thread_on_start" )
888
+ .configurationCategory (CORE_CATEGORY )
889
+ .description ("Whether to capture tread name and ID as labels." )
890
+ .dynamic (true )
891
+ .tags ("internal" )
892
+ .buildWithDefault (false );
893
+
886
894
public boolean isEnabled () {
887
895
return enabled .get ();
888
896
}
@@ -1217,4 +1225,8 @@ public String toString() {
1217
1225
}
1218
1226
}
1219
1227
1228
+ @ Override
1229
+ public boolean isCaptureThreadOnStart () {
1230
+ return captureThreadOnStart .get ();
1231
+ }
1220
1232
}
Original file line number Diff line number Diff line change @@ -542,6 +542,12 @@ protected void onAfterStart() {
542
542
543
543
List <WildcardMatcher > baggageToAttach = tracer .getConfig (CoreConfigurationImpl .class ).getBaggageToAttach ();
544
544
baggage .storeBaggageInAttributes (this , baggageToAttach );
545
+
546
+ if (tracer .getConfig (CoreConfigurationImpl .class ).isCaptureThreadOnStart ()) {
547
+ Thread currentThread = Thread .currentThread ();
548
+ this .addLabel ("thread_id" , currentThread .getId ());
549
+ this .addLabel ("thread_name" , currentThread .getName ());
550
+ }
545
551
}
546
552
547
553
@ Override
Original file line number Diff line number Diff line change @@ -54,6 +54,8 @@ public interface CoreConfiguration {
54
54
55
55
boolean isUseServletAttributesForExceptionPropagation ();
56
56
57
+ boolean isCaptureThreadOnStart ();
58
+
57
59
enum EventType {
58
60
/**
59
61
* Request bodies will never be reported
You can’t perform that action at this time.
0 commit comments