Skip to content

Commit

Permalink
Fix equals/hashCode for CodeOrigin probe (#8319)
Browse files Browse the repository at this point in the history
add toString
  • Loading branch information
jpbempel authored Feb 3, 2025
1 parent 5d18c24 commit 28acd37
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import static java.util.Arrays.asList;
import static java.util.Collections.singletonList;

import com.datadog.debugger.agent.Generated;
import com.datadog.debugger.instrumentation.CodeOriginInstrumentor;
import com.datadog.debugger.instrumentation.DiagnosticMessage;
import com.datadog.debugger.instrumentation.InstrumentationResult.Status;
Expand All @@ -17,7 +18,9 @@
import datadog.trace.bootstrap.debugger.ProbeLocation;
import datadog.trace.bootstrap.instrumentation.api.AgentSpan;
import datadog.trace.bootstrap.instrumentation.api.AgentTracer;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -89,4 +92,46 @@ public void buildLocation(MethodInfo methodInfo) {
}
this.location = new ProbeLocation(type, method, file, lines);
}

@Generated
@Override
public boolean equals(Object o) {
if (o == null || getClass() != o.getClass()) return false;
CodeOriginProbe that = (CodeOriginProbe) o;
return Objects.equals(language, that.language)
&& Objects.equals(id, that.id)
&& version == that.version
&& Arrays.equals(tags, that.tags)
&& Objects.equals(tagMap, that.tagMap)
&& Objects.equals(where, that.where)
&& Objects.equals(evaluateAt, that.evaluateAt)
&& entrySpanProbe == that.entrySpanProbe;
}

@Generated
@Override
public int hashCode() {
int result = Objects.hash(language, id, version, tagMap, where, evaluateAt, entrySpanProbe);
result = 31 * result + Arrays.hashCode(tags);
return result;
}

@Override
public String toString() {
return "CodeOriginProbe{"
+ "id='"
+ id
+ '\''
+ ", version="
+ version
+ ", tags="
+ Arrays.toString(tags)
+ ", where="
+ where
+ ", evaluateAt="
+ evaluateAt
+ ", entrySpanProbe="
+ entrySpanProbe
+ "} ";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -943,18 +943,13 @@ public int hashCode() {
public String toString() {
return getClass().getSimpleName()
+ "{"
+ "language='"
+ language
+ '\''
+ ", id='"
+ "id='"
+ id
+ '\''
+ ", version="
+ version
+ ", tags="
+ Arrays.toString(tags)
+ ", tagMap="
+ tagMap
+ ", where="
+ where
+ ", evaluateAt="
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,18 +201,13 @@ public int hashCode() {
@Override
public String toString() {
return "MetricProbe{"
+ "language='"
+ language
+ '\''
+ ", id='"
+ "id='"
+ id
+ '\''
+ ", version="
+ version
+ ", tags="
+ Arrays.toString(tags)
+ ", tagMap="
+ tagMap
+ ", where="
+ where
+ ", evaluateAt="
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,18 +291,13 @@ public boolean equals(Object o) {
@Override
public String toString() {
return "SpanDecorationProbe{"
+ "language='"
+ language
+ '\''
+ ", id='"
+ "id='"
+ id
+ '\''
+ ", version="
+ version
+ ", tags="
+ Arrays.toString(tags)
+ ", tagMap="
+ tagMap
+ ", where="
+ where
+ ", evaluateAt="
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,13 @@ public boolean equals(Object o) {
@Override
public String toString() {
return "SpanProbe{"
+ "language='"
+ language
+ '\''
+ ", id='"
+ "id='"
+ id
+ '\''
+ ", version="
+ version
+ ", tags="
+ Arrays.toString(tags)
+ ", tagMap="
+ tagMap
+ ", where="
+ where
+ ", evaluateAt="
Expand Down

0 comments on commit 28acd37

Please sign in to comment.