File tree Expand file tree Collapse file tree 2 files changed +13
-9
lines changed
aws-xray-recorder-sdk-core/src/main/java/com/amazonaws/xray Expand file tree Collapse file tree 2 files changed +13
-9
lines changed Original file line number Diff line number Diff line change @@ -138,6 +138,10 @@ public class AWSXRayRecorder {
138138 private boolean forcedTraceIdGeneration ;
139139
140140 public AWSXRayRecorder () {
141+ this (null );
142+ }
143+
144+ AWSXRayRecorder (Emitter sharedEmitter ) {
141145 samplingStrategy = new DefaultSamplingStrategy ();
142146 streamingStrategy = new DefaultStreamingStrategy ();
143147 prioritizationStrategy = new DefaultPrioritizationStrategy ();
@@ -175,10 +179,14 @@ public AWSXRayRecorder() {
175179 serviceRuntimeContext = new ConcurrentHashMap <>();
176180 serviceRuntimeContext .putAll (RUNTIME_INFORMATION );
177181
178- try {
179- emitter = Emitter .create ();
180- } catch (IOException e ) {
181- throw new RuntimeException ("Unable to instantiate AWSXRayRecorder: " , e );
182+ if (sharedEmitter != null ) {
183+ emitter = sharedEmitter ;
184+ } else {
185+ try {
186+ emitter = Emitter .create ();
187+ } catch (IOException e ) {
188+ throw new RuntimeException ("Unable to instantiate AWSXRayRecorder: " , e );
189+ }
182190 }
183191 }
184192
Original file line number Diff line number Diff line change @@ -267,7 +267,7 @@ public AWSXRayRecorderBuilder withForcedTraceIdGeneration() {
267267 * @return a configured instance of AWSXRayRecorder
268268 */
269269 public AWSXRayRecorder build () {
270- AWSXRayRecorder client = new AWSXRayRecorder ();
270+ AWSXRayRecorder client = new AWSXRayRecorder (emitter );
271271
272272 if (samplingStrategy != null ) {
273273 client .setSamplingStrategy (samplingStrategy );
@@ -291,10 +291,6 @@ public AWSXRayRecorder build() {
291291 client .setSegmentContextResolverChain (segmentContextResolverChain );
292292 }
293293
294- if (emitter != null ) {
295- client .setEmitter (emitter );
296- }
297-
298294 if (!segmentListeners .isEmpty ()) {
299295 client .addAllSegmentListeners (segmentListeners );
300296 }
You can’t perform that action at this time.
0 commit comments