gip-inclusion / itou-communaute-django

Site de la Communauté de l'Inclusion (version en Django)
https://communaute.inclusion.beta.gouv.fr/
GNU Affero General Public License v3.0
3 stars 1 forks source link

fix matomo stats collection #801

Closed vincentporte closed 5 days ago

vincentporte commented 4 weeks ago

image

vincentporte commented 6 days ago
2024-11-07T05:00:00.811Z (bas) CMD (/home/bas/app_be9c4821-d5c0-4470-b290-d5d33ad9b4f9/clevercloud/collect_daily_matomo_stats.sh)
2024-11-07T05:00:04.107Z (bas) CMDOUT (REFRESH MATERIALIZED VIEW)
2024-11-07T05:00:04.113Z (bas) CMDEND (/home/bas/app_be9c4821-d5c0-4470-b290-d5d33ad9b4f9/clevercloud/rebuild_index.sh)
2024-11-07T05:00:11.464Z (bas) CMDOUT (Traceback (most recent call last):)
2024-11-07T05:00:11.467Z (bas) CMDOUT (  File "/home/bas/venv/lib/python3.12/site-packages/httpcore/_exceptions.py", line 10, in map_exceptions)
2024-11-07T05:00:11.467Z (bas) CMDOUT (    yield)
2024-11-07T05:00:11.467Z (bas) CMDOUT (  File "/home/bas/venv/lib/python3.12/site-packages/httpcore/backends/sync.py", line 28, in read)
2024-11-07T05:00:11.467Z (bas) CMDOUT (    return self._sock.recv(max_bytes))
2024-11-07T05:00:11.467Z (bas) CMDOUT (           ^^^^^^^^^^^^^^^^^^^^^^^^^^)
2024-11-07T05:00:11.467Z (bas) CMDOUT (  File "/usr/host/lib/python3.12/ssl.py", line 1233, in recv)
2024-11-07T05:00:11.467Z (bas) CMDOUT (    return self.read(buflen))
2024-11-07T05:00:11.467Z (bas) CMDOUT (           ^^^^^^^^^^^^^^^^^)
2024-11-07T05:00:11.467Z (bas) CMDOUT (  File "/usr/host/lib/python3.12/ssl.py", line 1106, in read)
2024-11-07T05:00:11.467Z (bas) CMDOUT (    return self._sslobj.read(len))
2024-11-07T05:00:11.467Z (bas) CMDOUT (           ^^^^^^^^^^^^^^^^^^^^^^)
2024-11-07T05:00:11.467Z (bas) CMDOUT (TimeoutError: The read operation timed out)
2024-11-07T05:00:11.467Z (bas) CMDOUT ()
2024-11-07T05:00:11.467Z (bas) CMDOUT (During handling of the above exception, another exception occurred:)
2024-11-07T05:00:11.467Z (bas) CMDOUT ()
2024-11-07T05:00:11.467Z (bas) CMDOUT (Traceback (most recent call last):)
2024-11-07T05:00:11.469Z (bas) CMDOUT (  File "/home/bas/venv/lib/python3.12/site-packages/httpx/_transports/default.py", line 60, in map_httpcore_exceptions)
2024-11-07T05:00:11.469Z (bas) CMDOUT (    yield)
2024-11-07T05:00:11.469Z (bas) CMDOUT (  File "/home/bas/venv/lib/python3.12/site-packages/httpx/_transports/default.py", line 218, in handle_request)
2024-11-07T05:00:11.469Z (bas) CMDOUT (    resp = self._pool.handle_request(req))
2024-11-07T05:00:11.469Z (bas) CMDOUT (           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^)
2024-11-07T05:00:11.469Z (bas) CMDOUT (  File "/home/bas/venv/lib/python3.12/site-packages/httpcore/_sync/connection_pool.py", line 253, in handle_request)
2024-11-07T05:00:11.469Z (bas) CMDOUT (    raise exc)
2024-11-07T05:00:11.469Z (bas) CMDOUT (  File "/home/bas/venv/lib/python3.12/site-packages/httpcore/_sync/connection_pool.py", line 237, in handle_request)
2024-11-07T05:00:11.469Z (bas) CMDOUT (    response = connection.handle_request(request))
2024-11-07T05:00:11.469Z (bas) CMDOUT (               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^)
2024-11-07T05:00:11.469Z (bas) CMDOUT (  File "/home/bas/venv/lib/python3.12/site-packages/httpcore/_sync/connection.py", line 90, in handle_request)
2024-11-07T05:00:11.469Z (bas) CMDOUT (    return self._connection.handle_request(request))
2024-11-07T05:00:11.469Z (bas) CMDOUT (           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^)
2024-11-07T05:00:11.469Z (bas) CMDOUT (  File "/home/bas/venv/lib/python3.12/site-packages/httpcore/_sync/http11.py", line 112, in handle_request)
2024-11-07T05:00:11.469Z (bas) CMDOUT (    raise exc)
2024-11-07T05:00:11.469Z (bas) CMDOUT (  File "/home/bas/venv/lib/python3.12/site-packages/httpcore/_sync/http11.py", line 91, in handle_request)
2024-11-07T05:00:11.469Z (bas) CMDOUT (    ) = self._receive_response_headers(**kwargs))
2024-11-07T05:00:11.469Z (bas) CMDOUT (        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^)
2024-11-07T05:00:11.469Z (bas) CMDOUT (  File "/home/bas/venv/lib/python3.12/site-packages/httpcore/_sync/http11.py", line 155, in _receive_response_headers)
2024-11-07T05:00:11.469Z (bas) CMDOUT (    event = self._receive_event(timeout=timeout))
2024-11-07T05:00:11.472Z (bas) CMDOUT (            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^)
2024-11-07T05:00:11.472Z (bas) CMDOUT (  File "/home/bas/venv/lib/python3.12/site-packages/httpcore/_sync/http11.py", line 191, in _receive_event)
2024-11-07T05:00:11.472Z (bas) CMDOUT (    data = self._network_stream.read()
2024-11-07T05:00:11.472Z (bas) CMDOUT (           ^^^^^^^^^^^^^^^^^^^^^^^^^^)
2024-11-07T05:00:11.472Z (bas) CMDOUT (  File "/home/bas/venv/lib/python3.12/site-packages/httpcore/backends/sync.py", line 26, in read)
2024-11-07T05:00:11.472Z (bas) CMDOUT (    with map_exceptions(exc_map):)
2024-11-07T05:00:11.472Z (bas) CMDOUT (  File "/usr/host/lib/python3.12/contextlib.py", line 158, in __exit__)
2024-11-07T05:00:11.472Z (bas) CMDOUT (    self.gen.throw(value))
2024-11-07T05:00:11.472Z (bas) CMDOUT (  File "/home/bas/venv/lib/python3.12/site-packages/httpcore/_exceptions.py", line 14, in map_exceptions)
2024-11-07T05:00:11.472Z (bas) CMDOUT (    raise to_exc(exc))
2024-11-07T05:00:11.472Z (bas) CMDOUT (httpcore.ReadTimeout: The read operation timed out)
2024-11-07T05:00:11.472Z (bas) CMDOUT ()
2024-11-07T05:00:11.472Z (bas) CMDOUT (The above exception was the direct cause of the following exception:)
2024-11-07T05:00:11.472Z (bas) CMDOUT ()
2024-11-07T05:00:11.472Z (bas) CMDOUT (Traceback (most recent call last):)
2024-11-07T05:00:11.472Z (bas) CMDOUT (  File "/home/bas/app_be9c4821-d5c0-4470-b290-d5d33ad9b4f9/manage.py", line 31, in <module>)
2024-11-07T05:00:11.472Z (bas) CMDOUT (    main())
2024-11-07T05:00:11.472Z (bas) CMDOUT (  File "/home/bas/app_be9c4821-d5c0-4470-b290-d5d33ad9b4f9/manage.py", line 27, in main)
2024-11-07T05:00:11.472Z (bas) CMDOUT (    execute_from_command_line(sys.argv))
2024-11-07T05:00:11.472Z (bas) CMDOUT (  File "/home/bas/venv/lib/python3.12/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line)
2024-11-07T05:00:11.472Z (bas) CMDOUT (    utility.execute())
2024-11-07T05:00:11.472Z (bas) CMDOUT (  File "/home/bas/venv/lib/python3.12/site-packages/django/core/management/__init__.py", line 436, in execute)
2024-11-07T05:00:11.472Z (bas) CMDOUT (    self.fetch_command(subcommand).run_from_argv(self.argv))
2024-11-07T05:00:11.472Z (bas) CMDOUT (  File "/home/bas/venv/lib/python3.12/site-packages/django/core/management/base.py", line 413, in run_from_argv)
2024-11-07T05:00:11.472Z (bas) CMDOUT (    self.execute(*args, **cmd_options))
2024-11-07T05:00:11.472Z (bas) CMDOUT (  File "/home/bas/venv/lib/python3.12/site-packages/django/core/management/base.py", line 459, in execute)
2024-11-07T05:00:11.472Z (bas) CMDOUT (    output = self.handle(*args, **options))
2024-11-07T05:00:11.473Z (bas) CMDOUT (             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^)
2024-11-07T05:00:11.473Z (bas) CMDOUT (  File "/home/bas/app_be9c4821-d5c0-4470-b290-d5d33ad9b4f9/lacommunaute/stats/management/commands/collect_matomo_stats.py", line 45, in handle)
2024-11-07T05:00:11.474Z (bas) CMDOUT (    collect_stats_from_matomo_api(from_date=from_date, to_date=to_date, period=period))
2024-11-07T05:00:11.475Z (bas) CMDOUT (  File "/home/bas/app_be9c4821-d5c0-4470-b290-d5d33ad9b4f9/lacommunaute/utils/matomo.py", line 185, in collect_stats_from_matomo_api)
2024-11-07T05:00:11.475Z (bas) CMDOUT (    stats += get_matomo_visits_data(period, from_date))
2024-11-07T05:00:11.475Z (bas) CMDOUT (             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^)
2024-11-07T05:00:11.475Z (bas) CMDOUT (  File "/home/bas/app_be9c4821-d5c0-4470-b290-d5d33ad9b4f9/lacommunaute/utils/matomo.py", line 68, in get_matomo_visits_data)
2024-11-07T05:00:11.475Z (bas) CMDOUT (    data = get_matomo_data(period=period, search_date=search_date, method="VisitFrequency.get"))
2024-11-07T05:00:11.475Z (bas) CMDOUT (           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^)
2024-11-07T05:00:11.475Z (bas) CMDOUT (  File "/home/bas/app_be9c4821-d5c0-4470-b290-d5d33ad9b4f9/lacommunaute/utils/matomo.py", line 39, in get_matomo_data)
2024-11-07T05:00:11.477Z (bas) CMDOUT (    response = httpx.get(os.path.join(settings.MATOMO_BASE_URL, "index.php"), params=params))
2024-11-07T05:00:11.477Z (bas) CMDOUT (               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^)
2024-11-07T05:00:11.477Z (bas) CMDOUT (  File "/home/bas/venv/lib/python3.12/site-packages/httpx/_api.py", line 189, in get)