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

Add Job Executor #100

Merged
merged 33 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
9186c5c
add job executor
leonardoventurini Aug 14, 2023
a118024
Merge branch 'master' into feature/jobs
zodern Mar 12, 2024
4ad8d91
Simplify and improve reliability of jobs
zodern Mar 13, 2024
37a3368
Add logging for jobs
zodern Mar 14, 2024
f272a42
Connect websockets when supported
zodern Mar 14, 2024
840da38
Update monti-apm-core
zodern Mar 14, 2024
c8db348
Add heap snapshot job
zodern Mar 20, 2024
9af449b
Update monti-apm-core
zodern Mar 20, 2024
68cbdc8
Update monti-apm-core
zodern Mar 20, 2024
d556369
Add debug logging for if websockets supported
zodern Mar 21, 2024
b8a5ecd
Drop support for Meteor 1.4 and 1.5
zodern Mar 21, 2024
062aabf
Update monti-apm-core
zodern Mar 21, 2024
be36f91
Revert "Drop support for Meteor 1.4 and 1.5"
zodern Apr 9, 2024
3c540e7
Update zodern:types
zodern Apr 9, 2024
f885378
Disable websockets on Node 4
zodern Apr 26, 2024
169c042
Merge branch 'master' into feature/jobs
zodern May 14, 2024
32ac55f
Merge branch 'master' into feature/jobs
zodern Jul 11, 2024
8be460b
v2.50.0-beta.1
zodern Jul 11, 2024
1259024
Use _remoteCpuProfile directly
zodern Jul 11, 2024
f6050fa
v2.50.0-beta.2
zodern Jul 11, 2024
8f59bbd
Add comment for why Node 4 is not supported
zodern Nov 22, 2024
fd2654a
Re-add .npm/package
zodern Nov 22, 2024
2b9712b
Update monti-apm-core to 1.8
zodern Nov 22, 2024
85b86d1
Merge branch 'master' into feature/jobs
zodern Nov 22, 2024
434a6b5
Fix lint error
zodern Nov 22, 2024
5900db2
Handle disableInstrumentation like other options
zodern Nov 22, 2024
37e36f2
Improve disableInstrumentation docs
zodern Nov 22, 2024
3060e2c
Update test workflow
zodern Nov 22, 2024
d836522
Fix installing Meteor in CI
zodern Nov 22, 2024
d198b0d
Reduce Meteor releases used in redis oplog tests
zodern Nov 22, 2024
b952b4a
Use newer 2.13 release in test
zodern Nov 22, 2024
82e8864
Make callback to _startInstrumenting optional
zodern Nov 22, 2024
cbbcc25
Require passing parsed env to _connectWithEnv
zodern Nov 22, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 1 addition & 12 deletions .github/workflows/test-redis-oplog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,7 @@ jobs:
matrix:
meteorRelease:
- '--release 1.11'
- '--release 1.12.1'
- '--release 2.1.1'
- '--release 2.2'
- '--release 2.3.2'
- '--release 2.4.1'
- '--release 2.5.6'
- '--release 2.6.1'
- '--release 2.7.3'
- '--release 2.8.2'
- '--release 2.9.0'
# Left empty to use latest version
-
- '--release 2.16'
env:
REDIS_OPLOG_SETTINGS: '{"debug":true}'
steps:
Expand Down
11 changes: 8 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,21 @@ jobs:
- '--release 2.7.3'
- '--release 2.8.2'
- '--release 2.9.0'
# Left empty to use latest version
-
- '--release 2.10.0'
- '--release 2.11.0'
- '--release 2.12'
- '--release 2.13.3'
- '--release 2.14'
- '--release 2.15'
- '--release 2.16'
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Install Node.js
uses: actions/setup-node@v1
with:
node-version: '12.x'
node-version: '22.x'

- name: Install Dependencies
run: |
Expand Down
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
.build*
node_modules/
.npm
.npm/.package-garbage-*
smart.lock
versions.json
.idea
.eslintcache
.envrc
/packages/*
/packages/*
1 change: 1 addition & 0 deletions .npm/package/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
7 changes: 7 additions & 0 deletions .npm/package/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
This directory and the files immediately inside it are automatically generated
when you change this package's NPM dependencies. Commit the files in this
directory (npm-shrinkwrap.json, .gitignore, and this README) to source control
so that others run the same versions of sub-dependencies.

You should NOT check in the node_modules directory that Meteor automatically
creates; if you are using git, the .gitignore file tells git to ignore it.
198 changes: 198 additions & 0 deletions .npm/package/npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ You should use the same method that you used to give the agent the app id and se
| eventStackTrace | EVENT_STACK_TRACE | false | If true, records a stack trace when an event starts. Slightly decreases server performance. |
| disableNtp | OPTIONS_DISABLE_NTP | false | Disable NTP time synchronization used to get the accurate time in case the server or client's clock is wrong |
| stalledTimeout | STALLED_TIMEOUT | 1800000 (30m) | Timeout used to detect when methods and subscriptions might be stalled (have been running for a long time and might never return). The value is in milliseconds, and can be disabled by setting it to 0 |
| proxy | MONTI_OPTIONS_PROXY | none | Allows you to connect to Monti APM using a proxy |
| disableInstrumentation | MONTI_DISABLE_INSTRUMENTATION | false | Disables instrumentation. Useful for disabling without uninstalling the package |
| proxy | OPTIONS_PROXY | none | Allows you to connect to Monti APM using a proxy |
| disableInstrumentation | DISABLE_INSTRUMENTATION | false | Disables recording most metrics and traces. Can be configured using Meteor.settings, or by env variable |


### Traces
Expand Down
53 changes: 29 additions & 24 deletions lib/auto_connect.js
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
import { Meteor } from 'meteor/meteor';

Kadira._connectWithEnv = function () {
const options = Kadira._parseEnv(process.env);
if (options.appId && options.appSecret) {
const envOptions = Kadira._parseEnv(process.env);
const montiSettings = Meteor.settings.monti || Meteor.settings.kadira;

Kadira._connectWithEnv = function (env) {
if (env.appId && env.appSecret) {
Kadira.connect(
options.appId,
options.appSecret,
options
env.appId,
env.appSecret,
env
);

Kadira.connect = function () {
throw new Error('Kadira has been already connected using credentials from Environment Variables');
throw new Error('Monti APM: already connected using credentials from Environment Variables');
};
}
};


Kadira._connectWithSettings = function () {
const montiSettings = Meteor.settings.monti || Meteor.settings.kadira;

Kadira._connectWithSettings = function (settings) {
if (
montiSettings &&
montiSettings.appId &&
montiSettings.appSecret
settings &&
settings.appId &&
settings.appSecret
) {
Kadira.connect(
montiSettings.appId,
montiSettings.appSecret,
montiSettings.options || {}
settings.appId,
settings.appSecret,
settings.options || {}
);

Kadira.connect = function () {
throw new Error('Kadira has been already connected using credentials from Meteor.settings');
throw new Error('Monti APM: already connected using credentials from Meteor.settings');
};
}
};
Expand All @@ -40,11 +40,16 @@ Kadira._connectWithSettings = function () {
* We need to instrument this right away, and it's okay
* One reason for this is to call `setLabels()` function
* Otherwise, CPU profile can't see all our custom labeling
*
* Previously there was two log messages (one for instrumentation,
* and another for connection), this way we merged both of them.
*/
Kadira._startInstrumenting(function () {
Kadira._connectWithEnv();
Kadira._connectWithSettings();
});
let settingsOptions = montiSettings && montiSettings.options || {};
if (
envOptions.disableInstrumentation || settingsOptions.disableInstrumentation
) {
// eslint-disable-next-line no-console
console.log('Monti APM: Instrumentation is disabled. Metrics and traces will not be recorded.');
} else {
Kadira._startInstrumenting();
}

Kadira._connectWithEnv(envOptions);
Kadira._connectWithSettings(settingsOptions);
5 changes: 5 additions & 0 deletions lib/constants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export const JobType = {
CPU_PROFILE: 'cpuProfile',
HEAP_SNAPSHOT: 'heapSnapshot',
ALLOCATION_PROFILE: 'allocationProfile'
};
4 changes: 4 additions & 0 deletions lib/environment_variables.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

Kadira._parseEnv = function (env) {
let options = {};
for (let name in env) {

Check warning on line 7 in lib/environment_variables.js

View workflow job for this annotation

GitHub Actions / build

The body of a for-in should be wrapped in an if statement to filter unwanted properties from the prototype
let value = env[name];
let normalizedName = normalizedPrefix(name);
let info = Kadira._parseEnv._options[normalizedName];
Expand Down Expand Up @@ -134,4 +134,8 @@
name: 'disableNtp',
parser: Kadira._parseEnv.parseBool,
},
MONTI_DISABLE_INSTRUMENTATION: {
name: 'disableInstrumentation',
parser: Kadira._parseEnv.parseBool
}
};
6 changes: 1 addition & 5 deletions lib/hijack/instrument.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,7 @@ import { hijackDBOps } from './db';
import { wrapRedisOplogObserveDriver } from './redis_oplog';

let instrumented = false;
Kadira._startInstrumenting = function (callback) {
if (Meteor.settings?.monti?.disableInstrumentation || process.env.MONTI_DISABLE_INSTRUMENTATION) {
console.log('Monti APM: Instrumentation is disabled.');
return;
}
Kadira._startInstrumenting = function (callback = () => {}) {
if (instrumented) {
callback();
return;
Expand Down
Loading
Loading