Skip to content

Commit 7aba1f7

Browse files
committed
Revert "Merge branch 'add-prometheus-metrics-endpoint'"
This reverts commit e5c0f15 due to iv-org/invidious#3576 (comment) , reversing changes made to ecacbab.
1 parent 8be23eb commit 7aba1f7

File tree

6 files changed

+0
-99
lines changed

6 files changed

+0
-99
lines changed

src/invidious.cr

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,6 @@ end
190190

191191
if CONFIG.statistics_enabled
192192
Invidious::Jobs.register Invidious::Jobs::StatisticsRefreshJob.new(PG_DB, SOFTWARE)
193-
add_handler Metrics::RouteMetricsCollector.new
194193
end
195194

196195
if (CONFIG.use_pubsub_feeds.is_a?(Bool) && CONFIG.use_pubsub_feeds.as(Bool)) || (CONFIG.use_pubsub_feeds.is_a?(Int32) && CONFIG.use_pubsub_feeds.as(Int32) > 0)

src/invidious/helpers/helpers.cr

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -198,11 +198,3 @@ def get_playback_statistic
198198

199199
return tracker.as(Hash(String, Int64 | Float64))
200200
end
201-
202-
def to_prometheus_metrics(metrics_struct : Hash(String, Number)) : String
203-
return String.build do |str|
204-
metrics_struct.each.each do |key, value|
205-
str << key << " " << value << "\n"
206-
end
207-
end
208-
end

src/invidious/jobs/statistics_refresh_job.cr

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,6 @@ class Invidious::Jobs::StatisticsRefreshJob < Invidious::Jobs::BaseJob
2727
"playback" => {} of String => Int64 | Float64,
2828
}
2929

30-
STATISTICS_PROMETHEUS = {
31-
"invidious_updated_at" => Time.utc.to_unix,
32-
"invidious_last_channel_refreshed_at" => 0_i64,
33-
}
34-
3530
private getter db : DB::Database
3631

3732
def initialize(@db, @software_config : Hash(String, String))
@@ -64,9 +59,6 @@ class Invidious::Jobs::StatisticsRefreshJob < Invidious::Jobs::BaseJob
6459
users["activeHalfyear"] = Invidious::Database::Statistics.count_users_active_6m
6560
users["activeMonth"] = Invidious::Database::Statistics.count_users_active_1m
6661

67-
STATISTICS_PROMETHEUS["invidious_updated_at"] = Time.utc.to_unix
68-
STATISTICS_PROMETHEUS["invidious_last_channel_refreshed_at"] = Invidious::Database::Statistics.channel_last_update.try &.to_unix || 0_i64
69-
7062
STATISTICS["metadata"] = {
7163
"updatedAt" => Time.utc.to_unix,
7264
"lastChannelRefreshedAt" => Invidious::Database::Statistics.channel_last_update.try &.to_unix || 0_i64,

src/invidious/metrics.cr

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

src/invidious/routes/api/v1/misc.cr

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
require "../../../metrics.cr"
2-
31
module Invidious::Routes::API::V1::Misc
42
# Stats API endpoint for Invidious
53
def self.stats(env)
@@ -28,39 +26,6 @@ module Invidious::Routes::API::V1::Misc
2826
end
2927
end
3028

31-
def self.metrics(env)
32-
if !CONFIG.statistics_enabled
33-
env.response.status_code = 204
34-
return
35-
end
36-
37-
env.response.content_type = "text/plain"
38-
39-
return String.build do |str|
40-
Metrics::RouteMetricsCollector.num_of_request_counters.each do |metric_labels, value|
41-
str << "http_requests_total{"
42-
str << "method=\"" << metric_labels.request_method << "\" "
43-
str << "route=\"" << metric_labels.request_route << "\" "
44-
str << "response_code=\"" << metric_labels.response_code << "\""
45-
str << "} "
46-
str << value << "\n"
47-
end
48-
49-
Metrics::RouteMetricsCollector.request_duration_seconds_sums.each do |metric_labels, value|
50-
str << "http_request_duration_seconds_sum{"
51-
str << "method=\"" << metric_labels.request_method << "\" "
52-
str << "route=\"" << metric_labels.request_route << "\" "
53-
str << "response_code=\"" << metric_labels.response_code << "\""
54-
str << "} "
55-
str << value << "\n"
56-
end
57-
58-
Invidious::Jobs::StatisticsRefreshJob::STATISTICS_PROMETHEUS.each.each do |key, value|
59-
str << key << " " << value << "\n"
60-
end
61-
end
62-
end
63-
6429
# APIv1 currently uses the same logic for both
6530
# user playlists and Invidious playlists. This means that we can't
6631
# reasonably split them yet. This should be addressed in APIv2

src/invidious/routing.cr

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,6 @@ module Invidious::Routing
312312

313313
# Misc
314314
get "/api/v1/stats", {{namespace}}::Misc, :stats
315-
get "/api/v1/metrics", {{namespace}}::Misc, :metrics
316315
get "/api/v1/playlists/:plid", {{namespace}}::Misc, :get_playlist
317316
get "/api/v1/auth/playlists/:plid", {{namespace}}::Misc, :get_playlist
318317
get "/api/v1/mixes/:rdid", {{namespace}}::Misc, :mixes

0 commit comments

Comments
 (0)