Skip to content

Commit

Permalink
remove dependency on abstract message in schema extractor (#7260)
Browse files Browse the repository at this point in the history
  • Loading branch information
piochelepiotr authored Oct 16, 2024
1 parent 3f89f03 commit a80d13e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,11 @@ public static void onEnter(@Advice.This AbstractMessage message) {
if (callDepth > 0) {
return;
}
SchemaExtractor.attachSchemaOnSpan(message, activeSpan(), SchemaExtractor.serialization);
if (message == null) {
return;
}
SchemaExtractor.attachSchemaOnSpan(
message.getDescriptorForType(), activeSpan(), SchemaExtractor.serialization);
}

@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ public static void stopSpan(
}
if (message instanceof AbstractMessage) {
SchemaExtractor.attachSchemaOnSpan(
(AbstractMessage) message, span, SchemaExtractor.deserialization);
((AbstractMessage) message).getDescriptorForType(),
span,
SchemaExtractor.deserialization);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package datadog.trace.instrumentation.protobuf_java;

import com.google.protobuf.AbstractMessage;
import com.google.protobuf.Descriptors;
import com.google.protobuf.Descriptors.Descriptor;
import com.google.protobuf.Descriptors.FieldDescriptor;
Expand Down Expand Up @@ -170,13 +169,6 @@ public void iterateOverSchema(SchemaBuilder builder) {
extractSchema(descriptor, builder, 0);
}

public static void attachSchemaOnSpan(AbstractMessage message, AgentSpan span, String operation) {
if (message == null) {
return;
}
attachSchemaOnSpan(message.getDescriptorForType(), span, operation);
}

public static void attachSchemaOnSpan(
Descriptors.Descriptor descriptor, AgentSpan span, String operation) {
if (descriptor == null || span == null) {
Expand Down

0 comments on commit a80d13e

Please sign in to comment.