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

can't use histogram without the labelNames and buckets #56

Open
hpsmatheus opened this issue May 10, 2021 · 2 comments
Open

can't use histogram without the labelNames and buckets #56

hpsmatheus opened this issue May 10, 2021 · 2 comments

Comments

@hpsmatheus
Copy link

hpsmatheus commented May 10, 2021

I have the following histogram


this.usersHistogram = this.promService.getHistogram({
			name: 'users_histogram',
			help: 'Request duration',
			buckets: [0.1, 0.3, 0.5],
			labelNames: ['a1'],
		});

but if I remove the labelNames param, I get this error when starting the application

TypeError: Cannot read property 'forEach' of undefined
    at validateInput (/home/matheus/node_modules/@digikare/nestjs-prom/node_modules/prom-client/lib/histogram.js:166:9)
    at new Histogram (/home/matheus/node_modules/@digikare/nestjs-prom/node_modules/prom-client/lib/histogram.js:44:3)
    at findOrCreateMetric (/home/matheus/node_modules/@digikare/nestjs-prom/dist/common/prom.utils.js:50:20)
    at Object.findOrCreateHistogram (/home/matheus/node_modules/@digikare/nestjs-prom/dist/common/prom.utils.js:87:12)
    at PromService.getHistogram (/home/matheus/node_modules/@digikare/nestjs-prom/dist/prom.service.js:26:29)

And if I remove the buckets param, I get this error


TypeError: Cannot read property 'reduce' of undefined
    at new Histogram (/home/matheus/node_modules/@digikare/nestjs-prom/node_modules/prom-client/lib/histogram.js:51:40)
    at findOrCreateMetric (/home/matheus/node_modules/@digikare/nestjs-prom/dist/common/prom.utils.js:50:20)
    at Object.findOrCreateHistogram (/home/matheus/node_modules/@digikare/nestjs-prom/dist/common/prom.utils.js:87:12)
    at PromService.getHistogram (/home/matheus/node_modules/@digikare/nestjs-prom/dist/prom.service.js:26:29)

I'm trying to remove these params because the IHistogramMetricArguments says they are not required.

export interface IHistogramMetricArguments extends IMetricArguments {
    buckets?: number[];
}

export interface IMetricArguments {
    name: string;
    help?: string;
    labelNames?: string[];
    registry?: PromClient.Registry;
}

I'm using version 1.0.0

@travtarr
Copy link

travtarr commented Jun 6, 2021

I get the same issue. It seems to be that [email protected] introduced these breaking changes. Looking at the source ^13 might be a fix to the issue but I haven't tested it yet.

@cramhead
Copy link

Seem's it's still a problem in prom-client 13.1.0.
If I provide a default configuration for buckets it seems to stop throwing this error.

e.g.

this.promService.getHistogram({
      name: 'graphql_total_request_time',
      help: 'The time to complete a GraphQL query.',
      labelNames: ['operationName', 'operation'],
      buckets: [0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10],
    });
    ```

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

3 participants