Skip to content

Commit

Permalink
Add rpc.grpc.full_method tag to be used by the backend
Browse files Browse the repository at this point in the history
  • Loading branch information
manuel-alvarez-alvarez committed Jun 5, 2024
1 parent 9d3c7ef commit a32ae9a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public class GatewayBridge {
private static final Pattern QUERY_PARAM_VALUE_SPLITTER = Pattern.compile("=");
private static final Pattern QUERY_PARAM_SPLITTER = Pattern.compile("&");
private static final Map<String, List<String>> EMPTY_QUERY_PARAMS = Collections.emptyMap();
private static final char GRPC_METHOD_START = '/';
private static final String GRPC_FULL_METHOD_NAME_TAG = "rpc.grpc.full_method";

/** User tracking tags that will force the collection of request headers */
private static final String[] USER_TRACKING_TAGS = {
Expand Down Expand Up @@ -370,6 +370,9 @@ public void init() {
if (ctx == null || method == null || method.isEmpty()) {
return NoopFlow.INSTANCE;
}
// set the tag used by the backend to generate the grpc pass-lists
TraceSegment segment = ctx_.getTraceSegment();
segment.setTagCurrent(GRPC_FULL_METHOD_NAME_TAG, method);
while (true) {
DataSubscriberInfo subInfo = grpcServerMethodSubInfo;
if (subInfo == null) {
Expand All @@ -379,9 +382,6 @@ public void init() {
if (subInfo == null || subInfo.isEmpty()) {
return NoopFlow.INSTANCE;
}
if (method.charAt(0) != GRPC_METHOD_START) {
method = GRPC_METHOD_START + method;
}
DataBundle bundle =
new SingletonDataBundle<>(KnownAddresses.GRPC_SERVER_METHOD, method);
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ class ServerMethodTest extends AbstractSpringBootWithGRPCAppSecTest {
def match = grpcRootSpan.triggers[0]['rule_matches'][0]
match != null
match['parameters'][0]['address'] == 'grpc.server.method'
match['parameters'][0]['value'] == '/smoketest.Greeter/Hello'
match['parameters'][0]['value'] == 'smoketest.Greeter/Hello'
grpcRootSpan.meta['rpc.grpc.full_method'] == 'smoketest.Greeter/Hello'
}
}

0 comments on commit a32ae9a

Please sign in to comment.