Skip to content

Commit

Permalink
Fix: Fix issues around incorrect tags not being sent to Grafana + Add…
Browse files Browse the repository at this point in the history
… ruff format to repo (#42)
  • Loading branch information
jmfiola authored Jun 18, 2024
1 parent cdaf03f commit 1411e96
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 16 deletions.
1 change: 1 addition & 0 deletions .github/workflows/quality-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ jobs:
python-version: "3.10"
- run: pip install -e ".[dev]"
- run: ruff check .
- run: ruff format --check .
unit-test:
if: "!contains(github.event.head_commit.message, '[ci skip]')"
needs: [ruff-lint]
Expand Down
3 changes: 0 additions & 3 deletions src/grasshopper/lib/journeys/base_journey.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,6 @@ def merge_incoming_scenario_args(cls, lower_precedence_args):
def update_tags(self, new_tags: dict):
"""Update the tags for the influxdb listener."""
self.tags.update(new_tags)
db_listener = self.environment.grasshopper_listeners.influxdb_listener
if db_listener is not None:
db_listener.additional_tags.update(new_tags)

@classmethod
def reset_class_attributes(cls):
Expand Down
14 changes: 1 addition & 13 deletions src/grasshopper/lib/util/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,8 @@ def custom_trend(trend_name: str, extra_tag_keys=[]):

def calc_time_delta_and_report_metric(func):
def wrapper(journey_object, *args, **kwargs):
tags = {}
try:
environment = journey_object.environment
host = environment.host
test_parameters = journey_object.scenario_args
if hasattr(journey_object.environment, "extra_context"):
tags.update(journey_object.environment.extra_context)
except AttributeError:
raise ReferenceError(
"The custom_trend decorator must be placed on a journey function "
Expand All @@ -37,20 +32,13 @@ def wrapper(journey_object, *args, **kwargs):
result = func(journey_object, *args, **kwargs)
end_time = datetime.now()
time_delta = end_time - start_time
tags.update(
{
extra_tag_key: test_parameters.get(extra_tag_key)
for extra_tag_key in extra_tag_keys
}
)
tags["environment"] = host
environment.events.request.fire(
request_type="CUSTOM",
name=trend_name,
response_time=round(time_delta.total_seconds() * 1000, 3),
response_length=0,
response=None,
context=tags,
context=journey_object.tags,
exception=None,
)
return result
Expand Down

0 comments on commit 1411e96

Please sign in to comment.