@@ -14,22 +14,26 @@ const DEFAULT_BUCKETS: [f64; 11] = [
14
14
pub struct ToolCallLabels {
15
15
pub tool_name : String ,
16
16
pub status : String ,
17
+ pub api_key : String ,
17
18
}
18
19
19
20
#[ derive( Clone , Hash , PartialEq , Eq , Debug , EncodeLabelSet ) ]
20
21
pub struct ToolCallDurationLabels {
21
22
pub tool_name : String ,
23
+ pub api_key : String ,
22
24
}
23
25
24
26
#[ derive( Clone , Hash , PartialEq , Eq , Debug , EncodeLabelSet ) ]
25
27
pub struct GatewayRequestLabels {
26
28
pub endpoint_type : String ,
27
29
pub status : String ,
30
+ pub api_key : String ,
28
31
}
29
32
30
33
#[ derive( Clone , Hash , PartialEq , Eq , Debug , EncodeLabelSet ) ]
31
34
pub struct GatewayRequestDurationLabels {
32
35
pub endpoint_type : String ,
36
+ pub api_key : String ,
33
37
}
34
38
35
39
#[ derive( Clone ) ]
@@ -58,31 +62,31 @@ impl Metrics {
58
62
59
63
pub fn register ( & self , registry : & mut Registry ) {
60
64
registry. register (
61
- "mcp_tool_calls " ,
65
+ "subgraph_mcp_tool_calls " ,
62
66
"Total number of MCP tool calls" ,
63
67
self . mcp_tool_calls_total . clone ( ) ,
64
68
) ;
65
69
66
70
registry. register (
67
- "mcp_tool_call_duration_seconds " ,
71
+ "subgraph_mcp_tool_call_duration_seconds " ,
68
72
"Duration of MCP tool calls in seconds" ,
69
73
self . mcp_tool_call_duration_seconds . clone ( ) ,
70
74
) ;
71
75
72
76
registry. register (
73
- "gateway_requests " ,
77
+ "subgraph_mcp_gateway_requests " ,
74
78
"Total number of requests to the Graph Gateway" ,
75
79
self . gateway_requests_total . clone ( ) ,
76
80
) ;
77
81
78
82
registry. register (
79
- "gateway_request_duration_seconds " ,
83
+ "subgraph_mcp_gateway_request_duration_seconds " ,
80
84
"Duration of Graph Gateway requests in seconds" ,
81
85
self . gateway_request_duration_seconds . clone ( ) ,
82
86
) ;
83
87
}
84
88
85
- pub async fn observe_tool_call < F , Fut , T > ( & self , tool_name : & str , f : F ) -> T
89
+ pub async fn observe_tool_call < F , Fut , T > ( & self , tool_name : & str , api_key : & str , f : F ) -> T
86
90
where
87
91
F : FnOnce ( ) -> Fut ,
88
92
Fut : std:: future:: Future < Output = T > ,
@@ -102,19 +106,26 @@ impl Metrics {
102
106
. get_or_create ( & ToolCallLabels {
103
107
tool_name : tool_name. to_string ( ) ,
104
108
status : status. to_string ( ) ,
109
+ api_key : api_key. to_string ( ) ,
105
110
} )
106
111
. inc ( ) ;
107
112
108
113
self . mcp_tool_call_duration_seconds
109
114
. get_or_create ( & ToolCallDurationLabels {
110
115
tool_name : tool_name. to_string ( ) ,
116
+ api_key : api_key. to_string ( ) ,
111
117
} )
112
118
. observe ( duration. as_secs_f64 ( ) ) ;
113
119
114
120
result
115
121
}
116
122
117
- pub async fn observe_gateway_request < F , Fut , T > ( & self , endpoint_type : & str , f : F ) -> T
123
+ pub async fn observe_gateway_request < F , Fut , T > (
124
+ & self ,
125
+ endpoint_type : & str ,
126
+ api_key : & str ,
127
+ f : F ,
128
+ ) -> T
118
129
where
119
130
F : FnOnce ( ) -> Fut ,
120
131
Fut : std:: future:: Future < Output = T > ,
@@ -134,12 +145,14 @@ impl Metrics {
134
145
. get_or_create ( & GatewayRequestLabels {
135
146
endpoint_type : endpoint_type. to_string ( ) ,
136
147
status : status. to_string ( ) ,
148
+ api_key : api_key. to_string ( ) ,
137
149
} )
138
150
. inc ( ) ;
139
151
140
152
self . gateway_request_duration_seconds
141
153
. get_or_create ( & GatewayRequestDurationLabels {
142
154
endpoint_type : endpoint_type. to_string ( ) ,
155
+ api_key : api_key. to_string ( ) ,
143
156
} )
144
157
. observe ( duration. as_secs_f64 ( ) ) ;
145
158
0 commit comments