Emit GRPC_CALLS edge via gRPC Route node. */
| 1868 | |
| 1869 | /* Emit GRPC_CALLS edge via gRPC Route node. */ |
| 1870 | static void emit_grpc_edge(cbm_gbuf_t *gbuf, const cbm_gbuf_node_t *source, const CBMCall *call, |
| 1871 | const cbm_resolution_t *res) { |
| 1872 | char service[CBM_SZ_256]; |
| 1873 | char method[CBM_SZ_256]; |
| 1874 | /* Try callee_name first (e.g., "pb.NewCartServiceClient.GetCart") */ |
| 1875 | if (!extract_grpc_service_method(call->callee_name, service, sizeof(service), method, |
| 1876 | sizeof(method))) { |
| 1877 | /* Fallback: try the resolved QN for Go chained calls. |
| 1878 | * Go pattern: pb.NewCartServiceClient(conn).GetCart(ctx, req) |
| 1879 | * callee_name = "GetCart", QN = "...CartServiceClient.GetCart" |
| 1880 | * The QN contains the full ServiceClient.Method pattern. */ |
| 1881 | if (!res->qualified_name || |
| 1882 | !extract_grpc_service_method(res->qualified_name, service, sizeof(service), method, |
| 1883 | sizeof(method))) { |
| 1884 | return; |
| 1885 | } |
| 1886 | } |
| 1887 | |
| 1888 | char route_qn[CBM_SZ_512]; |
| 1889 | snprintf(route_qn, sizeof(route_qn), "__grpc__%s/%s", service, method); |
| 1890 | |
| 1891 | char route_name[CBM_SZ_256]; |
| 1892 | snprintf(route_name, sizeof(route_name), "%s/%s", service, method); |
| 1893 | |
| 1894 | int64_t route_id = cbm_gbuf_upsert_node(gbuf, "Route", route_name, route_qn, "", 0, 0, |
| 1895 | "{\"source\":\"grpc\"}"); |
| 1896 | |
| 1897 | char esc_c[CBM_SZ_256]; |
| 1898 | cbm_json_escape(esc_c, sizeof(esc_c), call->callee_name); |
| 1899 | char props[CBM_SZ_1K]; |
| 1900 | snprintf(props, sizeof(props), |
| 1901 | "{\"callee\":\"%s\",\"service\":\"%s\",\"method\":\"%s\",\"confidence\":%.2f}", esc_c, |
| 1902 | service, method, res->confidence); |
| 1903 | cbm_gbuf_insert_edge(gbuf, source->id, route_id, "GRPC_CALLS", props); |
| 1904 | } |
| 1905 | |
| 1906 | /* Emit GRAPHQL_CALLS edge. Extract operation from first string arg if available. */ |
| 1907 | static void emit_graphql_edge(cbm_gbuf_t *gbuf, const cbm_gbuf_node_t *source, const CBMCall *call, |
no test coverage detected