10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
# File 'lib/fast_exists/intelligence/health.rb', line 10
def run_checks
items = []
backend_symbol = FastExists.configuration.backend
items << check_item(
name: "Backend Availability",
status: FastExists.backends.registered?(backend_symbol) ? :pass : :critical,
message: "Backend '#{backend_symbol}' is registered and active"
)
if [:redis, :redis_bloom].include?(backend_symbol)
redis_ok = check_redis_connection
items << check_item(
name: "Redis Connectivity",
status: redis_ok ? :pass : :critical,
message: redis_ok ? "Connected to Redis successfully" : "Redis client connection failed"
)
if backend_symbol == :redis_bloom
rb_ok = check_redis_bloom_module
items << check_item(
name: "RedisBloom Module",
status: rb_ok ? :pass : :warning,
message: rb_ok ? "RedisBloom module loaded" : "RedisBloom module not detected on Redis server"
)
end
end
stats = FastExists.stats
fp_rate = stats[:false_positive_rate] || 0.0
if fp_rate > 0.02
items << check_item(name: "False Positive Rate", status: :critical, message: "False positive rate high (#{(fp_rate * 100).round(2)}%)")
elsif fp_rate > 0.005
items << check_item(name: "False Positive Rate", status: :warning, message: "False positive rate increasing (#{(fp_rate * 100).round(2)}%)")
else
items << check_item(name: "False Positive Rate", status: :pass, message: "False positive rate healthy")
end
sync_ok = FastExists.configuration.auto_sync
items << check_item(
name: "Synchronization Health",
status: sync_ok ? :pass : :warning,
message: sync_ok ? "Automatic commit synchronization active" : "Auto sync disabled"
)
inst_ok = FastExists.configuration.instrumentation
items << check_item(
name: "Instrumentation Status",
status: inst_ok ? :pass : :pass,
message: inst_ok ? "ActiveSupport::Notifications enabled" : "Instrumentation disabled"
)
items << check_item(
name: "Version Compatibility",
status: :pass,
message: "Ruby #{RUBY_VERSION} compatible with fast_exists v#{FastExists::VERSION}"
)
overall_status = determine_overall_status(items)
{
overall_status: overall_status,
checks: items
}
end
|