-
Notifications
You must be signed in to change notification settings - Fork 27
Fix Graphite Tag integration #131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -57,7 +57,6 @@ class TimeSeries: | |
|
|
||
|
|
||
| def decode_graphite_datapoints(series: Dict[str, List[List[float]]]) -> List[DataPoint]: | ||
|
|
||
| points = series["datapoints"] | ||
| return [DataPoint(int(p[1]), p[0]) for p in points if p[0] is not None] | ||
|
|
||
|
|
@@ -80,49 +79,28 @@ class GraphiteError(IOError): | |
|
|
||
| @dataclass | ||
| class GraphiteEvent: | ||
| test_owner: str | ||
| test_name: str | ||
| run_id: str | ||
| status: str | ||
| start_time: datetime | ||
| pub_time: datetime | ||
| end_time: datetime | ||
| version: Optional[str] | ||
| branch: Optional[str] | ||
| commit: Optional[str] | ||
|
|
||
| def __init__( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| self, | ||
| pub_time: int, | ||
| test_owner: str, | ||
| test_name: str, | ||
| run_id: str, | ||
| status: str, | ||
| start_time: int, | ||
| end_time: int, | ||
| version: Optional[str], | ||
| branch: Optional[str], | ||
| commit: Optional[str], | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. idea (maybe outside of scope of this PR): today, if we have other event tags like |
||
| ): | ||
| self.test_owner = test_owner | ||
| self.test_name = test_name | ||
| self.run_id = run_id | ||
| self.status = status | ||
| self.start_time = parse_datetime(str(start_time)) | ||
| self.pub_time = parse_datetime(str(pub_time)) | ||
| self.end_time = parse_datetime(str(end_time)) | ||
| if len(version) == 0 or version == "null": | ||
| self.version = None | ||
| else: | ||
| self.version = version | ||
| if len(branch) == 0 or branch == "null": | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This logic was lost in this PR. If a string text is empty or equal to "null", we still want to treat it as empty, unless there is a reason not to. |
||
| self.branch = None | ||
| else: | ||
| self.branch = branch | ||
| if len(commit) == 0 or commit == "null": | ||
| self.commit = None | ||
| else: | ||
| self.commit = commit | ||
| test_owner: Optional[str] = None | ||
| test_name: Optional[str] = None | ||
| run_id: Optional[str] = None | ||
| status: Optional[str] = None | ||
| start_time: Optional[datetime] = None | ||
| end_time: Optional[datetime] = None | ||
| version: Optional[str] = None | ||
| branch: Optional[str] = None | ||
| commit: Optional[str] = None | ||
|
|
||
|
|
||
| def __post_init__(self): | ||
| if self.pub_time is None: | ||
| raise ValueError("pub_time is required and cannot be None") | ||
| # Ensure pub_time is always a datetime | ||
|
|
||
| # Only parse if it isn't already a datetime object | ||
| if isinstance(self.pub_time, str): | ||
| self.pub_time = parse_datetime(self.pub_time) | ||
| elif isinstance(self.pub_time, (int, float)): | ||
| self.pub_time = datetime.fromtimestamp(self.pub_time) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change uses a different parsing logic than Why do need these extra manipulations with |
||
|
|
||
|
|
||
| def compress_target_paths(paths: List[str]) -> List[str]: | ||
|
|
@@ -160,10 +138,10 @@ def __init__(self, conf: GraphiteConfig): | |
| self.__url_limit = 4094 | ||
|
|
||
| def fetch_events( | ||
| self, | ||
| tags: Iterable[str], | ||
| from_time: Optional[datetime] = None, | ||
| until_time: Optional[datetime] = None, | ||
| self, | ||
| tags: Iterable[str], | ||
| from_time: Optional[datetime] = None, | ||
| until_time: Optional[datetime] = None, | ||
| ) -> List[GraphiteEvent]: | ||
| """ | ||
| Returns 'Performance Test' events that match all of | ||
|
|
@@ -190,7 +168,7 @@ def fetch_events( | |
| data_str = urllib.request.urlopen(url).read() | ||
| data_as_json = json.loads(data_str) | ||
| return [ | ||
| GraphiteEvent(event.get("when"), **ast.literal_eval(event.get("data"))) | ||
| GraphiteEvent(pub_time=event.get("when"), **ast.literal_eval(event.get("data"))) | ||
| for event in data_as_json | ||
| if event.get("what") == "Performance Test" | ||
| ] | ||
|
|
@@ -199,7 +177,7 @@ def fetch_events( | |
| raise GraphiteError(f"Failed to fetch Graphite events: {str(e)}") | ||
|
|
||
| def fetch_events_with_matching_time_option( | ||
| self, tags: Iterable[str], commit: Optional[str], version: Optional[str] | ||
| self, tags: Iterable[str], commit: Optional[str], version: Optional[str] | ||
| ) -> List[GraphiteEvent]: | ||
| events = [] | ||
| if commit is not None: | ||
|
|
||


There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It may not be clear what is the
datadictionary in this case. In the paragraph above, we talk abouttags, so I suggest replacing this statement withThe following tags are supported: