Skip to content

Commit a3685dd

Browse files
author
Lukas Wingerberg
committed
add some prometheus metrics
1 parent 6ea37d4 commit a3685dd

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

server/grpc-ffmpeg.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
SSL_KEY_PATH = os.getenv('SSL_KEY_PATH', 'server.key')
3131
SSL_CERT_PATH = os.getenv('SSL_CERT_PATH', 'server.crt')
3232
USE_SSL = os.getenv('USE_SSL', 'false').lower() == 'true'
33+
MAX_FFMPEG_WORKERS= os.getenv('MAX_FFMPEG_WORKERS', 10)
3334

3435
# Health check variables
3536
HEALTHCHECK_INTERVAL = 60 # Interval in seconds (1 hour)
@@ -45,6 +46,7 @@
4546
for binary in ALLOWED_BINARIES
4647
}
4748
ffmpeg_process_gauge = Gauge("ffmpeg_process_count", "Number of running ffmpeg processes")
49+
ffmpeg_max_workers_gauge = Gauge('ffmpeg_max_workers', 'Maximum number of allowed ffmpeg processes based on thread pool size')
4850

4951

5052
class TokenAuthValidator(grpc.AuthMetadataPlugin):
@@ -188,9 +190,12 @@ async def is_file_valid(self, filename):
188190
return False
189191

190192
async def start_grpc_server():
191-
server = grpc.aio.server(ThreadPoolExecutor(max_workers=10))
193+
server = grpc.aio.server(ThreadPoolExecutor(max_workers=MAX_FFMPEG_WORKERS))
192194
ffmpeg_pb2_grpc.add_FFmpegServiceServicer_to_server(FFmpegService(), server)
193195

196+
# Set the ffmpeg_max_workers metric to the max_workers value
197+
ffmpeg_max_workers_gauge.set(MAX_FFMPEG_WORKERS)
198+
194199
listen_addr = '0.0.0.0:50051'
195200
if USE_SSL:
196201
with open(SSL_CERT_PATH, 'rb') as f:

0 commit comments

Comments
 (0)