Skip to content

Commit 8d64683

Browse files
authored
logging: clear null trace_id (#2760)
To ThreadLocal, set(null) and remove() are functionally similar but remove() clears out the map-entry so it's more space-efficient. Fixes #2746.
1 parent 19c22a6 commit 8d64683

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

google-cloud-logging/src/main/java/com/google/cloud/logging/TraceLoggingEnhancer.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,11 @@ public TraceLoggingEnhancer(String prefix) {
3838
* @param id The traceID
3939
*/
4040
public static void setCurrentTraceId(String id) {
41-
traceId.set(id);
41+
if (id == null) {
42+
traceId.remove();
43+
} else {
44+
traceId.set(id);
45+
}
4246
}
4347

4448
/**

0 commit comments

Comments
 (0)