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

Integrated telemetry #100

Open
6aKa opened this issue Apr 10, 2023 · 3 comments
Open

Integrated telemetry #100

6aKa opened this issue Apr 10, 2023 · 3 comments
Labels
enhancement New feature or request needs feedback

Comments

@6aKa
Copy link

6aKa commented Apr 10, 2023

Count and store metrics for http/ws/pg/minion, like a total requests/request per sec/duration/query length.

@kraih kraih added enhancement New feature or request needs feedback labels Apr 10, 2023
@kraih
Copy link
Member

kraih commented Apr 10, 2023

That already exists for the Perl version as a plugin. https://github.com/mojolicious/mojo-status

@6aKa
Copy link
Author

6aKa commented Apr 11, 2023

Perl plugin collect metrics only for server. I talk about global storage and pluggable system for collectors. With default (configurable)/metrics endpoint, which return data in prometheus format.
Like this

import mojo, {serverMetricsCollector, wsMetricsCollector} from '@mojojs/core';
import {pgMetricsCollector} from '@mojojs/pg';

const app = mojo();
app.telemetry(serverMetricsCollector); -> collect http_requests_total, http_requests_duration
app.telemetry(wsMetricsCollector); -> collect wss_requests_total, wss_requests_duration
app.telemetry(pgMetricsCollector);

And with lowlevel functions to work with values, ex

app.get('/', async ctx => {
  await ctx.requestCount.inc('http_requests_total', {prefix: 'root'}); -> manually inc root_http_requests_total metric
  await ctx.render({json: {name: ctx.config.name}});
});

@kraih
Copy link
Member

kraih commented Apr 11, 2023

Sure, makes for a good plugin. All necessary hooks for metrics collection should exist already.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request needs feedback
Projects
None yet
Development

No branches or pull requests

2 participants