qontract-reconcile 0.10.1rc807__py3-none-any.whl → 0.10.1rc808__py3-none-any.whl
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.
- {qontract_reconcile-0.10.1rc807.dist-info → qontract_reconcile-0.10.1rc808.dist-info}/METADATA +1 -1
- {qontract_reconcile-0.10.1rc807.dist-info → qontract_reconcile-0.10.1rc808.dist-info}/RECORD +7 -7
- tools/saas_metrics_exporter/commit_distance/commit_distance.py +54 -81
- tools/saas_metrics_exporter/commit_distance/metrics.py +2 -9
- {qontract_reconcile-0.10.1rc807.dist-info → qontract_reconcile-0.10.1rc808.dist-info}/WHEEL +0 -0
- {qontract_reconcile-0.10.1rc807.dist-info → qontract_reconcile-0.10.1rc808.dist-info}/entry_points.txt +0 -0
- {qontract_reconcile-0.10.1rc807.dist-info → qontract_reconcile-0.10.1rc808.dist-info}/top_level.txt +0 -0
{qontract_reconcile-0.10.1rc807.dist-info → qontract_reconcile-0.10.1rc808.dist-info}/METADATA
RENAMED
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: qontract-reconcile
|
3
|
-
Version: 0.10.
|
3
|
+
Version: 0.10.1rc808
|
4
4
|
Summary: Collection of tools to reconcile services with their desired state as defined in the app-interface DB.
|
5
5
|
Home-page: https://github.com/app-sre/qontract-reconcile
|
6
6
|
Author: Red Hat App-SRE Team
|
{qontract_reconcile-0.10.1rc807.dist-info → qontract_reconcile-0.10.1rc808.dist-info}/RECORD
RENAMED
@@ -794,8 +794,8 @@ tools/saas_metrics_exporter/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMp
|
|
794
794
|
tools/saas_metrics_exporter/main.py,sha256=piocx6meMdJxoxeNz52gQGUjt5n7Fma4kgqYamszPrM,3180
|
795
795
|
tools/saas_metrics_exporter/commit_distance/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
796
796
|
tools/saas_metrics_exporter/commit_distance/channel.py,sha256=XEAh3eL8TmgMe7V2BsyxuXYWgvBBVdSJETd6Ec7cI04,2171
|
797
|
-
tools/saas_metrics_exporter/commit_distance/commit_distance.py,sha256=
|
798
|
-
tools/saas_metrics_exporter/commit_distance/metrics.py,sha256=
|
797
|
+
tools/saas_metrics_exporter/commit_distance/commit_distance.py,sha256=nyw9N1ESrcxweWfESI-zlldDdSQGLtiuC6x7DXIjtDw,3074
|
798
|
+
tools/saas_metrics_exporter/commit_distance/metrics.py,sha256=5-y6n-sGACAS3eJ5ndY-2BFxcd0fxLfhvZmmBHu4JuA,426
|
799
799
|
tools/sre_checkpoints/__init__.py,sha256=CDaDaywJnmRCLyl_NCcvxi-Zc0hTi_3OdwKiFOyS39I,145
|
800
800
|
tools/sre_checkpoints/util.py,sha256=zEDbGr18ZeHNQwW8pUsr2JRjuXIPz--WAGJxZo9sv_Y,894
|
801
801
|
tools/test/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -804,8 +804,8 @@ tools/test/test_app_interface_metrics_exporter.py,sha256=SX7qL3D1SIRKFo95FoQztvf
|
|
804
804
|
tools/test/test_qontract_cli.py,sha256=_D61RFGAN5x44CY1tYbouhlGXXABwYfxKSWSQx3Jrss,4941
|
805
805
|
tools/test/test_sd_app_sre_alert_report.py,sha256=v363r9zM7__0kR5K6mvJoGFcM9BvE33fWAayrqkpojA,2116
|
806
806
|
tools/test/test_sre_checkpoints.py,sha256=SKqPPTl9ua0RFdSSofnoQX-JZE6dFLO3LRhfQzqtfh8,2607
|
807
|
-
qontract_reconcile-0.10.
|
808
|
-
qontract_reconcile-0.10.
|
809
|
-
qontract_reconcile-0.10.
|
810
|
-
qontract_reconcile-0.10.
|
811
|
-
qontract_reconcile-0.10.
|
807
|
+
qontract_reconcile-0.10.1rc808.dist-info/METADATA,sha256=avC3f2n3tg5yBABcDSjLjyLvPd7Axtxg7AYNThYdak4,2314
|
808
|
+
qontract_reconcile-0.10.1rc808.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
809
|
+
qontract_reconcile-0.10.1rc808.dist-info/entry_points.txt,sha256=GKQqCl2j2X1BJQ69een6rHcR26PmnxnONLNOQB-nRjY,491
|
810
|
+
qontract_reconcile-0.10.1rc808.dist-info/top_level.txt,sha256=l5ISPoXzt0SdR4jVdkfa7RPSKNc8zAHYWAnR-Dw8Ey8,24
|
811
|
+
qontract_reconcile-0.10.1rc808.dist-info/RECORD,,
|
@@ -7,124 +7,97 @@ from reconcile.typed_queries.saas_files import SaasFile
|
|
7
7
|
from reconcile.utils.secret_reader import HasSecret
|
8
8
|
from reconcile.utils.vcs import VCS
|
9
9
|
from tools.saas_metrics_exporter.commit_distance.channel import (
|
10
|
-
Channel,
|
11
10
|
SaasTarget,
|
12
11
|
build_channels,
|
13
12
|
)
|
14
13
|
from tools.saas_metrics_exporter.commit_distance.metrics import SaasCommitDistanceGauge
|
15
14
|
|
16
15
|
|
17
|
-
@dataclass
|
18
|
-
class Distance:
|
19
|
-
publisher: SaasTarget
|
20
|
-
subscriber: SaasTarget
|
21
|
-
channel: Channel
|
22
|
-
distance: int = 0
|
23
|
-
|
24
|
-
|
25
16
|
@dataclass
|
26
17
|
class CommitDistanceMetric:
|
27
18
|
value: float
|
28
19
|
metric: SaasCommitDistanceGauge
|
29
20
|
|
30
21
|
|
31
|
-
@dataclass
|
32
|
-
class
|
22
|
+
@dataclass(frozen=True)
|
23
|
+
class DistanceKey:
|
33
24
|
repo_url: str
|
34
25
|
auth_code: HasSecret | None
|
35
26
|
ref_from: str
|
36
27
|
ref_to: str
|
37
|
-
distance: int = 0
|
38
|
-
|
39
|
-
def __hash__(self) -> int:
|
40
|
-
return hash((self.repo_url, self.ref_from, self.ref_to))
|
41
28
|
|
42
29
|
|
43
30
|
class CommitDistanceFetcher:
|
44
31
|
def __init__(self, vcs: VCS):
|
45
32
|
self._vcs = vcs
|
46
33
|
|
47
|
-
def
|
48
|
-
|
49
|
-
|
50
|
-
def _calculate_commit_distance(self, data: ThreadData) -> None:
|
51
|
-
if data.ref_from == data.ref_to:
|
52
|
-
data.distance = 0
|
53
|
-
return
|
34
|
+
def _calculate_commit_distance(self, key: DistanceKey) -> tuple[DistanceKey, int]:
|
35
|
+
if key.ref_from == key.ref_to:
|
36
|
+
return key, 0
|
54
37
|
|
55
38
|
commits = self._vcs.get_commits_between(
|
56
|
-
repo_url=
|
57
|
-
auth_code=
|
58
|
-
commit_from=
|
59
|
-
commit_to=
|
39
|
+
repo_url=key.repo_url,
|
40
|
+
auth_code=key.auth_code,
|
41
|
+
commit_from=key.ref_from,
|
42
|
+
commit_to=key.ref_to,
|
43
|
+
)
|
44
|
+
return key, len(commits)
|
45
|
+
|
46
|
+
@staticmethod
|
47
|
+
def _build_distance_key(
|
48
|
+
publisher: SaasTarget, subscriber: SaasTarget
|
49
|
+
) -> DistanceKey:
|
50
|
+
return DistanceKey(
|
51
|
+
repo_url=publisher.repo_url,
|
52
|
+
auth_code=publisher.auth_code,
|
53
|
+
ref_from=subscriber.ref,
|
54
|
+
ref_to=publisher.ref,
|
60
55
|
)
|
61
|
-
data.distance = len(commits)
|
62
|
-
|
63
|
-
def _populate_distances(
|
64
|
-
self, distances: Iterable[Distance], thread_data: Iterable[ThreadData]
|
65
|
-
) -> None:
|
66
|
-
m = {
|
67
|
-
self._data_key(
|
68
|
-
repo_url=d.repo_url, ref_from=d.ref_from, ref_to=d.ref_to
|
69
|
-
): d.distance
|
70
|
-
for d in thread_data
|
71
|
-
}
|
72
|
-
for distance in distances:
|
73
|
-
distance.distance = m[
|
74
|
-
self._data_key(
|
75
|
-
repo_url=distance.publisher.repo_url,
|
76
|
-
ref_from=distance.subscriber.ref,
|
77
|
-
ref_to=distance.publisher.ref,
|
78
|
-
)
|
79
|
-
]
|
80
56
|
|
81
57
|
def fetch(
|
82
|
-
self,
|
58
|
+
self,
|
59
|
+
saas_files: Iterable[SaasFile],
|
60
|
+
thread_pool_size: int,
|
83
61
|
) -> list[CommitDistanceMetric]:
|
84
62
|
channels = build_channels(saas_files=saas_files)
|
85
|
-
distances: list[Distance] = []
|
86
|
-
thread_data: set[ThreadData] = set()
|
87
|
-
|
88
|
-
for channel in channels:
|
89
|
-
for subscriber in channel.subscribers:
|
90
|
-
for publisher in channel.publishers:
|
91
|
-
thread_data.add(
|
92
|
-
ThreadData(
|
93
|
-
repo_url=publisher.repo_url,
|
94
|
-
auth_code=publisher.auth_code,
|
95
|
-
ref_from=subscriber.ref,
|
96
|
-
ref_to=publisher.ref,
|
97
|
-
)
|
98
|
-
)
|
99
|
-
distances.append(
|
100
|
-
Distance(
|
101
|
-
publisher=publisher,
|
102
|
-
subscriber=subscriber,
|
103
|
-
channel=channel,
|
104
|
-
)
|
105
|
-
)
|
106
63
|
|
107
|
-
|
108
|
-
self.
|
109
|
-
|
110
|
-
|
111
|
-
|
64
|
+
distance_keys = {
|
65
|
+
self._build_distance_key(publisher=publisher, subscriber=subscriber)
|
66
|
+
for channel in channels
|
67
|
+
for subscriber in channel.subscribers
|
68
|
+
for publisher in channel.publishers
|
69
|
+
}
|
112
70
|
|
113
|
-
|
71
|
+
distance_by_key = dict(
|
72
|
+
threaded.run(
|
73
|
+
self._calculate_commit_distance,
|
74
|
+
distance_keys,
|
75
|
+
thread_pool_size=thread_pool_size,
|
76
|
+
)
|
77
|
+
)
|
114
78
|
|
115
79
|
commit_distance_metrics = [
|
116
80
|
CommitDistanceMetric(
|
117
|
-
value=float(
|
81
|
+
value=float(
|
82
|
+
distance_by_key[
|
83
|
+
self._build_distance_key(
|
84
|
+
publisher=publisher,
|
85
|
+
subscriber=subscriber,
|
86
|
+
)
|
87
|
+
]
|
88
|
+
),
|
118
89
|
metric=SaasCommitDistanceGauge(
|
119
|
-
channel=
|
120
|
-
app=
|
121
|
-
publisher=
|
122
|
-
publisher_namespace=
|
123
|
-
subscriber=
|
124
|
-
subscriber_namespace=
|
90
|
+
channel=channel.name,
|
91
|
+
app=publisher.app_name,
|
92
|
+
publisher=publisher.target_name,
|
93
|
+
publisher_namespace=publisher.namespace_name,
|
94
|
+
subscriber=subscriber.target_name,
|
95
|
+
subscriber_namespace=subscriber.namespace_name,
|
125
96
|
),
|
126
97
|
)
|
127
|
-
for
|
98
|
+
for channel in channels
|
99
|
+
for subscriber in channel.subscribers
|
100
|
+
for publisher in channel.publishers
|
128
101
|
]
|
129
102
|
|
130
103
|
return commit_distance_metrics
|
@@ -1,19 +1,12 @@
|
|
1
|
-
from pydantic import BaseModel
|
2
|
-
|
3
1
|
from reconcile.utils.metrics import (
|
4
2
|
GaugeMetric,
|
5
3
|
)
|
6
4
|
|
7
5
|
|
8
|
-
class
|
9
|
-
"Base class for Saas metrics"
|
10
|
-
|
11
|
-
integration: str = "saas_metrics_exporter"
|
12
|
-
|
13
|
-
|
14
|
-
class SaasCommitDistanceGauge(SaasBaseMetric, GaugeMetric):
|
6
|
+
class SaasCommitDistanceGauge(GaugeMetric):
|
15
7
|
"Gauge for the commit distance between saas targets in a channel"
|
16
8
|
|
9
|
+
integration: str = "saas_metrics_exporter"
|
17
10
|
channel: str
|
18
11
|
publisher: str
|
19
12
|
publisher_namespace: str
|
File without changes
|
File without changes
|
{qontract_reconcile-0.10.1rc807.dist-info → qontract_reconcile-0.10.1rc808.dist-info}/top_level.txt
RENAMED
File without changes
|