@@ -276,12 +276,12 @@ public static void request(
276276 throws AtlanException {
277277 // Create a unique ID for every request, and add it to the logging context and header
278278 String requestId = UUID .randomUUID ().toString ();
279- MDC . put ( "X-Atlan-Request-Id" , requestId );
279+ injectTraceId ( requestId );
280280 log .debug ("({}) {} with: {}" , method , url , body );
281281 ApiResource .atlanResponseGetter .request (client , method , url , body , options , requestId );
282282 // Ensure we reset the Atlan request ID, so we always have the context from the original
283283 // request that was made (even if it in turn triggered off other requests)
284- MDC . put ( "X-Atlan-Request-Id" , requestId );
284+ injectTraceId ( requestId );
285285 if (log .isDebugEnabled ()) {
286286 log .debug (" ... empty response." );
287287 }
@@ -360,12 +360,12 @@ public static <T extends ApiResource> T request(
360360 throws AtlanException {
361361 // Create a unique ID for every request, and add it to the logging context and header
362362 String requestId = UUID .randomUUID ().toString ();
363- MDC . put ( "X-Atlan-Request-Id" , requestId );
363+ injectTraceId ( requestId );
364364 log .debug ("({}) {} with: {}" , method , url , body );
365365 T response = ApiResource .atlanResponseGetter .request (client , method , url , body , clazz , options , requestId );
366366 // Ensure we reset the Atlan request ID, so we always have the context from the original
367367 // request that was made (even if it in turn triggered off other requests)
368- MDC . put ( "X-Atlan-Request-Id" , requestId );
368+ injectTraceId ( requestId );
369369 if (log .isDebugEnabled () && (options == null || !options .getSkipLogging ())) {
370370 if (response != null ) {
371371 if (Atlan .enableTelemetry ) {
@@ -404,13 +404,13 @@ public static String requestPlainText(
404404 throws AtlanException {
405405 // Create a unique ID for every request, and add it to the logging context and header
406406 String requestId = UUID .randomUUID ().toString ();
407- MDC . put ( "X-Atlan-Request-Id" , requestId );
407+ injectTraceId ( requestId );
408408 log .debug ("({}) {} with: {}" , method , url , body );
409409 String response =
410410 ApiResource .atlanResponseGetter .requestPlainText (client , method , url , body , options , requestId );
411411 // Ensure we reset the Atlan request ID, so we always have the context from the original
412412 // request that was made (even if it in turn triggered off other requests)
413- MDC . put ( "X-Atlan-Request-Id" , requestId );
413+ injectTraceId ( requestId );
414414 if (log .isDebugEnabled ()) {
415415 if (response != null ) {
416416 log .debug (" ... response: {}" , response );
@@ -481,13 +481,13 @@ public static <T extends ApiResource> T request(
481481 }
482482 // Create a unique ID for every request, and add it to the logging context and header
483483 String requestId = UUID .randomUUID ().toString ();
484- MDC . put ( "X-Atlan-Request-Id" , requestId );
484+ injectTraceId ( requestId );
485485 log .debug ("({}) {} with: {}" , method , url , filename );
486486 T response = ApiResource .atlanResponseGetter .request (
487487 client , method , url , payload , filename , clazz , extras , options , requestId );
488488 // Ensure we reset the Atlan request ID, so we always have the context from the original
489489 // request that was made (even if it in turn triggered off other requests)
490- MDC . put ( "X-Atlan-Request-Id" , requestId );
490+ injectTraceId ( requestId );
491491 if (log .isDebugEnabled ()) {
492492 if (response != null ) {
493493 if (Atlan .enableTelemetry ) {
@@ -531,11 +531,11 @@ public static <T extends ApiResource> T request(
531531 }
532532 // Create a unique ID for every request, and add it to the logging context and header
533533 String requestId = UUID .randomUUID ().toString ();
534- MDC . put ( "X-Atlan-Request-Id" , requestId );
534+ injectTraceId ( requestId );
535535 T response = ApiResource .atlanResponseGetter .request (client , method , url , map , clazz , options , requestId );
536536 // Ensure we reset the Atlan request ID, so we always have the context from the original
537537 // request that was made (even if it in turn triggered off other requests)
538- MDC . put ( "X-Atlan-Request-Id" , requestId );
538+ injectTraceId ( requestId );
539539 if (log .isDebugEnabled ()) {
540540 if (response != null ) {
541541 if (Atlan .enableTelemetry ) {
@@ -550,6 +550,10 @@ public static <T extends ApiResource> T request(
550550 return response ;
551551 }
552552
553+ public static void injectTraceId (String requestId ) {
554+ MDC .put ("trace_id" , requestId );
555+ }
556+
553557 /**
554558 * Invalidate null typed parameters.
555559 *
0 commit comments