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

feature: Need Cardinality Limiter for gql.loaderBatchSize tag in gql.dataLoader metrics #1974

Open
hzariv opened this issue Aug 2, 2024 · 7 comments
Labels
backlog enhancement New feature or request

Comments

@hzariv
Copy link

hzariv commented Aug 2, 2024

Please read our contributor guide before
creating an issue. Also consider discussing your idea on
the discussion forum first.

Describe the Feature Request

gql.loaderBatchSize tag in gql.dataLoader metrics can have a high cordinality. I need a way to limit this tag cardinality.

Describe Preferred Solution

I would like management.metrics.dgs-graphql.tags.limiter.limit property to apply to gql.loaderBatchSize tag

Describe Alternatives

Provide a way for me to customize the metrics tags

@hzariv hzariv added the enhancement New feature or request label Aug 2, 2024
@mrvaruntandon
Copy link
Contributor

Hi @hzariv,

Is there any discussion thread on this feature request that I can read to understand this issue better?
if no, could you please explain the request a little more?

@hzariv
Copy link
Author

hzariv commented Aug 3, 2024

@mrvaruntandon We have many applications that use @DgsDataLoader heavily with diffrent batch sizes. This results in high cardinality in our metrics system. Here is an example of these metrics. As you can see gql_loaderBatchSize is unbounded and can very. This results in cardinality issues for us. So I need a way to limit the cardinality for this tag or a way to customise the gql_dataLoader_seconds_count and gql_dataLoader_seconds_sum metrics.

gql_dataLoader_seconds_count{gql_loaderBatchSize="152",gql_loaderName="Extension",} 5.0 gql_dataLoader_seconds_sum{gql_loaderBatchSize="152",gql_loaderName="Extension",} 0.286892171 gql_dataLoader_seconds_count{gql_loaderBatchSize="140",gql_loaderName="Extension",} 1.0 gql_dataLoader_seconds_sum{gql_loaderBatchSize="140",gql_loaderName="Extension",} 0.061202343 gql_dataLoader_seconds_count{gql_loaderBatchSize="10",gql_loaderName="Extension",} 119.0 gql_dataLoader_seconds_sum{gql_loaderBatchSize="10",gql_loaderName="Extension",} 0.442741418 gql_dataLoader_seconds_count{gql_loaderBatchSize="176",gql_loaderName="Extension",} 4.0 gql_dataLoader_seconds_sum{gql_loaderBatchSize="176",gql_loaderName="Extension",} 0.299238463

@mrvaruntandon
Copy link
Contributor

@hzariv, Thank you for sharing the behaviour you are seeing.

Do you have some sample project from which I can replicate this high cardinality behaviour explained in this issue?

@hzariv
Copy link
Author

hzariv commented Aug 6, 2024

@mrvaruntandon the following example project already has a MappedBatchLoader so if the query is asking for a group of shows with multiple reviews you will get the dataloader metrics as describe here with loaderBatchSize tag in dataLoader metrics. There is nothing special here that application is using. If the caller send queries for multiple shows with a number of reviews, DGS framework will create dataLoader metrics with different batch sizes and that can result in high cardinality.

https://github.com/Netflix/dgs-examples-java/blob/main/src/main/java/com/example/demo/dataloaders/ReviewsDataLoader.java

@mrvaruntandon
Copy link
Contributor

@hzariv are you still facing this issue?

@hzariv
Copy link
Author

hzariv commented Sep 17, 2024

@mrvaruntandon I ended up removing gql.loaderBatchSize tag from gql.dataLoader.seconds* metrics using a MeterFilter to circumvent the problem.

@srinivasankavitha
Copy link
Contributor

@hzariv - how did you install the MeterFilter? Per this discussion here, you mentioned you couldn't accomplish that because the MeterRegistry bean cannot be customized because DgsMeterRegistrySupplier is internal: #1986 (reply in thread)

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

No branches or pull requests

4 participants