-
Notifications
You must be signed in to change notification settings - Fork 5
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
agents: add metrics transform API to agent #123
Merged
trevnorris
merged 3 commits into
node-v20.x-nsolid-v5.x
from
trevnorris/transform-statsd
May 29, 2024
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#include <node.h> | ||
#include <v8.h> | ||
#include <uv.h> | ||
#include <nsolid.h> | ||
|
||
#include <assert.h> | ||
#include <atomic> | ||
|
||
using v8::FunctionCallbackInfo; | ||
using v8::Value; | ||
|
||
void CheckEnvCount(const FunctionCallbackInfo<Value>& args) { | ||
int len = 0; | ||
node::nsolid::GetAllEnvInst([&len](node::nsolid::SharedEnvInst) { | ||
len++; | ||
}); | ||
args.GetReturnValue().Set(len); | ||
} | ||
|
||
|
||
NODE_MODULE_INIT(/* exports, module, context */) { | ||
NODE_SET_METHOD(exports, "checkEnvCount", CheckEnvCount); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
'targets': [{ | ||
'target_name': 'binding', | ||
'sources': [ 'binding.cc' ], | ||
'includes': ['../common.gypi'], | ||
'target_defaults': { | ||
'default_configuration': 'Release', | ||
'configurations': { | ||
'Debug': { | ||
'defines': [ 'DEBUG', '_DEBUG' ], | ||
'cflags': [ '-g', '-O0', '-fstandalone-debug' ], | ||
} | ||
}, | ||
}, | ||
}], | ||
} |
35 changes: 35 additions & 0 deletions
35
test/addons/nsolid-get-all-envinst/nsolid-get-all-envinst.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
'use strict'; | ||
|
||
const { buildType, mustCall, skip } = require('../../common'); | ||
const assert = require('assert'); | ||
const bindingPath = require.resolve(`./build/${buildType}/binding`); | ||
const binding = require(bindingPath); | ||
const { Worker, isMainThread, parentPort } = require('worker_threads'); | ||
const workerList = []; | ||
|
||
if (process.env.NSOLID_COMMAND) | ||
skip('required to run without the Console'); | ||
|
||
if (!isMainThread && +process.argv[2] !== process.pid) | ||
skip('Test must first run as the main thread'); | ||
|
||
if (isMainThread) { | ||
spawnWorker(); | ||
} else { | ||
parentPort.on('message', () => process.exit()); | ||
} | ||
|
||
function spawnWorker() { | ||
if (workerList.length > 4) { | ||
for (let w of workerList) | ||
w.postMessage('bye'); | ||
return; | ||
} | ||
const w = new Worker(__filename, { argv: [process.pid] }); | ||
w.on('online', () => { | ||
// Add 1 for the main thread. | ||
assert.strictEqual(binding.checkEnvCount(), workerList.length + 1); | ||
spawnWorker(); | ||
}); | ||
workerList.push(w); | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This is because of the test right? Why aren't you adding the ThreadAdded/RemovedHook methods inside that conditional as well?
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.
Mostly because I am being lazy. There are two main assumptions:
StatsDAgent
instance will be used for the entire process lifetimeStatsDAgent
instances will ever be created.Using these assumptions, I decided it would be easier for each
StatsDAgent
instance to set up its own hooks to check when a new thread is created/destroyed rather than have a single global hook that would iterate through a list ofStatsDAgent
instances when a thread is created/destroyed. This simplified the logic a lot and will be easy to fix if we ever add the ability to remove a hook.Though, now that I type this up I realize that all the stuff I added for the
agent_list_
can be removed. Since it was never used. Will make that change.