Skip to content

Commit

Permalink
Application Details (#383)
Browse files Browse the repository at this point in the history
* Update tests, builds and doc (#318)

* rebased with bwc tests

Signed-off-by: Shenoy Pratik <[email protected]>

* updated bwc tests

Signed-off-by: Shenoy Pratik <[email protected]>

* added release notes

Signed-off-by: Shenoy Pratik <[email protected]>

* Rename trace-analytics to observability (#341)

Signed-off-by: Joshua Li <[email protected]>

* Event analytics unit tests (#342)

* tests

Signed-off-by: Eric Wei <[email protected]>

* updated some snapshots

Signed-off-by: Eric Wei <[email protected]>

* resolved few failing tests

Signed-off-by: Eric Wei <[email protected]>

* few modifications

Signed-off-by: Eric Wei <[email protected]>

* Update service map parsing results for testing (#345)

Signed-off-by: Joshua Li <[email protected]>

* bumping version to 1.2.2 (#346)

* bumping version to 1.2.2

Signed-off-by: Shenoy Pratik <[email protected]>

* update PR in release notes

Signed-off-by: Shenoy Pratik <[email protected]>

* updating readme and badges (#352)

Signed-off-by: Shenoy Pratik <[email protected]>

* Update Workflow (#360)

* updated snapshot in workflow to 1.2.3

Signed-off-by: Shenoy Pratik <[email protected]>

* replaced variable with 1.2.3-snapshot

Signed-off-by: Shenoy Pratik <[email protected]>

* revert string to variable

Signed-off-by: Shenoy Pratik <[email protected]>

* bumping main to 1.3 (#361)

Signed-off-by: Shenoy Pratik <[email protected]>

* Add observability visualization to notebooks  (#351)

* added observability viz support to notes

Signed-off-by: Shenoy Pratik <[email protected]>

* updated tests, clone para, zeppelin parser

Signed-off-by: Shenoy Pratik <[email protected]>

* updated observability viz links & cypress

Signed-off-by: Shenoy Pratik <[email protected]>

* updated tests

Signed-off-by: Shenoy Pratik <[email protected]>

* removed inputType, merged both viz options

Signed-off-by: Shenoy Pratik <[email protected]>

* resolved merge conflict

Signed-off-by: Shenoy Pratik <[email protected]>

* updated links, adaptors, tests

Signed-off-by: Shenoy Pratik <[email protected]>

* removed unused files, updated workflow

Signed-off-by: Shenoy Pratik <[email protected]>

* updated UI dateformat for observability viz

Signed-off-by: Shenoy Pratik <[email protected]>

* updated jest timeout

Signed-off-by: Shenoy Pratik <[email protected]>

* updated notebook tests

Signed-off-by: Shenoy Pratik <[email protected]>

* Add .whitesource configuration file (#365)

Co-authored-by: whitesource-for-github-com[bot] <50673670+whitesource-for-github-com[bot]@users.noreply.github.com>

* CVE fix:json-schema, gson & glob-parent (#368)

* CVE fix:json-schema, gson & glob-parent

Signed-off-by: Shenoy Pratik <[email protected]>

* updated yarn.lock

Signed-off-by: Shenoy Pratik <[email protected]>

* Update Release Notes 1.2.4 (#370)

* CVE fix:json-schema, gson & glob-parent

Signed-off-by: Shenoy Pratik <[email protected]>

* updated yarn.lock

Signed-off-by: Shenoy Pratik <[email protected]>

* Update Release Notes 1.2.4

Signed-off-by: Shenoy Pratik <[email protected]>

* jcenter removed from gradle.build (#374)

Signed-off-by: Shenoy Pratik <[email protected]>

* Application Analytics (#299)

* Add database schema for application

Signed-off-by: Eugene Lee <[email protected]>

* Finished front end for Application overview
Signed-off-by: Eugene Lee <[email protected]>

* Finished application detail page tabs
Signed-off-by: Eugene Lee <[email protected]>

* WIP: Overview Page
Signed-off-by: Eugene Lee <[email protected]>

* Rough sketch of App Analytics UI
Signed-off-by: Eugene Lee <[email protected]>

* Create dummy page
Signed-off-by: Eugene Lee <[email protected]>

* Create app complete. Stabilizing dashboard component.
Signed-off-by: Eugene Lee <[email protected]>

* Update to 1.2 Observability

Signed-off-by: Eugene Lee <[email protected]>

* notebooks internal error

Signed-off-by: Eugene Lee <[email protected]>

* Address comments on PR: copyright headers, indentation, unnecessary render props

Signed-off-by: Eugene Lee <[email protected]>

* Set max width of app and event

Signed-off-by: Eugene Lee <[email protected]>

* Remove optional after description

Signed-off-by: Eugene Lee <[email protected]>

* Change to singular

Signed-off-by: Eugene Lee <[email protected]>

* Remove count badge for log source

Signed-off-by: Eugene Lee <[email protected]>

* #290: Change form row label to ppl base query

Signed-off-by: Eugene Lee <[email protected]>

* #291: Change description and help text for log source

Signed-off-by: Eugene Lee <[email protected]>

* Pass down proper props

Signed-off-by: Eugene Lee <[email protected]>

* Resolve gradle error and module not found error

Signed-off-by: Eugene Lee <[email protected]>

* Resolve kotlin errors

Signed-off-by: Eugene Lee <[email protected]>

* Fix parsers

Signed-off-by: Eugene Lee <[email protected]>

* Add praseItemList

Signed-off-by: Eugene Lee <[email protected]>

* Camelcase fields

Signed-off-by: Eugene Lee <[email protected]>

* Remove whitespace, add copyright

Signed-off-by: Eugene Lee <[email protected]>

* #292: Add autocomplete to Log Source accordion

Signed-off-by: Eugene Lee <[email protected]>

* Lexicographic kotlin import

Signed-off-by: Eugene Lee <[email protected]>

* Add newline at end of files

Signed-off-by: Eugene Lee <[email protected]>

* #293: Add service map to create page

Signed-off-by: Eugene Lee <[email protected]>

* #304: Activate Clear All button for services

Signed-off-by: Eugene Lee <[email protected]>

* #305: Add button to clear base query

Signed-off-by: Eugene Lee <[email protected]>

* #295: Add eui combo box for trace groups

Signed-off-by: Eugene Lee <[email protected]>

* Separate out configuration renders

Signed-off-by: Eugene Lee <[email protected]>

* debug adding filters traces

Signed-off-by: Eugene Lee <[email protected]>

* #296: Add traces table to config

Signed-off-by: Eugene Lee <[email protected]>

* Change from tsx to ts

Signed-off-by: Eugene Lee <[email protected]>

* #309: Add page props and add app specific filters

Signed-off-by: Eugene Lee <[email protected]>

* #308: Add button to clear trace groups

Signed-off-by: Eugene Lee <[email protected]>

* #311: Allow services and traces to be selected

Signed-off-by: Eugene Lee <[email protected]>

* Remove link to traces on table

Signed-off-by: Eugene Lee <[email protected]>

* Disable clear all if nothing selected

Signed-off-by: Eugene Lee <[email protected]>

* disable clear all when no log source

Signed-off-by: Eugene Lee <[email protected]>

* Remove comment, add style to constant, temporarily remove availability

Signed-off-by: Eugene Lee <[email protected]>

* Address PR comments

Signed-off-by: Eugene Lee <[email protected]>

* Revert type assignment

Signed-off-by: Eugene Lee <[email protected]>

* Update tests, builds and doc (#318)

* rebased with bwc tests

Signed-off-by: Shenoy Pratik <[email protected]>

* updated bwc tests

Signed-off-by: Shenoy Pratik <[email protected]>

* added release notes

Signed-off-by: Shenoy Pratik <[email protected]>

* Fix errors and address comments

Signed-off-by: Eugene Lee <[email protected]>

* #319: Disable create until required fields are filled out

Signed-off-by: Eugene Lee <[email protected]>

* #329: Add missing field tool tip

Signed-off-by: Eugene Lee <[email protected]>

* Remove unnecessary imports

Signed-off-by: Eugene Lee <[email protected]>

* #320: Add clear modal for friction

Signed-off-by: Eugene Lee <[email protected]>

Co-authored-by: Shenoy Pratik <[email protected]>

* Fix merge conflict

Signed-off-by: Eugene Lee <[email protected]>

* #321: Add clear modal for services (#355)

Signed-off-by: Eugene Lee <[email protected]>

* #322: Add clear modal for traces (#356)

Signed-off-by: Eugene Lee <[email protected]>

* Adds tests for application creation (#357)

* Remove unnecessary memoization

Signed-off-by: Eugene Lee <[email protected]>

* Add tests for create page

Signed-off-by: Eugene Lee <[email protected]>

* Application Analytics (#299)

* Add database schema for application

Signed-off-by: Eugene Lee <[email protected]>

* Finished front end for Application overview
Signed-off-by: Eugene Lee <[email protected]>

* Finished application detail page tabs
Signed-off-by: Eugene Lee <[email protected]>

* WIP: Overview Page
Signed-off-by: Eugene Lee <[email protected]>

* Rough sketch of App Analytics UI
Signed-off-by: Eugene Lee <[email protected]>

* Create dummy page
Signed-off-by: Eugene Lee <[email protected]>

* Create app complete. Stabilizing dashboard component.
Signed-off-by: Eugene Lee <[email protected]>

* Update to 1.2 Observability

Signed-off-by: Eugene Lee <[email protected]>

* notebooks internal error

Signed-off-by: Eugene Lee <[email protected]>

* Address comments on PR: copyright headers, indentation, unnecessary render props

Signed-off-by: Eugene Lee <[email protected]>

* Set max width of app and event

Signed-off-by: Eugene Lee <[email protected]>

* Remove optional after description

Signed-off-by: Eugene Lee <[email protected]>

* Change to singular

Signed-off-by: Eugene Lee <[email protected]>

* Remove count badge for log source

Signed-off-by: Eugene Lee <[email protected]>

* #290: Change form row label to ppl base query

Signed-off-by: Eugene Lee <[email protected]>

* #291: Change description and help text for log source

Signed-off-by: Eugene Lee <[email protected]>

* Pass down proper props

Signed-off-by: Eugene Lee <[email protected]>

* Resolve gradle error and module not found error

Signed-off-by: Eugene Lee <[email protected]>

* Resolve kotlin errors

Signed-off-by: Eugene Lee <[email protected]>

* Fix parsers

Signed-off-by: Eugene Lee <[email protected]>

* Add praseItemList

Signed-off-by: Eugene Lee <[email protected]>

* Camelcase fields

Signed-off-by: Eugene Lee <[email protected]>

* Remove whitespace, add copyright

Signed-off-by: Eugene Lee <[email protected]>

* #292: Add autocomplete to Log Source accordion

Signed-off-by: Eugene Lee <[email protected]>

* Lexicographic kotlin import

Signed-off-by: Eugene Lee <[email protected]>

* Add newline at end of files

Signed-off-by: Eugene Lee <[email protected]>

* #293: Add service map to create page

Signed-off-by: Eugene Lee <[email protected]>

* #304: Activate Clear All button for services

Signed-off-by: Eugene Lee <[email protected]>

* #305: Add button to clear base query

Signed-off-by: Eugene Lee <[email protected]>

* #295: Add eui combo box for trace groups

Signed-off-by: Eugene Lee <[email protected]>

* Separate out configuration renders

Signed-off-by: Eugene Lee <[email protected]>

* debug adding filters traces

Signed-off-by: Eugene Lee <[email protected]>

* #296: Add traces table to config

Signed-off-by: Eugene Lee <[email protected]>

* Change from tsx to ts

Signed-off-by: Eugene Lee <[email protected]>

* #309: Add page props and add app specific filters

Signed-off-by: Eugene Lee <[email protected]>

* #308: Add button to clear trace groups

Signed-off-by: Eugene Lee <[email protected]>

* #311: Allow services and traces to be selected

Signed-off-by: Eugene Lee <[email protected]>

* Remove link to traces on table

Signed-off-by: Eugene Lee <[email protected]>

* Disable clear all if nothing selected

Signed-off-by: Eugene Lee <[email protected]>

* disable clear all when no log source

Signed-off-by: Eugene Lee <[email protected]>

* Remove comment, add style to constant, temporarily remove availability

Signed-off-by: Eugene Lee <[email protected]>

* Address PR comments

Signed-off-by: Eugene Lee <[email protected]>

* Revert type assignment

Signed-off-by: Eugene Lee <[email protected]>

* Update tests, builds and doc (#318)

* rebased with bwc tests

Signed-off-by: Shenoy Pratik <[email protected]>

* updated bwc tests

Signed-off-by: Shenoy Pratik <[email protected]>

* added release notes

Signed-off-by: Shenoy Pratik <[email protected]>

* Fix errors and address comments

Signed-off-by: Eugene Lee <[email protected]>

* #319: Disable create until required fields are filled out

Signed-off-by: Eugene Lee <[email protected]>

* #329: Add missing field tool tip

Signed-off-by: Eugene Lee <[email protected]>

* Remove unnecessary imports

Signed-off-by: Eugene Lee <[email protected]>

* #320: Add clear modal for friction

Signed-off-by: Eugene Lee <[email protected]>

Co-authored-by: Shenoy Pratik <[email protected]>

* Add create route for app analytics

Signed-off-by: Eugene Lee <[email protected]>

* #325: Return to app table on cancel

Signed-off-by: Eugene Lee <[email protected]>

* Remove unnecessary import

Signed-off-by: Eugene Lee <[email protected]>

* #340: Apps selectable, actions correctly disabled

Signed-off-by: Eugene Lee <[email protected]>

* Fix mapping update

Signed-off-by: Eugene Lee <[email protected]>

* #327: Rename application

Signed-off-by: Eugene Lee <[email protected]>

* #376: Fetch all applications for home page

Signed-off-by: Eugene Lee <[email protected]>

* #343: Enable deletion of application

Signed-off-by: Eugene Lee <[email protected]>

* Fetch application by Id

Signed-off-by: Eugene Lee <[email protected]>

* Add exception catch

Signed-off-by: Eugene Lee <[email protected]>

* More specific exception
:

Signed-off-by: Eugene Lee <[email protected]>

* Log error instead of warn

Signed-off-by: Eugene Lee <[email protected]>

* Remove generic exception

Signed-off-by: Eugene Lee <[email protected]>

* Debug assert

Signed-off-by: Eugene Lee <[email protected]>

* Fix type

Signed-off-by: Eugene Lee <[email protected]>

* Fix Lint

Signed-off-by: Eugene Lee <[email protected]>

* Address comments

Signed-off-by: Eugene Lee <[email protected]>

* 343: Enable deletion of application

Signed-off-by: Eugene Lee <[email protected]>

* Remove duplicate import

Signed-off-by: Eugene Lee <[email protected]>

* Remove branch

Signed-off-by: Eugene Lee <[email protected]>

* Remove trace if selected

Signed-off-by: Eugene Lee <[email protected]>

* Rename trace-analytics to observability (#341)

Signed-off-by: Joshua Li <[email protected]>

* updating readme and badges (#352)

Signed-off-by: Shenoy Pratik <[email protected]>

* Name is blank if loading

Signed-off-by: Eugene Lee <[email protected]>

Co-authored-by: Shenoy Pratik <[email protected]>
Co-authored-by: Joshua Li <[email protected]>
Co-authored-by: Eric Wei <[email protected]>
Co-authored-by: whitesource-for-github-com[bot] <50673670+whitesource-for-github-com[bot]@users.noreply.github.com>
  • Loading branch information
5 people authored Jan 25, 2022
1 parent 1c8cd21 commit ab9be3c
Show file tree
Hide file tree
Showing 5 changed files with 101 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@ import DSLService from 'public/services/requests/dsl';
import PPLService from 'public/services/requests/ppl';
import SavedObjects from 'public/services/saved_objects/event_analytics/saved_objects';
import TimestampUtils from 'public/services/timestamp/timestamp';
import React, { ReactChild, useState } from 'react';
import React, { ReactChild, useEffect, useState } from 'react';
import { isEmpty, uniqueId } from 'lodash';
import {
ApplicationType,
APP_ANALYTICS_API_PREFIX,
TAB_CONFIG_ID_TXT_PFX,
TAB_CONFIG_TITLE,
TAB_LOG_ID_TXT_PFX,
Expand Down Expand Up @@ -70,14 +72,45 @@ interface AppDetailProps extends AppAnalyticsComponentDeps {
notifications: NotificationsStart;
}


export function Application(props: AppDetailProps) {
const { pplService, dslService, timestampUtils, savedObjects, http, notifications } = props;
const { pplService, dslService, timestampUtils, savedObjects, http, notifications, appId, chrome, parentBreadcrumb } = props;
const [application, setApplication] = useState<ApplicationType>();
const [selectedTabId, setSelectedTab] = useState<string>(TAB_OVERVIEW_ID);
const handleContentTabClick = (selectedTab: IQueryTab) => setSelectedTab(selectedTab.id);
const history = useHistory();
const [toasts, setToasts] = useState<Array<Toast>>([]);

// Fetch application by id
const fetchAppById = async (appId: string) => {
return http
.get(`${APP_ANALYTICS_API_PREFIX}/${appId}`)
.then((res) => {
setApplication(res.application);
})
.catch((err) => {
setToast('Error occurred while fetching application', 'danger');
console.error(err);
})
}

useEffect(() => {
fetchAppById(appId);
}, [appId]);

useEffect(() => {
chrome.setBreadcrumbs([
parentBreadcrumb,
{
text: 'Application analytics',
href: '#/application_analytics',
},
{
text: application?.name || '',
href: `${parentBreadcrumb.href}${appId}`,
},
]);
}, [appId, application?.name]);

const setToast = (title: string, color = 'success', text?: ReactChild, side?: string) => {
if (!text) text = '';
setToasts([...toasts, { id: new Date().toISOString(), title, text, color } as Toast]);
Expand All @@ -98,20 +131,20 @@ export function Application(props: AppDetailProps) {

const getOverview = () => {
return (
<Dashboard {...props} page="app" appId="id" appName="Cool Application" />
<Dashboard {...props} page="app" appId={appId} appName={application?.name} />
);
};

const getService = () => {
return (
<Services {...props} page="app" appId="id" appName="Cool Application" />
<Services {...props} page="app" appId={appId} appName={application?.name} />
);
};

const getTrace = () => {
return (
<>
<Traces {...props} page="app" appId="id" appName="Cool Application" />
<Traces {...props} page="app" appId={appId} appName={application?.name} />
<EuiSpacer size='m'/>
<SpanDetailPanel
{...props}
Expand Down Expand Up @@ -218,7 +251,7 @@ export function Application(props: AppDetailProps) {
<EuiPageHeader>
<EuiPageHeaderSection>
<EuiTitle size="l">
<h1>my-app1</h1>
<h1>{application?.name || ''}</h1>
</EuiTitle>
</EuiPageHeaderSection>
</EuiPageHeader>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export const CreateApp = (props: CreateAppProps) => {
};

const onCreate = () => {
createApp(state.name, state.description, query, selectedServices, selectedTraces)
createApp(state.name, state.description, query, selectedServices, selectedTraces);
}

const onCancel = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export interface AppAnalyticsComponentDeps extends TraceAnalyticsComponentDeps {

export const Home = (props: HomeProps) => {
const { pplService, dslService, timestampUtils, savedObjects, parentBreadcrumb, http, chrome, notifications } = props;
const [applicationData, setApplicationData] = useState<Array<ApplicationListType>>([]);
const [applicationList, setApplicationList] = useState<Array<ApplicationListType>>([]);
const [toasts, setToasts] = useState<Array<Toast>>([]);
const [indicesExist, setIndicesExist] = useState(true);
const storedFilters = sessionStorage.getItem('AppAnalyticsFilters');
Expand Down Expand Up @@ -94,10 +94,10 @@ export const Home = (props: HomeProps) => {
return http
.get(`${APP_ANALYTICS_API_PREFIX}/`)
.then((res) => {
setApplicationData(res.data);
setApplicationList(res.data);
})
.catch((err) => {
setToast('Error occured while fetching applications', 'danger');
setToast('Error occurred while fetching applications', 'danger');
console.error(err);
})
}
Expand All @@ -124,7 +124,9 @@ export const Home = (props: HomeProps) => {
})
.then((res) => {
setToast(`Application "${name}" successfully created!`);
window.location.assign(`${parentBreadcrumb.href}${res.newAppId}`)
setFiltersWithStorage([]);
setQueryWithStorage('');
window.location.assign(`${parentBreadcrumb.href}application_analytics/${res.newAppId}`)
})
.catch((err) => {
setToast(`Error occurred while creating new application "${name}"`, 'danger');
Expand All @@ -149,8 +151,8 @@ export const Home = (props: HomeProps) => {
body: JSON.stringify(requestBody)
})
.then((res) => {
setApplicationData((prevApplicationData) => {
const newApplicationData = [...prevApplicationData];
setApplicationList((prevApplicationList) => {
const newApplicationData = [...prevApplicationList];
const renamedApplication = newApplicationData.find(
(application) => application.id === appId
);
Expand All @@ -170,8 +172,8 @@ export const Home = (props: HomeProps) => {
return http
.delete(`${APP_ANALYTICS_API_PREFIX}/${appList.join(',')}`)
.then((res) => {
setApplicationData((prevApplicationData) => {
return prevApplicationData.filter((app) => !appList.includes(app.id))
setApplicationList((prevApplicationList) => {
return prevApplicationList.filter((app) => !appList.includes(app.id))
});
const message =
toastMessage || `Application${appList.length > 1 ? 's' : ''} successfully deleted!`;
Expand Down Expand Up @@ -201,7 +203,7 @@ export const Home = (props: HomeProps) => {
<ObservabilitySideBar>
<AppTable
loading={false}
applications={applicationData}
applications={applicationList}
fetchApplications={fetchApps}
renameApplication={renameApp}
deleteApplication={deleteApp}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { ILegacyScopedClusterClient } from "../../../../../src/core/server";
export class AppAnalyticsAdaptor {

// Fetch all existing applications
fetchApps = async(client: ILegacyScopedClusterClient) => {
fetchApps = async (client: ILegacyScopedClusterClient) => {
try {
const response = await client.callAsCurrentUser('observability.getObject', {
objectType: 'application',
Expand All @@ -25,6 +25,18 @@ export class AppAnalyticsAdaptor {
}
}

// Fetch application by id
fetchAppById = async (client: ILegacyScopedClusterClient, appId: string) => {
try {
const response = await client.callAsCurrentUser('observability.getObjectById', {
objectId: appId,
});
return response.observabilityObjectList[0];
} catch (err: any) {
throw new Error('Fetch Application By Id Error: ' + err);
}
}

// Create a new application
createNewApp = async (
client: ILegacyScopedClusterClient,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,42 @@ export function registerAppAnalyticsRouter(router: IRouter) {
}
}
)

// Fetch application by id
router.get(
{
path: `${API_PREFIX}/{appId}`,
validate: {
params: schema.object({
appId: schema.string(),
}),
},
},
async(
context,
request,
response
): Promise<IOpenSearchDashboardsResponse<any | ResponseError>> => {
const opensearchClient: ILegacyScopedClusterClient = context.observability_plugin.observabilityClient.asScoped(
request
);
try {
const appObject = await appAnalyticsBackend.fetchAppById(
opensearchClient,
request.params.appId
);
return response.ok({
body: appObject
});
} catch (err: any) {
console.error('Error occurred while fetching application', err);
return response.custom({
statusCode: err.statusCode || 500,
body: err.message,
});
}
}
)

// Create a new application
router.post(
Expand Down

0 comments on commit ab9be3c

Please sign in to comment.