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

refactor: stats package #2489

Merged
merged 2 commits into from Sep 29, 2022
Merged

refactor: stats package #2489

merged 2 commits into from Sep 29, 2022

Conversation

atzoum
Copy link
Contributor

@atzoum atzoum commented Sep 27, 2022

Description

Refactoring the stats package and introducing the following improvements:

  1. Thread-safe initialization of stats.Stats instances (including the default, singleton instance). No more global variables.
  2. Using Stats.Start & Stats.Stop for controlling the component's lifecycle. During tests, the default stats instance is initialised, but not started.
  3. Proper handling of muted measurements, i.e. Measurement (fka RudderStats) instances created before the Stats instance was able to successfully create a statsd client remained muted in the previous implementation. A special test case verifies the correct behaviour (see stats_internal_test.go).
  4. Test coverage is now >90%.

Notion Ticket

Link

Security

  • The code changed/added as part of this pull request won't create any security issues with how the software is being used.

@codecov
Copy link

codecov bot commented Sep 27, 2022

Codecov Report

Base: 40.54% // Head: 41.36% // Increases project coverage by +0.82% 🎉

Coverage data is based on head (06dd4e8) compared to base (7ae6421).
Patch coverage: 66.00% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2489      +/-   ##
==========================================
+ Coverage   40.54%   41.36%   +0.82%     
==========================================
  Files         174      175       +1     
  Lines       36237    36266      +29     
==========================================
+ Hits        14691    15003     +312     
+ Misses      20627    20326     -301     
- Partials      919      937      +18     
Impacted Files Coverage Δ
config/backend-config/admin.go 0.00% <0.00%> (ø)
enterprise/reporting/noop.go 0.00% <0.00%> (ø)
enterprise/reporting/reporting.go 8.33% <0.00%> (ø)
gateway/admin.go 0.00% <0.00%> (ø)
middleware/middleware.go 40.00% <0.00%> (ø)
processor/trackingplan.go 53.38% <ø> (ø)
router/destinationReponseHandler.go 74.39% <0.00%> (ø)
router/failed-events-manager.go 0.00% <0.00%> (ø)
services/filemanager/gcsmanager.go 30.24% <0.00%> (ø)
services/metric/measurement.go 0.00% <0.00%> (ø)
... and 48 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@atzoum atzoum force-pushed the refactor.stats branch 3 times, most recently from ddc8e4f to c036621 Compare September 27, 2022 13:20
services/stats/misc.go Outdated Show resolved Hide resolved
@atzoum atzoum force-pushed the refactor.stats branch 3 times, most recently from d697f80 to da1426f Compare September 28, 2022 12:23
@atzoum atzoum changed the title [WIP] refactor: stats package refactor: stats package Sep 28, 2022
@atzoum atzoum marked this pull request as ready for review September 28, 2022 13:34
Copy link
Member

@lvrach lvrach left a comment

Choose a reason for hiding this comment

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

Amazing work on the tests, approved with some minor comments

services/stats/config.go Outdated Show resolved Hide resolved
services/stats/misc.go Outdated Show resolved Hide resolved
services/stats/stats_internal_test.go Show resolved Hide resolved
main.go Show resolved Hide resolved
services/stats/stats.go Outdated Show resolved Hide resolved
@atzoum atzoum merged commit c36b303 into master Sep 29, 2022
@atzoum atzoum deleted the refactor.stats branch September 29, 2022 15:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants