django-prometheus icon indicating copy to clipboard operation
django-prometheus copied to clipboard

Use default registry when `prometheus_multiproc_dir` is set

Open Bentechy66 opened this issue 3 years ago • 1 comments

This should allow custom collectors to be used when this envvar is set (see #271) (unless I've missed something and they can already)

Bentechy66 avatar Apr 23 '21 12:04 Bentechy66

this fail with:

django.request:ERROR:: Internal Server Error: /metrics
Traceback (most recent call last):
  File ".../env/lib/python3.7/site-packages/asgiref/sync.py", line 458, in thread_handler
    raise exc_info[1]
  File ".../env/lib/python3.7/site-packages/django/core/handlers/exception.py", line 38, in inner
    response = await get_response(request)
  File ".../env/lib/python3.7/site-packages/django/core/handlers/base.py", line 233, in _get_response_async
    response = await wrapped_callback(request, *callback_args, **callback_kwargs)
  File ".../env/lib/python3.7/site-packages/asgiref/sync.py", line 423, in __call__
    ret = await asyncio.wait_for(future, timeout=None)
  File "/usr/lib/python3.7/asyncio/tasks.py", line 414, in wait_for
    return await fut
  File "/usr/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File ".../env/lib/python3.7/site-packages/asgiref/sync.py", line 462, in thread_handler
    return func(*args, **kwargs)
  File ".../env/lib/python3.7/site-packages/sentry_sdk/integrations/django/views.py", line 67, in sentry_wrapped_callback
    return callback(request, *args, **kwargs)
  File ".../env/lib/python3.7/site-packages/django_prometheus/exports.py", line 122, in ExportToDjangoView
    multiprocess.MultiProcessCollector(registry)
  File ".../env/lib/python3.7/site-packages/prometheus_client/multiprocess.py", line 36, in __init__
    registry.register(self)
  File ".../env/lib/python3.7/site-packages/prometheus_client/registry.py", line 31, in register
    duplicates))
ValueError: Duplicated timeseries in CollectorRegistry: {'django_http_ajax_requests_created', 'django_http_responses_streaming_created', 'django_http_responses_streaming_total', 'django_http_requests_before_middlewares_created', 'django_http_responses_total_by_templatename', 'django_http_responses_body_total_bytes_count', 'django_http_exceptions_total_by_view_total', 'django_http_requests_total_by_method', 'django_http_requests_unknown_latency_total', 'django_http_responses_before_middlewares', 'django_http_responses_body_total_bytes_sum', 'django_http_responses_total_by_templatename_created', 'django_http_responses_total_by_status_view_method_total', 'django_http_requests_latency_including_middlewares_seconds_sum', 'django_http_requests_unknown_latency', 'django_http_responses_body_total_bytes_bucket', 'django_http_requests_latency_including_middlewares_seconds_created', 'django_http_requests_total_by_method_total', 'django_http_responses_total_by_status_view_method_created', 'django_http_requests_latency_seconds_by_view_method_bucket', 'django_http_requests_body_total_bytes_bucket', 'django_http_exceptions_total_by_type_total', 'django_http_requests_total_by_view_transport_method', 'django_http_requests_before_middlewares_total', 'django_http_requests_unknown_latency_including_middlewares', 'django_http_responses_body_total_bytes', 'django_http_requests_total_by_method_created', 'django_http_responses_body_total_bytes_created', 'django_http_requests_body_total_bytes_sum', 'django_http_requests_latency_seconds_by_view_method_sum', 'django_http_responses_before_middlewares_created', 'django_http_ajax_requests', 'django_http_responses_total_by_status_view_method', 'django_http_requests_unknown_latency_including_middlewares_total', 'django_http_requests_unknown_latency_including_middlewares_created', 'django_http_requests_total_by_view_transport_method_total', 'django_http_responses_total_by_status_created', 'django_http_requests_latency_seconds_by_view_method_created', 'django_http_exceptions_total_by_type', 'django_http_exceptions_total_by_view_created', 'django_http_requests_total_by_transport', 'django_http_responses_streaming', 'django_http_requests_body_total_bytes', 'django_http_responses_total_by_charset_created', 'django_http_requests_total_by_transport_total', 'django_http_requests_body_total_bytes_created', 'django_http_requests_latency_including_middlewares_seconds', 'django_http_requests_unknown_latency_created', 'django_http_responses_total_by_status_total', 'django_http_responses_total_by_charset_total', 'django_http_requests_before_middlewares', 'django_http_responses_total_by_templatename_total', 'django_http_requests_latency_including_middlewares_seconds_bucket', 'django_http_requests_latency_seconds_by_view_method_count', 'django_http_exceptions_total_by_type_created', 'django_http_responses_total_by_status', 'django_http_requests_latency_including_middlewares_seconds_count', 'django_http_responses_before_middlewares_total', 'django_http_requests_total_by_transport_created', 'django_http_exceptions_total_by_view', 'django_http_requests_latency_seconds_by_view_method', 'django_http_requests_total_by_view_transport_method_created', 'django_http_requests_body_total_bytes_count', 'django_http_ajax_requests_total', 'django_http_responses_total_by_charset'}

lsaavedr avatar May 24 '21 04:05 lsaavedr