Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove dependency on abstract message in schema extractor #7260

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading