Skip to content

feat(auth-cron): add metrics MAPCO-8511#102

Merged
netanelC merged 4 commits into
masterfrom
add-metrics-to-cron
Aug 19, 2025
Merged

feat(auth-cron): add metrics MAPCO-8511#102
netanelC merged 4 commits into
masterfrom
add-metrics-to-cron

Conversation

@netanelC
Copy link
Copy Markdown
Contributor

Introduce a new metrics endpoint to provide telemetry data, enhancing the application's monitoring capabilities. Adjustments include integrating the metrics registry and updating the server response logic.

@netanelC netanelC self-assigned this Aug 18, 2025
@netanelC netanelC requested a review from CptSchnitz August 18, 2025 15:02
@netanelC netanelC changed the title feat(auth-cron): add metrics feat(auth-cron): add metrics MAPCO-8511 Aug 18, 2025
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Aug 18, 2025

🎫 Related Jira Issue: MAPCO-8511

Comment thread packages/auth-cron/src/index.ts Outdated
import { metricsRegistry } from './telemetry/metrics';

const LIVENESS_PORT = 8080;
const PORT = 8080;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

get the port from env if defined.
later integrate with the schema

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

Comment thread packages/auth-cron/src/index.ts Outdated
Comment on lines 49 to 67
const server = createServer((request, response) => {
response.end(`HELLO WORLD`);
if (request.url === '/metrics') {
metricsRegistry
.metrics()
.then((metrics) => {
response.setHeader('Content-Type', metricsRegistry.contentType);
response.end(metrics);
})
.catch((err) => {
if (err instanceof Error) {
logger?.error({ msg: 'Failed to generate metrics', err });
}
response.statusCode = 500;
response.end('Error generating metrics');
});
} else {
response.end('HELLO WORLD');
}
});
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

dont you want to just install express and use the middleware from telemetry?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done


const metricsRegistry = new Registry();

collectMetricsExpressMiddleware({ registry: metricsRegistry });
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ok you should really just use express........
this is a middleware

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

Comment thread packages/auth-cron/src/index.ts Outdated
Co-authored-by: Ofer <12687466+CptSchnitz@users.noreply.github.com>
@netanelC netanelC merged commit af8e937 into master Aug 19, 2025
12 checks passed
@netanelC netanelC deleted the add-metrics-to-cron branch October 15, 2025 08:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants