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

fix: add guidance re usage query count #6910

Merged
merged 1 commit into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cypress/e2e/cloud/usage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {Organization} from '../../../src/types'

const statHeaders = [
'Data In (MB)',
'Query Count',
'Query Count (Flux Only) ?',
Copy link
Contributor

Choose a reason for hiding this comment

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

I just noticed the ? here - doesn't the tooltip element cover that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a change I identified after running the ui integration tests, which failed without the change. This is part of a test that designates what text to look for in the header. QuestionMarkToolip is a Clockface component that, among other things, renders and formats a ? as text wherever the component is rendered. As a result, the test needed to be updated to address the fact that the text within the header now includes that ?.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, that makes sense, thanks for the explanation!

'Storage (GB-hr)',
'Data Out (GB)',
]
Expand Down
29 changes: 25 additions & 4 deletions src/usage/UsageSingleStat.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
// Libraries
import React, {FC, useContext} from 'react'
import {Panel, ComponentSize, InfluxColors} from '@influxdata/clockface'
import {
Panel,
ComponentSize,
InfluxColors,
QuestionMarkTooltip,
} from '@influxdata/clockface'

// Components
import {View} from 'src/visualization'
import {UsageContext} from 'src/usage/context/usage'

// Constants
const QUERY_COUNT_VECTOR_NAME = 'Query Count'

// Types
import {
SingleStatViewProperties,
Expand Down Expand Up @@ -39,6 +47,10 @@ const UsageSingleStat: FC<Props> = ({
decimalPlaces: {isEnforced: false, digits: 0},
}

// Adjusts table properties to warn user that only flux queries are included in the Query Count.
const isQueryCount: Boolean = usageVector.name === QUERY_COUNT_VECTOR_NAME
const vectorName = isQueryCount ? 'Query Count (Flux Only)' : usageVector.name
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This overrides the default backend-provided vector name.


const error = fromFluxResult?.table?.columns?.error?.data?.[0]

return (
Expand All @@ -51,9 +63,14 @@ const UsageSingleStat: FC<Props> = ({
size={ComponentSize.ExtraSmall}
testID="usage-single-stat--header"
>
<h5>{`${usageVector.name} ${
usageVector.unit !== '' ? `(${usageVector.unit})` : ''
}`}</h5>
<h5>
{`${vectorName} ${
usageVector.unit !== '' ? `(${usageVector.unit})` : ''
}`}
{isQueryCount && (
<QuestionMarkTooltip tooltipContents={queryCountWarning} />
)}
</h5>
</Panel.Header>
<Panel.Body className="panel-body--size" style={{height: 300 / length}}>
<View
Expand All @@ -68,4 +85,8 @@ const UsageSingleStat: FC<Props> = ({
)
}

const queryCountWarning = (
<p>SQL and InfluxQL query counts are not displayed.</p>
)

export default UsageSingleStat