timeexecution 8.4.1__tar.gz → 8.4.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. {timeexecution-8.4.1 → timeexecution-8.4.2}/.github/workflows/tests.yml +1 -1
  2. {timeexecution-8.4.1/timeexecution.egg-info → timeexecution-8.4.2}/PKG-INFO +1 -1
  3. {timeexecution-8.4.1 → timeexecution-8.4.2}/requirements.txt +1 -1
  4. {timeexecution-8.4.1 → timeexecution-8.4.2}/tests/test_elasticsearch.py +6 -1
  5. {timeexecution-8.4.1 → timeexecution-8.4.2}/tests/test_hooks.py +1 -1
  6. {timeexecution-8.4.1 → timeexecution-8.4.2}/time_execution/backends/elasticsearch.py +17 -7
  7. {timeexecution-8.4.1 → timeexecution-8.4.2/timeexecution.egg-info}/PKG-INFO +1 -1
  8. {timeexecution-8.4.1 → timeexecution-8.4.2}/timeexecution.egg-info/SOURCES.txt +2 -0
  9. timeexecution-8.4.2/timeexecution.egg-info/scm_file_list.json +36 -0
  10. timeexecution-8.4.2/timeexecution.egg-info/scm_version.json +8 -0
  11. {timeexecution-8.4.1 → timeexecution-8.4.2}/.editorconfig +0 -0
  12. {timeexecution-8.4.1 → timeexecution-8.4.2}/.gitchangelog.rc +0 -0
  13. {timeexecution-8.4.1 → timeexecution-8.4.2}/.github/workflows/lint.yml +0 -0
  14. {timeexecution-8.4.1 → timeexecution-8.4.2}/.github/workflows/publish.yml +0 -0
  15. {timeexecution-8.4.1 → timeexecution-8.4.2}/.gitignore +0 -0
  16. {timeexecution-8.4.1 → timeexecution-8.4.2}/CHANGELOG.md +0 -0
  17. {timeexecution-8.4.1 → timeexecution-8.4.2}/LICENSE +0 -0
  18. {timeexecution-8.4.1 → timeexecution-8.4.2}/MANIFEST.in +0 -0
  19. {timeexecution-8.4.1 → timeexecution-8.4.2}/Makefile +0 -0
  20. {timeexecution-8.4.1 → timeexecution-8.4.2}/README.md +0 -0
  21. {timeexecution-8.4.1 → timeexecution-8.4.2}/pyproject.toml +0 -0
  22. {timeexecution-8.4.1 → timeexecution-8.4.2}/setup.cfg +0 -0
  23. {timeexecution-8.4.1 → timeexecution-8.4.2}/setup.py +0 -0
  24. {timeexecution-8.4.1 → timeexecution-8.4.2}/tests/__init__.py +0 -0
  25. {timeexecution-8.4.1 → timeexecution-8.4.2}/tests/conftest.py +0 -0
  26. {timeexecution-8.4.1 → timeexecution-8.4.2}/tests/dummy_process.py +0 -0
  27. {timeexecution-8.4.1 → timeexecution-8.4.2}/tests/test_base_backend.py +0 -0
  28. {timeexecution-8.4.1 → timeexecution-8.4.2}/tests/test_decorator_async.py +0 -0
  29. {timeexecution-8.4.1 → timeexecution-8.4.2}/tests/test_threaded_backend.py +0 -0
  30. {timeexecution-8.4.1 → timeexecution-8.4.2}/time_execution/__init__.py +0 -0
  31. {timeexecution-8.4.1 → timeexecution-8.4.2}/time_execution/backends/__init__.py +0 -0
  32. {timeexecution-8.4.1 → timeexecution-8.4.2}/time_execution/backends/base.py +0 -0
  33. {timeexecution-8.4.1 → timeexecution-8.4.2}/time_execution/backends/threaded.py +0 -0
  34. {timeexecution-8.4.1 → timeexecution-8.4.2}/time_execution/decorator.py +0 -0
  35. {timeexecution-8.4.1 → timeexecution-8.4.2}/time_execution/py.typed +0 -0
  36. {timeexecution-8.4.1 → timeexecution-8.4.2}/time_execution/timed.py +0 -0
  37. {timeexecution-8.4.1 → timeexecution-8.4.2}/timeexecution.egg-info/dependency_links.txt +0 -0
  38. {timeexecution-8.4.1 → timeexecution-8.4.2}/timeexecution.egg-info/not-zip-safe +0 -0
  39. {timeexecution-8.4.1 → timeexecution-8.4.2}/timeexecution.egg-info/requires.txt +0 -0
  40. {timeexecution-8.4.1 → timeexecution-8.4.2}/timeexecution.egg-info/top_level.txt +0 -0
  41. {timeexecution-8.4.1 → timeexecution-8.4.2}/tox.ini +0 -0
@@ -22,7 +22,7 @@ jobs:
22
22
  with:
23
23
  python-version: ${{ matrix.python-version }}
24
24
  - name: Install Tox and other dependencies
25
- run: pip install tox tox-docker wheel twine 'setuptools; python_version >= "3.12"'
25
+ run: pip install tox tox-docker wheel twine 'setuptools; python_version >= "3.12"' 'vcs-versioning; python_version >= "3.12"'
26
26
  - name: Run tests with Tox
27
27
  # Run tox using the version of Python in `PATH`
28
28
  run: tox -e py
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: timeexecution
3
- Version: 8.4.1
3
+ Version: 8.4.2
4
4
  Summary: Python project
5
5
  Home-page: https://github.com/kpn/py-timeexecution
6
6
  Author: KPN DE Platform
@@ -11,7 +11,7 @@ mock
11
11
  isort
12
12
  black
13
13
  flake8
14
- mypy
14
+ mypy<2.0.0
15
15
 
16
16
  # Distribution
17
17
  setuptools; python_version >= "3.12"
@@ -129,6 +129,7 @@ class TestTimeExecution(BaseTestTimeExecutionElasticSearch):
129
129
  "writing metric %r failure %r",
130
130
  {
131
131
  "timestamp": datetime(2016, 7, 13),
132
+ "@timestamp": datetime(2016, 7, 13),
132
133
  "value": None,
133
134
  "name": "test:metric",
134
135
  },
@@ -159,7 +160,11 @@ class TestTimeExecution(BaseTestTimeExecutionElasticSearch):
159
160
  "time_execution.backends.elasticsearch.Elasticsearch.bulk",
160
161
  side_effect=transport_error,
161
162
  )
162
- metrics = [1, 2, 3]
163
+ metrics = [
164
+ {"name": "metric.name", "value": 1, "timestamp": 1},
165
+ {"name": "metric.name", "value": 2, "timestamp": 2},
166
+ {"name": "metric.name", "value": 3, "timestamp": 3},
167
+ ]
163
168
  with es_index_error_ctx:
164
169
  self.backend.bulk_write(metrics)
165
170
  mocked_logger.warning.assert_called_once_with("bulk_write metrics %r failure %r", metrics, transport_error)
@@ -269,7 +269,7 @@ class TestTimeExecution:
269
269
  assert func_args == (42,)
270
270
  assert func_kwargs == {"bar": 100500}
271
271
  assert not is_started, "the decorated function should not run just yet"
272
- (response, _exception, _metrics) = yield
272
+ response, _exception, _metrics = yield
273
273
  assert is_started
274
274
  assert response == "response"
275
275
  return {"key": "value"}
@@ -1,8 +1,8 @@
1
1
  import logging
2
- from datetime import datetime
2
+ from datetime import datetime, timezone
3
3
 
4
4
  from elasticsearch import Elasticsearch
5
- from elasticsearch.exceptions import TransportError
5
+ from elasticsearch.exceptions import BadRequestError, TransportError
6
6
 
7
7
  from time_execution.backends.base import BaseMetricsBackend
8
8
 
@@ -29,7 +29,7 @@ class ElasticsearchBackend(BaseMetricsBackend):
29
29
  self.client = Elasticsearch(hosts=hosts, *args, **kwargs)
30
30
 
31
31
  def get_index(self):
32
- return self.index_pattern.format(index=self.index, date=datetime.now())
32
+ return self.index_pattern.format(index=self.index, date=datetime.now(timezone.utc).replace(tzinfo=None))
33
33
 
34
34
  def write(self, name, **data):
35
35
  """
@@ -41,20 +41,24 @@ class ElasticsearchBackend(BaseMetricsBackend):
41
41
  """
42
42
 
43
43
  data["name"] = name
44
+ now = datetime.now(timezone.utc).replace(tzinfo=None)
44
45
  if not ("timestamp" in data):
45
- data["timestamp"] = datetime.utcnow()
46
+ data["timestamp"] = now
47
+ if not ("@timestamp" in data):
48
+ data["@timestamp"] = now
46
49
 
47
50
  try:
48
51
  index_params = {
49
52
  "index": self.get_index(),
50
53
  "id": None,
51
54
  "body": data,
55
+ "op_type": "create",
52
56
  }
53
57
  if self.pipeline:
54
58
  index_params["pipeline"] = self.pipeline
55
59
 
56
60
  self.client.index(**index_params)
57
- except TransportError as exc:
61
+ except (BadRequestError, TransportError) as exc:
58
62
  logger.warning("writing metric %r failure %r", data, exc)
59
63
 
60
64
  def bulk_write(self, metrics):
@@ -66,8 +70,14 @@ class ElasticsearchBackend(BaseMetricsBackend):
66
70
  """
67
71
  actions = []
68
72
  index = self.get_index()
73
+ now = datetime.now(timezone.utc).replace(tzinfo=None)
69
74
  for metric in metrics:
70
- actions.append({"index": {"_index": index}})
75
+ if not ("timestamp" in metric):
76
+ metric["timestamp"] = now
77
+ if not ("@timestamp" in metric):
78
+ metric["@timestamp"] = now
79
+
80
+ actions.append({"create": {"_index": index}})
71
81
  actions.append(metric)
72
82
 
73
83
  bulk_params = {"operations": actions}
@@ -76,5 +86,5 @@ class ElasticsearchBackend(BaseMetricsBackend):
76
86
 
77
87
  try:
78
88
  self.client.bulk(**bulk_params)
79
- except TransportError as exc:
89
+ except (BadRequestError, TransportError) as exc:
80
90
  logger.warning("bulk_write metrics %r failure %r", metrics, exc)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: timeexecution
3
- Version: 8.4.1
3
+ Version: 8.4.2
4
4
  Summary: Python project
5
5
  Home-page: https://github.com/kpn/py-timeexecution
6
6
  Author: KPN DE Platform
@@ -35,4 +35,6 @@ timeexecution.egg-info/SOURCES.txt
35
35
  timeexecution.egg-info/dependency_links.txt
36
36
  timeexecution.egg-info/not-zip-safe
37
37
  timeexecution.egg-info/requires.txt
38
+ timeexecution.egg-info/scm_file_list.json
39
+ timeexecution.egg-info/scm_version.json
38
40
  timeexecution.egg-info/top_level.txt
@@ -0,0 +1,36 @@
1
+ {
2
+ "files": [
3
+ ".editorconfig",
4
+ ".gitchangelog.rc",
5
+ ".github/workflows/lint.yml",
6
+ ".github/workflows/publish.yml",
7
+ ".github/workflows/tests.yml",
8
+ ".gitignore",
9
+ "CHANGELOG.md",
10
+ "LICENSE",
11
+ "MANIFEST.in",
12
+ "Makefile",
13
+ "README.md",
14
+ "pyproject.toml",
15
+ "requirements.txt",
16
+ "setup.cfg",
17
+ "setup.py",
18
+ "tests/__init__.py",
19
+ "tests/conftest.py",
20
+ "tests/dummy_process.py",
21
+ "tests/test_base_backend.py",
22
+ "tests/test_decorator_async.py",
23
+ "tests/test_elasticsearch.py",
24
+ "tests/test_hooks.py",
25
+ "tests/test_threaded_backend.py",
26
+ "time_execution/__init__.py",
27
+ "time_execution/backends/__init__.py",
28
+ "time_execution/backends/base.py",
29
+ "time_execution/backends/elasticsearch.py",
30
+ "time_execution/backends/threaded.py",
31
+ "time_execution/decorator.py",
32
+ "time_execution/py.typed",
33
+ "time_execution/timed.py",
34
+ "tox.ini"
35
+ ]
36
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "tag": "8.4.2",
3
+ "distance": 0,
4
+ "node": "gcb99c0d72742a413cd6f13f7d3974e9698154fbe",
5
+ "dirty": false,
6
+ "branch": "HEAD",
7
+ "node_date": "2026-09-18"
8
+ }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes