Skip to content

Commit

Permalink
remove dependency on abstract message in schema extractor
Browse files Browse the repository at this point in the history
  • Loading branch information
piochelepiotr committed Jun 28, 2024
1 parent 08f0979 commit fec8d9f
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 @@ -58,7 +58,11 @@ public void methodAdvice(MethodTransformer transformer) {
public static class WriteToAdvice {
@Advice.OnMethodEnter(suppress = Throwable.class)
public static void onEnter(@Advice.This AbstractMessage message) {
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 @@ -68,7 +68,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 fec8d9f

Please sign in to comment.