-
Notifications
You must be signed in to change notification settings - Fork 13
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 prom metrics api to terafoundation #3594
Conversation
bump: (minor) @terascope/[email protected], [email protected] bump: (minor) @terascope/[email protected], @terascope/[email protected] bump: (minor) @terascope/[email protected], @terascope/[email protected] bump: (minor) [email protected], [email protected] bump: (minor) [email protected], [email protected] bump: (minor) @terascope/[email protected], @terascope/[email protected]
Current Prom Metrics output for master:
|
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.
I am going to approve this but I would like Peter to answer some of the questions I've asked inline.
@@ -101,9 +105,12 @@ export type FoundationSysConfig<S> = { | |||
log_path: string; | |||
log_level: LogLevelConfig; | |||
logging: LogType[]; | |||
asset_storage_connection_type?: string; | |||
asset_storage_connection?: string; | |||
asset_storage_connection_type: string; |
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.
Why have these gone from being optional in this PR?
Also, it's just occurred to me that asset_storage_connection_type
shouldn't be in the terafoundation config, it should be in the teraslice config right? there are no assets in other terafoundation apps (spaces). This isn't really relevant for this PR though.
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.
I realized that a FoundationSysConfig
type is only created after the terafoundation
config has run through convict
and defaults have been inserted. asset_storage_connection_type
and asset_storage_connection
should and will always exist on this type. There are most likely a few if (field exists)
statements that can be removed since I made this change.
it('should not initialize a promMetricsAPI', async () => { | ||
const result = await context.apis.foundation.promMetrics.init(config); | ||
expect(result).toBe(false); | ||
}); |
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.
I would have probably chosen to try a some other api calls here to ensure they don't blow up.
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.
Although maybe there's other cases where other apis are tested and shown to not throw when it's all disabled.
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.
I went ahead and added a few.
@@ -38,7 +38,7 @@ export class AssetsService { | |||
|
|||
async initialize() { | |||
try { | |||
this.assetsStorage = await new AssetsStorage(this.context); | |||
this.assetsStorage = new AssetsStorage(this.context); |
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.
Again, why is there an AssetsStorage related change here?
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.
I just noticed that the await was unnecessary. Maybe I should have done that in another PR.
All of the comments about the asset storage stuff ... is important but unrelated to this PR. |
This PR makes the following changes:
PromMetrics
andExporter
classes fromstandard-assets
intoterafoundation
promMetrics
as a field tocontext.apis.foundation
, allowing the promMetrics class to be used anywhere that usesterafoundation
. ApromMetricsProxy
is used to catch calls topromMetrics
if metrics are disabled.terafoundation
schema.ts
andjob-components
job-schemas.ts
. Values in ajobConfig
will override values interafoundation
.prom_metrics_enabled
- start a Prometheus exporter serverprom_metrics_port
- port the server will listen onprom_metrics_add_defaults
- collect default metrics recommended by Prometheus as well as Node.js-specific metrics.MockPromMetrics
injob-components
TestContext
to be used in unit tests.terafoundation
,types
andjob-components
.promMetrics.init
and add an info metric toClusterMaster
,SlicerExecutionContext
andWorkerExecutionContext
classes.ref: #3360