Skip to content

QueryCountStatsMonitor: emit query/count - #6473

Merged
leventov merged 4 commits into
apache:masterfrom
QiuMM:emit
Oct 19, 2018
Merged

leventov merged 4 commits into
apache:masterfrom
QiuMM:emit

Conversation

@QiuMM

@QiuMM QiuMM commented Oct 16, 2018 •

Copy link
Copy Markdown
Member

Let QueryCountStatsMonitor emit query/count, then I can monitor QPS of my services, or I have to count it by myself.

Map<String, Long> diff = keyedDiff.to(
"queryCountStats",
ImmutableMap.of("query/success/count", statsProvider.getSuccessfulQueryCount(),
ImmutableMap.of("query/total/count", statsProvider.getSuccessfulQueryCount() + statsProvider.getFailedQueryCount(),

@gianm gianm Oct 16, 2018 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should include interrupted too. It looks like "failed" and "interrupted" are exclusive.

For consistency I'd also suggest retrieving the successful/failed/interrupted counts first, then summing them into the total. This is because the counts are always getting updated in the background, and if you call getSuccessfulQueryCount() more than once, the two won't necessarily be the same.

@leventov leventov Oct 16, 2018 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think metric names should add slashes when some different options are imaginable after the slash. With this, I think just query/count or query/count/total (with another option of query/count/delta) is better

@QiuMM

QiuMM commented Oct 16, 2018

Copy link
Copy Markdown
Member Author

@gianm @leventov thanks for your reviews. Have updated.

@leventov leventov changed the title QueryCountStatsMonitor: emit query/total/count QueryCountStatsMonitor: emit query/count Oct 16, 2018
ImmutableMap.of("query/success/count", statsProvider.getSuccessfulQueryCount(),
"query/failed/count", statsProvider.getFailedQueryCount(),
"query/interrupted/count", statsProvider.getInterruptedQueryCount()
ImmutableMap.of("query/count", successfulQueryCount + failedQueryCount + interruptedQueryCount,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should break "query/count", successfulQueryCount + failedQueryCount + interruptedQueryCount, on the next line, as well as the following lines

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, changed.

"query/interrupted/count", interruptedQueryCount

ImmutableMap.of(
"query/count",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could keep corresponding keys and values on the same line, e. g.

ImmutableMap.of(
    key1, value1,
    key2, value2,
    ...
)

I think it's more readable and recognised as an exception from the general rule here: https://github.com/apache/incubator-druid/pull/6461/files#diff-b26be0568e2252c7501570f97d7a91e8R212

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you mean like below?

Map<String, Long> diff = keyedDiff.to(
        "queryCountStats",
        ImmutableMap.of(
            "query/count", successfulQueryCount + failedQueryCount + interruptedQueryCount,
            "query/success/count", successfulQueryCount,
            "query/failed/count", failedQueryCount,
            "query/interrupted/count", interruptedQueryCount
        )
    );

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated, thanks.

@gianm gianm left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM after CI!

@leventov
leventov merged commit f5f4171 into apache:master Oct 19, 2018
@QiuMM
QiuMM deleted the emit branch November 7, 2018 17:06
@jon-wei jon-wei added this to the 0.14.0 milestone Feb 20, 2019
riovic918data pushed a commit to riovic918data/druid that referenced this pull request Jun 12, 2026
Let `QueryCountStatsMonitor` emit `query/count`, then I can monitor QPS of my services, or I have to count it by myself.
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

Successfully merging this pull request may close these issues.

4 participants