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

fxa-auth-server mock statsd lacks of function histogram #16491

Open
jackyzy823 opened this issue Feb 28, 2024 · 0 comments
Open

fxa-auth-server mock statsd lacks of function histogram #16491

jackyzy823 opened this issue Feb 28, 2024 · 0 comments

Comments

@jackyzy823
Copy link
Contributor

jackyzy823 commented Feb 28, 2024

Description

Here

this.metrics?.histogram(
requires metrics is not null and metrics.histogram is a function

If metrics is not enabled, mock Statsd will be used:

const statsd = config.statsd.enabled
? new StatsD({
...config.statsd,
errorHandler: (err) => {
// eslint-disable-next-line no-use-before-define
log.error('statsd.error', err);
},
})
: {
increment: () => {},
timing: () => {},
close: () => {},
};

However it lacks of function histogram

metrics is initialized here :

function resolveMetrics() {
if (Container.has(StatsD)) {
return Container.get(StatsD);
}
}

Solution:

  1. Either set metrics to undefined if metrics is not enabled, like here
    const metrics = config.metrics?.host
    ? new StatsD({
    ...config.metrics,
    errorHandler: (err) => {
    // eslint-disable-next-line no-use-before-define
    logger.error('statsd.error', { err });
    },
    })
    : undefined;
  2. Or mock histogram function (and possibly other functions)

┆Issue is synchronized with this Jira Task

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

No branches or pull requests

1 participant