File tree Expand file tree Collapse file tree 1 file changed +16
-10
lines changed
internal-api/src/main/java/datadog/trace/api Expand file tree Collapse file tree 1 file changed +16
-10
lines changed Original file line number Diff line number Diff line change @@ -102,11 +102,13 @@ static void calculate() {
102102 private ProcessTags () {}
103103
104104 // need to be synchronized on writing. As optimization, it does not need to be sync on read.
105- public static synchronized void addTag (String key , String value ) {
105+ public static void addTag (String key , String value ) {
106106 if (enabled ) {
107- Lazy .TAGS .put (key , value );
108- Lazy .serializedForm = null ;
109- Lazy .listForm = null ;
107+ synchronized (Lazy .TAGS ) {
108+ Lazy .TAGS .put (key , value );
109+ Lazy .serializedForm = null ;
110+ Lazy .listForm = null ;
111+ }
110112 }
111113 }
112114
@@ -136,15 +138,19 @@ public static UTF8BytesString getTagsForSerialization() {
136138
137139 /** Visible for testing. */
138140 static void empty () {
139- Lazy .TAGS .clear ();
140- Lazy .serializedForm = null ;
141- Lazy .listForm = null ;
141+ synchronized (Lazy .TAGS ) {
142+ Lazy .TAGS .clear ();
143+ Lazy .serializedForm = null ;
144+ Lazy .listForm = null ;
145+ }
142146 }
143147
144148 /** Visible for testing. */
145149 static void reset () {
146- empty ();
147- enabled = Config .get ().isExperimentalPropagateProcessTagsEnabled ();
148- Lazy .TAGS .putAll (Lazy .loadTags ());
150+ synchronized (Lazy .TAGS ) {
151+ empty ();
152+ enabled = Config .get ().isExperimentalPropagateProcessTagsEnabled ();
153+ Lazy .TAGS .putAll (Lazy .loadTags ());
154+ }
149155 }
150156}
You can’t perform that action at this time.
0 commit comments