Skip to content
This repository has been archived by the owner on Mar 2, 2025. It is now read-only.

Commit

Permalink
Merge pull request #268 from IKatsuba/default-metrics-config
Browse files Browse the repository at this point in the history
feat(stats): add default metrics configuration
  • Loading branch information
IKatsuba authored Nov 21, 2023
2 parents a1d9e8b + 5bae50a commit d0d01b1
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion apps/api-e2e/tests/app.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ describe('api e2e', () => {
beforeAll(async () => {
createTestProject();

addPackageToPackageJson('nx-cloud');
addPackageToPackageJson('nx-cloud@16.4.0');
}, 120000);

afterAll(() => {
Expand Down
4 changes: 2 additions & 2 deletions apps/api-e2e/tests/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { tmpProjPath } from '@nx/plugin/testing';
import { dirname, join, basename } from 'path';
import { dirname, basename } from 'path';
import * as ch from 'child_process';
import { execSync } from 'child_process';
import { getPackageManagerCommand } from 'nx/src/utils/package-manager';
Expand All @@ -19,7 +19,7 @@ export function createTestProject() {
});

execSync(
`npx --yes create-nx-workspace@latest ${projectName} --preset apps --no-nxCloud --no-interactive`,
`npx --yes create-nx-workspace@16 ${projectName} --preset apps --no-nxCloud --no-interactive`,
{
cwd: dirname(projectDirectory),
stdio: 'inherit',
Expand Down
4 changes: 4 additions & 0 deletions libs/api/models/src/lib/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,9 @@ export interface Environment {

ENV: 'development' | string;

// Prometheus starts here
METRICS_PATH: string;
DEFAULT_METRICS_ENABLED: boolean;
DEFAULT_METRICS_PREFIX: string;
// Prometheus ends here
}
6 changes: 6 additions & 0 deletions libs/api/stats/src/lib/prometheus-stats.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ import { Environment } from '@nx-turbo/api-models';
PrometheusModule.registerAsync({
useFactory: (config: ConfigService<Environment>) => ({
path: config.get('METRICS_PATH', '/metrics'),
defaultMetrics: {
enabled: config.get('DEFAULT_METRICS_ENABLED', true),
config: {
prefix: config.get('DEFAULT_METRICS_PREFIX', 'nx_cloud_'),
},
},
}),
inject: [ConfigService],
}),
Expand Down

0 comments on commit d0d01b1

Please sign in to comment.