Skip to content

refactor: Abstracted registering of new aggregators into a Harvester class that is responsible for starting, stopping, updating all registered aggregators. #1994

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

Merged
merged 2 commits into from
Feb 8, 2024

Conversation

bizob2828
Copy link
Member

Description

Sorry for the large PR 😬. This PR removes all the places that are necessary to add certain calls when adding a new aggregator. This introduces a harvester class that is responsible for tracking all aggregators. Then depending on stages in the agent it will start, stop, update, and clear the aggregators. To do that I had to update the signature of every aggregator to pass in the harvester instance because registering of an aggregator is done at the construction via harvest.add. Also I added an evaluator config to determine when an aggregator is enabled based on relevant configuration. Previously this was done in startAggregators and was easy to miss when adding a new aggregator.

This achieves 1 part of the making it easier to add a new aggregator for the future. I deferred having a common agent method for enqueuing events to another story. The idea behind that is instead of calling the aggregators directly we will have a generic agent.addEvent method that takes id and event and priority. So right now it's

agent.customEventAggregator.add([{ type, timestamp }, event])

It'd be

agent.addEvent(CUSTOM_EVENT, [{ type, timestamp}, event])

This functionality will come next. Then we can add the LLM aggregator with its relevant config(still being discussed what the values for config are).

Lastly, I added some missing coverage or made more direct tests around behaviors as it was very difficult to see where things were being tested.

How to Test

Related Issues

Closes #1981

class that is responsible for starting, stopping, updating all
registered aggregators.
Copy link

codecov bot commented Feb 1, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (5eae6ee) 97.04% compared to head (5fc10a3) 97.05%.
Report is 7 commits behind head on main.

❗ Current head 5fc10a3 differs from pull request most recent head 15ade23. Consider uploading reports for the commit 15ade23 to get more accurate results

Additional details and impacted files
@@           Coverage Diff            @@
##             main    #1994    +/-   ##
========================================
  Coverage   97.04%   97.05%            
========================================
  Files         218      219     +1     
  Lines       40493    40129   -364     
========================================
- Hits        39297    38946   -351     
+ Misses       1196     1183    -13     
Flag Coverage Δ
integration-tests-16.x 78.89% <94.88%> (-0.05%) ⬇️
integration-tests-18.x 79.17% <94.88%> (-0.02%) ⬇️
integration-tests-20.x 79.18% <94.88%> (-0.02%) ⬇️
unit-tests-16.x 91.08% <99.53%> (-0.08%) ⬇️
unit-tests-18.x 91.06% <99.53%> (-0.08%) ⬇️
unit-tests-20.x 91.06% <99.53%> (-0.08%) ⬇️
versioned-tests-16.x 74.59% <63.25%> (+0.46%) ⬆️
versioned-tests-18.x 74.61% <63.25%> (+0.46%) ⬆️
versioned-tests-20.x 74.62% <63.25%> (+0.46%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

jsumners-nr
jsumners-nr previously approved these changes Feb 1, 2024
Copy link
Contributor

@jsumners-nr jsumners-nr left a comment

Choose a reason for hiding this comment

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

I haven't gone over every line since it's mostly just massaging things into the new signatures. I have one piece of feedback, but overall 👍

Comment on lines 89 to 102
this._methods[name] = method
}
}

CollectorAPI.prototype.send = function send(method, data, callback) {
if (!callback) {
this._throwCallbackError()
}
if (!data) {
callback(new TypeError(`must pass data for ${method} to send`))
return
}

this._sendData(this._methods[method], data, callback)
Copy link
Contributor

Choose a reason for hiding this comment

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

For other people reviewing this: the changes in lines 73-86 are tied to this._methods. This PR is simplifying that mapping.

@bizob2828 bizob2828 merged commit 1fb85a6 into newrelic:main Feb 8, 2024
@bizob2828 bizob2828 deleted the generic-event-send branch August 28, 2024 18:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Provide ability to send common events
2 participants