Skip to content

Commit cc7160d

Browse files
committed
refactor: remove observability & perf code added for experimental use
1 parent e24d8d7 commit cc7160d

File tree

21 files changed

+9
-2695
lines changed

21 files changed

+9
-2695
lines changed

analytics/reporter.go

Lines changed: 0 additions & 181 deletions
This file was deleted.

api/health.go

Lines changed: 0 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@ package api
33
import (
44
"encoding/json"
55
"net/http"
6-
"runtime"
76
"time"
8-
9-
"github.com/malwarebo/conductor/utils"
107
)
118

129
type HealthResponse struct {
@@ -15,21 +12,6 @@ type HealthResponse struct {
1512
Uptime string `json:"uptime"`
1613
}
1714

18-
type MetricsResponse struct {
19-
GoRoutines int `json:"goroutines"`
20-
Memory Memory `json:"memory"`
21-
Uptime string `json:"uptime"`
22-
Providers map[string]interface{} `json:"providers,omitempty"`
23-
Business map[string]interface{} `json:"business_metrics,omitempty"`
24-
}
25-
26-
type Memory struct {
27-
Alloc uint64 `json:"alloc"`
28-
TotalAlloc uint64 `json:"total_alloc"`
29-
Sys uint64 `json:"sys"`
30-
NumGC uint32 `json:"num_gc"`
31-
}
32-
3315
var startTime = time.Now()
3416

3517
func CreateHealthCheckHandler(w http.ResponseWriter, r *http.Request) {
@@ -48,54 +30,3 @@ func CreateHealthCheckHandler(w http.ResponseWriter, r *http.Request) {
4830
return
4931
}
5032
}
51-
52-
func CreateMetricsHandler(w http.ResponseWriter, r *http.Request) {
53-
var m runtime.MemStats
54-
runtime.ReadMemStats(&m)
55-
56-
uptime := time.Since(startTime)
57-
58-
businessMetrics := make(map[string]interface{})
59-
allMetrics := utils.CreateGetAllMetrics()
60-
61-
paymentCounts := make(map[string]int)
62-
fraudCounts := make(map[string]int)
63-
providerCounts := make(map[string]int)
64-
65-
for _, metric := range allMetrics {
66-
switch metric.Name {
67-
case "payments_total":
68-
key := metric.Labels["status"] + "_" + metric.Labels["currency"]
69-
paymentCounts[key] = int(metric.Value)
70-
case "fraud_analysis_total":
71-
key := metric.Labels["status"]
72-
fraudCounts[key] = int(metric.Value)
73-
case "provider_operations_total":
74-
key := metric.Labels["provider"] + "_" + metric.Labels["status"]
75-
providerCounts[key] = int(metric.Value)
76-
}
77-
}
78-
79-
businessMetrics["payments"] = paymentCounts
80-
businessMetrics["fraud_analysis"] = fraudCounts
81-
businessMetrics["provider_operations"] = providerCounts
82-
83-
response := MetricsResponse{
84-
GoRoutines: runtime.NumGoroutine(),
85-
Memory: Memory{
86-
Alloc: m.Alloc,
87-
TotalAlloc: m.TotalAlloc,
88-
Sys: m.Sys,
89-
NumGC: m.NumGC,
90-
},
91-
Uptime: uptime.String(),
92-
Business: businessMetrics,
93-
}
94-
95-
w.Header().Set("Content-Type", "application/json")
96-
w.WriteHeader(http.StatusOK)
97-
if err := json.NewEncoder(w).Encode(response); err != nil {
98-
http.Error(w, "Failed to encode response", http.StatusInternalServerError)
99-
return
100-
}
101-
}

api/routing_handler.go

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,6 @@ func (h *RoutingHandler) HandleRouting(w http.ResponseWriter, r *http.Request) {
5151

5252
response.RoutingTime = time.Since(startTime).Milliseconds()
5353

54-
utils.CreateRecordRoutingMetrics(r.Context(), response.RecommendedProvider, response.ConfidenceScore, response.EstimatedSuccessRate)
55-
5654
w.Header().Set("Content-Type", "application/json")
5755
w.WriteHeader(http.StatusOK)
5856

@@ -83,51 +81,6 @@ func (h *RoutingHandler) HandleProviderStats(w http.ResponseWriter, r *http.Requ
8381
}
8482
}
8583

86-
func (h *RoutingHandler) HandleRoutingMetrics(w http.ResponseWriter, r *http.Request) {
87-
startDateStr := r.URL.Query().Get("start_date")
88-
endDateStr := r.URL.Query().Get("end_date")
89-
90-
var err error
91-
92-
if startDateStr != "" {
93-
_, err = time.Parse(time.RFC3339, startDateStr)
94-
if err != nil {
95-
http.Error(w, "Invalid start_date format. Use RFC3339 (e.g., 2024-01-01T00:00:00Z)", http.StatusBadRequest)
96-
return
97-
}
98-
}
99-
100-
if endDateStr != "" {
101-
_, err = time.Parse(time.RFC3339, endDateStr)
102-
if err != nil {
103-
http.Error(w, "Invalid end_date format. Use RFC3339 (e.g., 2024-01-01T00:00:00Z)", http.StatusBadRequest)
104-
return
105-
}
106-
}
107-
108-
metrics := &models.RoutingMetrics{
109-
TotalDecisions: 1000,
110-
CacheHitRate: 0.75,
111-
AvgConfidenceScore: 85.5,
112-
SuccessRate: 0.96,
113-
AvgResponseTime: 150,
114-
CostSavings: 1250.50,
115-
ProviderDistribution: map[string]int64{
116-
"stripe": 650,
117-
"xendit": 350,
118-
},
119-
}
120-
121-
w.Header().Set("Content-Type", "application/json")
122-
w.WriteHeader(http.StatusOK)
123-
124-
if err := json.NewEncoder(w).Encode(metrics); err != nil {
125-
utils.CreateLogger("conductor").Error(r.Context(), "Failed to encode routing metrics", map[string]interface{}{
126-
"error": err.Error(),
127-
})
128-
}
129-
}
130-
13184
func (h *RoutingHandler) HandleRoutingConfig(w http.ResponseWriter, r *http.Request) {
13285
switch r.Method {
13386
case "GET":

docker/docker-compose.yml

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -42,30 +42,6 @@ services:
4242
- redis_data:/data
4343
restart: unless-stopped
4444

45-
prometheus:
46-
image: prom/prometheus:latest
47-
ports:
48-
- "9090:9090"
49-
volumes:
50-
- ./prometheus.yml:/etc/prometheus/prometheus.yml
51-
command:
52-
- '--config.file=/etc/prometheus/prometheus.yml'
53-
- '--storage.tsdb.path=/prometheus'
54-
- '--web.console.libraries=/etc/prometheus/console_libraries'
55-
- '--web.console.templates=/etc/prometheus/consoles'
56-
restart: unless-stopped
57-
58-
grafana:
59-
image: grafana/grafana:latest
60-
ports:
61-
- "3000:3000"
62-
environment:
63-
- GF_SECURITY_ADMIN_PASSWORD=admin
64-
volumes:
65-
- grafana_data:/var/lib/grafana
66-
restart: unless-stopped
67-
6845
volumes:
6946
postgres_data:
7047
redis_data:
71-
grafana_data:

docker/prometheus.yml

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)