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

Errors inbox #45

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
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
8 changes: 7 additions & 1 deletion src/contexts/utils/account-gql.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const FETCH_ACCOUNTS_GQL = {
};

export const FETCH_ACCOUNT_WITH_ID_GQL_OBJ = {
query: `query ($id: Int!, $withFragment: Boolean!,$EVENT_TYPES_INCLUDE: Boolean!, $PROGRAMMABILITY_SUBSCRIBED: Boolean!, $APM_SUBSCRIBED: Boolean!, $BROWSER_SUBSCRIBED: Boolean!, $MOBILE_SUBSCRIBED: Boolean!, $INFRA_SUBSCRIBED: Boolean!, $LOGGING_SUBSCRIBED: Boolean!, $SYNTHETICS_SUBSCRIBED: Boolean!, $INSIGHTS_SUBSCRIBED: Boolean!, $WORKLOADS_SUBSCRIBED: Boolean!, $KUBERNETES_SUBSCRIBED: Boolean!, $SLM_SUBSCRIBED: Boolean!, $NPM_SUBSCRIBED: Boolean!) {
query: `query ($id: Int!, $withFragment: Boolean!,$EVENT_TYPES_INCLUDE: Boolean!, $PROGRAMMABILITY_SUBSCRIBED: Boolean!, $APM_SUBSCRIBED: Boolean!, $BROWSER_SUBSCRIBED: Boolean!, $MOBILE_SUBSCRIBED: Boolean!, $INFRA_SUBSCRIBED: Boolean!, $LOGGING_SUBSCRIBED: Boolean!, $SYNTHETICS_SUBSCRIBED: Boolean!, $INSIGHTS_SUBSCRIBED: Boolean!, $WORKLOADS_SUBSCRIBED: Boolean!, $KUBERNETES_SUBSCRIBED: Boolean!, $SLM_SUBSCRIBED: Boolean!, $NPM_SUBSCRIBED: Boolean!, $ERRORS_INBOX_SUBSCRIBED: Boolean!) {
actor {
account(id: $id) {
id
Expand All @@ -29,6 +29,7 @@ export const FETCH_ACCOUNT_WITH_ID_GQL_OBJ = {
...INFRA_Fragments @include(if: $INFRA_SUBSCRIBED)
...SYNTHETICS_Fragments @include(if: $SYNTHETICS_SUBSCRIBED)
...INSIGHTS_Fragments @include(if: $INSIGHTS_SUBSCRIBED)
...ERRORS_INBOX_Fragments @include(if: $ERRORS_INBOX_SUBSCRIBED)
...WORKLOADS_Fragments @include(if: $WORKLOADS_SUBSCRIBED)
...KUBERNETES_Fragments @include(if: $KUBERNETES_SUBSCRIBED)
...SLM_Fragments @include(if: $SLM_SUBSCRIBED)
Expand Down Expand Up @@ -131,6 +132,10 @@ export const FETCH_ACCOUNT_WITH_ID_GQL_OBJ = {
}
}

fragment ERRORS_INBOX_Fragments on Account {
ERRORS_INBOX_PLACEHOLDER: id
}

fragment WORKLOADS_Fragments on Account {
WORKLOADS_PLACEHOLDER:id
}
Expand Down Expand Up @@ -216,6 +221,7 @@ export const FETCH_ACCOUNT_WITH_ID_GQL_OBJ = {
INFRA_SUBSCRIBED: false,
LOGGING_SUBSCRIBED: false,
SYNTHETICS_SUBSCRIBED: false,
ERRORS_INBOX_SUBSCRIBED: false,
WORKLOADS_SUBSCRIBED: false,
KUBERNETES_SUBSCRIBED: false,
SLM_SUBSCRIBED: false,
Expand Down
22 changes: 22 additions & 0 deletions src/contexts/utils/account.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ function _setGQLVariables(query, account) {
LOGGING_SUBSCRIBED: subscriptions
? subscriptions.includes('logging')
: true,
ERRORS_INBOX_SUBSCRIBED: subscriptions
? subscriptions.includes('errorsInbox')
: true,
WORKLOADS_SUBSCRIBED: subscriptions
? subscriptions.includes('workloads')
: true,
Expand Down Expand Up @@ -169,6 +172,10 @@ export function setNrqlFragmentSubscription(query) {
/\$NPM_SUBSCRIBED/g,
query.variables.NPM_SUBSCRIBED
);
nrqlFragment = nrqlFragment.replace(
/\$ERRORS_INBOX_SUBSCRIBED/g,
query.variables.ERRORS_INBOX_SUBSCRIBED
);
nrqlFragment = nrqlFragment.replace(
/\$PROGRAMMABILITY_SUBSCRIBED/g,
query.variables.PROGRAMMABILITY_SUBSCRIBED
Expand Down Expand Up @@ -573,6 +580,7 @@ const subscriptionGQLVarDict = {
synthetics: 'SYNTHETICS_SUBSCRIBED',
logging: 'LOGGING_SUBSCRIBED',
eventTypeInclude: 'EVENT_TYPES_INCLUDE',
errorsInbox: 'ERRORS_INBOX_SUBSCRIBED',
workloads: 'WORKLOADS_SUBSCRIBED',
kubernetes: 'KUBERNETES_SUBSCRIBED',
slm: 'SLM_SUBSCRIBED',
Expand Down Expand Up @@ -604,6 +612,7 @@ export function* getAccountDetails(
// see subscriptionGQLVarDict
subscriptions.push('eventTypeInclude');
subscriptions.push('programmability');
subscriptions.push('errorsInbox');
subscriptions.push('kubernetes');
subscriptions.push('workloads');
subscriptions.push('slm');
Expand Down Expand Up @@ -640,6 +649,7 @@ export function assembleResults(results) {
const response = {
data: {
actor: {
errorsInbox: null,
account: null
}
}
Expand Down Expand Up @@ -668,6 +678,18 @@ export function assembleResults(results) {
...result.data.actor.account
};
}

if (
result.data &&
result.data.actor &&
result.data.actor.errorsInbox !== null
) {
ctr++;
response.data.actor.errorsInbox = {
...response.data.actor.errorsInbox,
...result.data.actor.errorsInbox
};
}
}
// return null if all nrql fragments for the account had errors
return ctr > 0 ? response : null;
Expand Down
1 change: 1 addition & 0 deletions src/entities.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export * from './modules/insights';
export * from './modules/logs';
export * from './modules/programmability';
export * from './modules/mobile';
export * from './modules/errors-inbox';
export * from './modules/workloads';
export * from './modules/kubernetes';
export * from './modules/slm';
Expand Down
52 changes: 50 additions & 2 deletions src/modules/Account.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class Account {
this.infraHosts = new Map();
this.insightsDashboards = [];
// this.InfraApps = new Map();
this.errorsInbox = new Map();
this.workloadMap = new Map();

this.kubernetesMap = new Map();
Expand Down Expand Up @@ -112,7 +113,6 @@ class Account {
this.npmKentikFlowDevices = props.npmKentikFlowDevices;
this.npmKentikVpcDevices = props.npmKentikVpcDevices;
this.npmKtranslateSyslogDevices = props.npmKtranslateSyslogDevices;

}

getName() {
Expand Down Expand Up @@ -1955,7 +1955,7 @@ class Account {

// How many devices don't have profiles -- using generic profile
getNoKentikProviderCount() {
return this.npmNoKentikProvider[0].npmNoKentikProviderProfileCount;
return this.npmNoKentikProvider ? this.npmNoKentikProvider[0].npmNoKentikProviderProfileCount : 0;
}

getNoKentikProviderPercent() {
Expand Down Expand Up @@ -2012,5 +2012,53 @@ class Account {
const result = this.getKtranslateSyslogDeviceCount();
return Boolean(result);;
}

// ERRORS-INBOX METHODS ###########################

getErrorsInboxGroupCount() {
return this.errorsInbox.size || 0;
}

getErrorGroupAssignedPercent() {
const result = Math.round((this.assignedErrorGroupCount / this.getErrorsInboxGroupCount()) * 100);
return isFinite(result) ? result : 0;
}

// resolved percentage
getErrorGroupResolvedPercent() {
const result = Math.round(
(Array.from(this.errorsInbox.values()).filter(item => item.state === 'RESOLVED' || item.state === null).length /
this.getErrorsInboxGroupCount()) *
100
);
return isFinite(result) ? result : 0;
}

getErrorGroupIgnoredPercent() {
const result = Math.round(
(Array.from(this.errorsInbox.values()).filter(item => item.state === 'IGNORED').length /
this.getErrorsInboxGroupCount()) *
100
);
return isFinite(result) ? result : 0;
}

getAppLoggingEnabled() {
let total = 0;
if (!this.apmApps) {
return total;
}

for (const app of this.apmApps.values()) {
if (app.appLoggingEnabled) {
total++;
}
}
return total;
}

getAppLoggingEnabledPercent() {
return Math.round((this.getAppLoggingEnabled() / this.getReportingApps()) * 100) || 0
}
}
export { Account };
20 changes: 20 additions & 0 deletions src/modules/errors-inbox/ErrorsInbox.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
class ErrorsInbox {
constructor(entity, account) {
this.id = entity.id;
this.entityGuid = entity.entityGuid;
this.name = entity.name;
this.accountId = account.id;
this.state = entity.state;
this.assignment = entity.assignment;
}

isErrorGroupAssigned() {
return (
(this.assignment !== null && this.assignment.email !== null) ||
(this.assignment !== null && this.assignment.userInfo !== null) ||
false
);
}
}

export { ErrorsInbox };
133 changes: 133 additions & 0 deletions src/modules/errors-inbox/ErrorsInboxPanel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
import React from 'react';
import PropTypes from 'prop-types';

import {
createErrorsInboxTableData,
computeErrorsInboxMaturityScore
} from './process-errors-inbox-score';
import { ErrorsInboxTable, ErrorsInboxSummaryCols } from './ErrorsInboxTable';
import {
ApplicationCtxConsumer,
CustomCircleLoader,
MaturityScoreCtxConsumer
} from '../../contexts';
import { FilterTableData } from '../../utils/FilterTableData';
import {
ErrorsInboxModel,
fetchErrorsInboxData
} from './fetch-errors-inbox-data';

export const ErrorsInboxPanel = () => (
<ApplicationCtxConsumer>
{appContext => {
if (appContext.loading) {
return <CustomCircleLoader message="Fetching Errors Inbox..." />;
}
return (
<MaturityScoreCtxConsumer>
{scoreContext => {
return (
<ErrorsInboxTag
appContext={appContext}
maturityCtxUpdateScore={scoreContext.updateScore}
/>
);
}}
</MaturityScoreCtxConsumer>
);
}}
</ApplicationCtxConsumer>
);

export class ErrorsInboxTag extends React.Component {
static propTypes = {
appContext: PropTypes.object,
maturityCtxUpdateScore: PropTypes.func,
fetchData: PropTypes.func,
scoreWeights: PropTypes.object,
tableColHeader: PropTypes.array,
createTableData: PropTypes.func,
computeMaturityScore: PropTypes.func
};

constructor(props) {
super(props);
this.state = {
loading: true,
table: []
};
const { appContext } = this.props;

this.nerdGraphQuery = appContext.nerdGraphQuery;
this.ctxAcctMap = new Map(appContext.accountMap);
this.docEventTypes = appContext.docEventTypes;
this.maturityCtxUpdateScore = this.props.maturityCtxUpdateScore;

this.addMaturityScoreToTable = this.addMaturityScoreToTable.bind(this);

this.fetchData = this.props.fetchData || fetchErrorsInboxData;

this.createTableData =
this.props.createTableData || createErrorsInboxTableData;
this.computeMaturityScore =
this.props.computeMaturityScore || computeErrorsInboxMaturityScore;

this.scoreWeights =
this.props.scoreWeights || ErrorsInboxModel.scoreWeights;
this.tableColHeader = this.props.tableColHeader || ErrorsInboxSummaryCols;
}

async componentDidMount() {
await this.fetchData(this.ctxAcctMap, this.nerdGraphQuery);

const tableData = this.createTableData(this.ctxAcctMap, {});
const scores = this.addMaturityScoreToTable(tableData);

this.setState({
loading: false,
table: tableData
});

this.maturityCtxUpdateScore('ERRORS_INBOX', scores, tableData);
}

addMaturityScoreToTable(tableData) {
const maturityScores = {};

tableData.forEach(row => {
const { score } = this.computeMaturityScore({
rowData: row,
scoreWeights: this.scoreWeights
});

const { accountID, accountName } = row;
row.overallScore = score;

maturityScores[accountID] = { accountID, accountName, SCORE: score };
});

return maturityScores;
}

render() {
if (this.state.loading) {
return <CustomCircleLoader message="Loading Errors Inbox..." />;
}

return (
<FilterTableData
tableData={this.state.table}
filterKeys={['overallScore']}
>
{({ filteredData }) => {
return (
<ErrorsInboxTable
data={filteredData}
columns={this.tableColHeader}
/>
);
}}
</FilterTableData>
);
}
}
Loading