Skip to content
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

[jormungandr] NewRelic added for stat_manager #4127

Merged
merged 7 commits into from
Oct 5, 2023
Merged

[jormungandr] NewRelic added for stat_manager #4127

merged 7 commits into from
Oct 5, 2023

Conversation

azime
Copy link
Contributor

@azime azime commented Oct 4, 2023

Jira: NAV-2346

@azime azime requested review from kadhikari, xlqian and pbench October 4, 2023 14:25
@pbougue pbougue changed the title NewRelic added for stat_manager [jormungandr] NewRelic added for stat_manager Oct 5, 2023
Comment on lines 212 to 222
result = func(obj, *args, **kwargs)
except Exception as e:
event_params["status"] = "failed"
event_params.update({"reason": str(e)})
duration = timeit.default_timer() - start_time
event_params.update({"duration": duration})

# Send the custom event to newrelic !
record_custom_event("stat_manager", event_params)

return result
Copy link
Contributor

@pbougue pbougue Oct 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 remarks :

  1. Maybe you should also re-raise in the except, not sure.
  2. More idiomatic:
Suggested change
result = func(obj, *args, **kwargs)
except Exception as e:
event_params["status"] = "failed"
event_params.update({"reason": str(e)})
duration = timeit.default_timer() - start_time
event_params.update({"duration": duration})
# Send the custom event to newrelic !
record_custom_event("stat_manager", event_params)
return result
return func(obj, *args, **kwargs)
except Exception as e:
event_params["status"] = "failed"
event_params.update({"reason": str(e)})
finally:
duration = timeit.default_timer() - start_time
event_params.update({"duration": duration})
# Send the custom event to newrelic !
record_custom_event("stat_manager", event_params)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@sonarqubecloud
Copy link

sonarqubecloud bot commented Oct 5, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

94.6% 94.6% Coverage
0.0% 0.0% Duplication

@pbougue pbougue merged commit 6da0a5c into dev Oct 5, 2023
@pbougue pbougue deleted the nr_stat_manager branch October 5, 2023 16:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants