1+ using System . Diagnostics . Metrics ;
2+
3+ namespace NLWebNet . Metrics ;
4+
5+ /// <summary>
6+ /// Contains metric definitions and constants for NLWebNet monitoring
7+ /// </summary>
8+ public static class NLWebMetrics
9+ {
10+ /// <summary>
11+ /// The meter name for NLWebNet metrics
12+ /// </summary>
13+ public const string MeterName = "NLWebNet" ;
14+
15+ /// <summary>
16+ /// The version for metrics tracking
17+ /// </summary>
18+ public const string Version = "1.0.0" ;
19+
20+ /// <summary>
21+ /// Shared meter instance for all NLWebNet metrics
22+ /// </summary>
23+ public static readonly Meter Meter = new ( MeterName , Version ) ;
24+
25+ // Request/Response Metrics
26+ public static readonly Counter < long > RequestCount = Meter . CreateCounter < long > (
27+ "nlweb.requests.total" ,
28+ description : "Total number of requests processed" ) ;
29+
30+ public static readonly Histogram < double > RequestDuration = Meter . CreateHistogram < double > (
31+ "nlweb.request.duration" ,
32+ unit : "ms" ,
33+ description : "Duration of request processing in milliseconds" ) ;
34+
35+ public static readonly Counter < long > RequestErrors = Meter . CreateCounter < long > (
36+ "nlweb.requests.errors" ,
37+ description : "Total number of request errors" ) ;
38+
39+ // AI Service Metrics
40+ public static readonly Counter < long > AIServiceCalls = Meter . CreateCounter < long > (
41+ "nlweb.ai.calls.total" ,
42+ description : "Total number of AI service calls" ) ;
43+
44+ public static readonly Histogram < double > AIServiceDuration = Meter . CreateHistogram < double > (
45+ "nlweb.ai.duration" ,
46+ unit : "ms" ,
47+ description : "Duration of AI service calls in milliseconds" ) ;
48+
49+ public static readonly Counter < long > AIServiceErrors = Meter . CreateCounter < long > (
50+ "nlweb.ai.errors" ,
51+ description : "Total number of AI service errors" ) ;
52+
53+ // Data Backend Metrics
54+ public static readonly Counter < long > DataBackendQueries = Meter . CreateCounter < long > (
55+ "nlweb.data.queries.total" ,
56+ description : "Total number of data backend queries" ) ;
57+
58+ public static readonly Histogram < double > DataBackendDuration = Meter . CreateHistogram < double > (
59+ "nlweb.data.duration" ,
60+ unit : "ms" ,
61+ description : "Duration of data backend operations in milliseconds" ) ;
62+
63+ public static readonly Counter < long > DataBackendErrors = Meter . CreateCounter < long > (
64+ "nlweb.data.errors" ,
65+ description : "Total number of data backend errors" ) ;
66+
67+ // Health Check Metrics
68+ public static readonly Counter < long > HealthCheckExecutions = Meter . CreateCounter < long > (
69+ "nlweb.health.checks.total" ,
70+ description : "Total number of health check executions" ) ;
71+
72+ public static readonly Counter < long > HealthCheckFailures = Meter . CreateCounter < long > (
73+ "nlweb.health.failures" ,
74+ description : "Total number of health check failures" ) ;
75+
76+ // Business Metrics
77+ public static readonly Counter < long > QueryTypeCount = Meter . CreateCounter < long > (
78+ "nlweb.queries.by_type" ,
79+ description : "Count of queries by type (List, Summarize, Generate)" ) ;
80+
81+ public static readonly Histogram < double > QueryComplexity = Meter . CreateHistogram < double > (
82+ "nlweb.queries.complexity" ,
83+ description : "Query complexity score based on length and structure" ) ;
84+
85+ /// <summary>
86+ /// Common tag keys for consistent metric labeling
87+ /// </summary>
88+ public static class Tags
89+ {
90+ public const string Endpoint = "endpoint" ;
91+ public const string Method = "method" ;
92+ public const string StatusCode = "status_code" ;
93+ public const string QueryMode = "query_mode" ;
94+ public const string ErrorType = "error_type" ;
95+ public const string HealthCheckName = "health_check" ;
96+ public const string DataBackendType = "backend_type" ;
97+ public const string AIServiceType = "ai_service_type" ;
98+ }
99+ }
0 commit comments