Skip to content

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

@jackyzy823

Description

@jackyzy823

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions