Skip to content

Commit 28acd37

Browse files
authored
Fix equals/hashCode for CodeOrigin probe (#8319)
add toString
1 parent 5d18c24 commit 28acd37

File tree

5 files changed

+49
-24
lines changed

5 files changed

+49
-24
lines changed

dd-java-agent/agent-debugger/src/main/java/com/datadog/debugger/probe/CodeOriginProbe.java

+45
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import static java.util.Arrays.asList;
77
import static java.util.Collections.singletonList;
88

9+
import com.datadog.debugger.agent.Generated;
910
import com.datadog.debugger.instrumentation.CodeOriginInstrumentor;
1011
import com.datadog.debugger.instrumentation.DiagnosticMessage;
1112
import com.datadog.debugger.instrumentation.InstrumentationResult.Status;
@@ -17,7 +18,9 @@
1718
import datadog.trace.bootstrap.debugger.ProbeLocation;
1819
import datadog.trace.bootstrap.instrumentation.api.AgentSpan;
1920
import datadog.trace.bootstrap.instrumentation.api.AgentTracer;
21+
import java.util.Arrays;
2022
import java.util.List;
23+
import java.util.Objects;
2124
import org.slf4j.Logger;
2225
import org.slf4j.LoggerFactory;
2326

@@ -89,4 +92,46 @@ public void buildLocation(MethodInfo methodInfo) {
8992
}
9093
this.location = new ProbeLocation(type, method, file, lines);
9194
}
95+
96+
@Generated
97+
@Override
98+
public boolean equals(Object o) {
99+
if (o == null || getClass() != o.getClass()) return false;
100+
CodeOriginProbe that = (CodeOriginProbe) o;
101+
return Objects.equals(language, that.language)
102+
&& Objects.equals(id, that.id)
103+
&& version == that.version
104+
&& Arrays.equals(tags, that.tags)
105+
&& Objects.equals(tagMap, that.tagMap)
106+
&& Objects.equals(where, that.where)
107+
&& Objects.equals(evaluateAt, that.evaluateAt)
108+
&& entrySpanProbe == that.entrySpanProbe;
109+
}
110+
111+
@Generated
112+
@Override
113+
public int hashCode() {
114+
int result = Objects.hash(language, id, version, tagMap, where, evaluateAt, entrySpanProbe);
115+
result = 31 * result + Arrays.hashCode(tags);
116+
return result;
117+
}
118+
119+
@Override
120+
public String toString() {
121+
return "CodeOriginProbe{"
122+
+ "id='"
123+
+ id
124+
+ '\''
125+
+ ", version="
126+
+ version
127+
+ ", tags="
128+
+ Arrays.toString(tags)
129+
+ ", where="
130+
+ where
131+
+ ", evaluateAt="
132+
+ evaluateAt
133+
+ ", entrySpanProbe="
134+
+ entrySpanProbe
135+
+ "} ";
136+
}
92137
}

dd-java-agent/agent-debugger/src/main/java/com/datadog/debugger/probe/LogProbe.java

+1-6
Original file line numberDiff line numberDiff line change
@@ -943,18 +943,13 @@ public int hashCode() {
943943
public String toString() {
944944
return getClass().getSimpleName()
945945
+ "{"
946-
+ "language='"
947-
+ language
948-
+ '\''
949-
+ ", id='"
946+
+ "id='"
950947
+ id
951948
+ '\''
952949
+ ", version="
953950
+ version
954951
+ ", tags="
955952
+ Arrays.toString(tags)
956-
+ ", tagMap="
957-
+ tagMap
958953
+ ", where="
959954
+ where
960955
+ ", evaluateAt="

dd-java-agent/agent-debugger/src/main/java/com/datadog/debugger/probe/MetricProbe.java

+1-6
Original file line numberDiff line numberDiff line change
@@ -201,18 +201,13 @@ public int hashCode() {
201201
@Override
202202
public String toString() {
203203
return "MetricProbe{"
204-
+ "language='"
205-
+ language
206-
+ '\''
207-
+ ", id='"
204+
+ "id='"
208205
+ id
209206
+ '\''
210207
+ ", version="
211208
+ version
212209
+ ", tags="
213210
+ Arrays.toString(tags)
214-
+ ", tagMap="
215-
+ tagMap
216211
+ ", where="
217212
+ where
218213
+ ", evaluateAt="

dd-java-agent/agent-debugger/src/main/java/com/datadog/debugger/probe/SpanDecorationProbe.java

+1-6
Original file line numberDiff line numberDiff line change
@@ -291,18 +291,13 @@ public boolean equals(Object o) {
291291
@Override
292292
public String toString() {
293293
return "SpanDecorationProbe{"
294-
+ "language='"
295-
+ language
296-
+ '\''
297-
+ ", id='"
294+
+ "id='"
298295
+ id
299296
+ '\''
300297
+ ", version="
301298
+ version
302299
+ ", tags="
303300
+ Arrays.toString(tags)
304-
+ ", tagMap="
305-
+ tagMap
306301
+ ", where="
307302
+ where
308303
+ ", evaluateAt="

dd-java-agent/agent-debugger/src/main/java/com/datadog/debugger/probe/SpanProbe.java

+1-6
Original file line numberDiff line numberDiff line change
@@ -55,18 +55,13 @@ public boolean equals(Object o) {
5555
@Override
5656
public String toString() {
5757
return "SpanProbe{"
58-
+ "language='"
59-
+ language
60-
+ '\''
61-
+ ", id='"
58+
+ "id='"
6259
+ id
6360
+ '\''
6461
+ ", version="
6562
+ version
6663
+ ", tags="
6764
+ Arrays.toString(tags)
68-
+ ", tagMap="
69-
+ tagMap
7065
+ ", where="
7166
+ where
7267
+ ", evaluateAt="

0 commit comments

Comments
 (0)