Skip to content

Commit

Permalink
addressed linter issues
Browse files Browse the repository at this point in the history
Signed-off-by: sumukhswamy <[email protected]>
  • Loading branch information
sumukhswamy committed Apr 30, 2024
1 parent 173074d commit 8a357b8
Show file tree
Hide file tree
Showing 12 changed files with 91 additions and 64 deletions.
4 changes: 2 additions & 2 deletions public/components/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ interface ObservabilityAppDeps {
dataSourceEnabled: boolean;
dataSourceManagement: DataSourceManagementPluginSetup;
setActionMenu: (menuMount: MountPoint | undefined) => void;
savedObjectsMDSClient: CoreStart['savedObjects']
savedObjectsMDSClient: CoreStart['savedObjects'];
}

// for cypress to test redux store
Expand Down Expand Up @@ -66,7 +66,7 @@ export const App = ({
dataSourceManagement,
setActionMenu,
dataSourceEnabled,
savedObjectsMDSClient
savedObjectsMDSClient,
}: ObservabilityAppDeps) => {
const { chrome, http, notifications, savedObjects: coreSavedObjects } = CoreStartProp;
const parentBreadcrumb = {
Expand Down
3 changes: 1 addition & 2 deletions public/components/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { DataSourceManagementPluginSetup } from '../../../../src/plugins/data_so
import { AppPluginStartDependencies } from '../types';
import { App } from './app';


export const Observability = (
CoreStartProp: CoreStart,
DepsStart: AppPluginStartDependencies,
Expand All @@ -26,7 +25,7 @@ export const Observability = (
dataSourceManagement: DataSourceManagementPluginSetup,
savedObjectsMDSClient: CoreStart['savedObjects']
) => {
const { setHeaderActionMenu } = AppMountParametersProp
const { setHeaderActionMenu } = AppMountParametersProp;
const { dataSource } = DepsStart;
ReactDOM.render(
<App
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export interface DashboardProps extends TraceAnalyticsComponentDeps {
text?: React.ReactChild | undefined,
side?: string | undefined
) => void;
dataSourceMDSId: DataSourceOption[]
dataSourceMDSId: DataSourceOption[];
}

export function Dashboard(props: DashboardProps) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ export function DashboardContent(props: DashboardProps) {
setPercentileMap
).finally(() => setLoading(false));
} else if (mode === 'data_prepper') {
console.log(dataSourceMDSId, 'traces page');
handleDashboardRequest(
http,
DSL,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export function SpanDetailPanel(props: {
http: HttpSetup;
traceId: string;
colorMap: any;
mode: TraceAnalyticsMode
mode: TraceAnalyticsMode;
dataSourceMDSId: string;
page?: string;
openSpanFlyout?: any;
Expand Down Expand Up @@ -82,41 +82,52 @@ export function SpanDetailPanel(props: {
if (_.isEmpty(props.colorMap)) return;
const refreshDSL = spanFiltersToDSL();
setDSL(refreshDSL);
handleSpansGanttRequest(props.traceId, props.http, setData, props.colorMap, refreshDSL, mode, props.dataSourceMDSId);
handleSpansGanttRequest(
props.traceId,
props.http,
setData,
props.colorMap,
refreshDSL,
mode,
props.dataSourceMDSId
);
}, 150);

const spanFiltersToDSL = () => {
const spanDSL: any = mode === 'jaeger' ? {
query: {
bool: {
must: [
{
term: {
traceID: props.traceId,
const spanDSL: any =
mode === 'jaeger'
? {
query: {
bool: {
must: [
{
term: {
traceID: props.traceId,
},
},
],
filter: [],
should: [],
must_not: [],
},
},
],
filter: [],
should: [],
must_not: [],
},
},
} : {
query: {
bool: {
must: [
{
term: {
traceId: props.traceId,
}
: {
query: {
bool: {
must: [
{
term: {
traceId: props.traceId,
},
},
],
filter: [],
should: [],
must_not: [],
},
},
],
filter: [],
should: [],
must_not: [],
},
},
};
};
spanFilters.map(({ field, value }) => {
if (value != null) {
spanDSL.query.bool.must.push({
Expand Down Expand Up @@ -165,10 +176,10 @@ export function SpanDetailPanel(props: {
};
};

const layout = useMemo(
() => getSpanDetailLayout(data.gantt, data.ganttMaxX),
[data.gantt, data.ganttMaxX]
);
const layout = useMemo(() => getSpanDetailLayout(data.gantt, data.ganttMaxX), [
data.gantt,
data.ganttMaxX,
]);

const [currentSpan, setCurrentSpan] = useState('');

Expand Down Expand Up @@ -240,7 +251,7 @@ export function SpanDetailPanel(props: {

return (
<>
<EuiPanel data-test-subj='span-gantt-chart-panel'>
<EuiPanel data-test-subj="span-gantt-chart-panel">
<EuiFlexGroup>
<EuiFlexItem>
<PanelTitle title="Spans" totalItems={data.gantt.length / 2} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,15 @@ export function SpanDetailTable(props: SpanDetailTableProps) {
size: tableParams.size,
sortingColumns: tableParams.sortingColumns.map(({ id, direction }) => ({ [id]: direction })),
};
handleSpansRequest(props.http, setItems, setTotal, spanSearchParams, props.DSL, mode, props.dataSourceMDSId);
handleSpansRequest(
props.http,
setItems,
setTotal,
spanSearchParams,
props.DSL,
mode,
props.dataSourceMDSId
);
}, [tableParams, props.DSL]);

useEffect(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ export function TracesContent(props: TracesProps) {
mode,
dataPrepperIndicesExist,
jaegerIndicesExist,
notifications,
dataSourceManagement,
dataSourceMDSId,
} = props;
Expand Down
2 changes: 1 addition & 1 deletion public/components/trace_analytics/home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export const Home = (props: HomeProps) => {
setToasts([...toasts, { id: new Date().toISOString(), title, text, color } as Toast]);
};

let [dataSourceMDSId, setDataSourceMDSId] = useState([{ id: '', label: '' }]);
const [dataSourceMDSId, setDataSourceMDSId] = useState([{ id: '', label: '' }]);

useEffect(() => {
handleDataPrepperIndicesExistRequest(
Expand Down
34 changes: 16 additions & 18 deletions public/components/trace_analytics/requests/request_handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export async function handleDslRequest(
bodyQuery: any,
mode: TraceAnalyticsMode,
dataSourceMDSId?: string,
setShowTimeoutToast?: () => void,
setShowTimeoutToast?: () => void
) {
if (DSL?.query) {
bodyQuery.query.bool.must.push(...DSL.query.bool.must);
Expand All @@ -33,11 +33,10 @@ export async function handleDslRequest(
if (!bodyQuery.index) {
body = { ...bodyQuery, index: mode === 'jaeger' ? JAEGER_INDEX_NAME : DATA_PREPPER_INDEX_NAME };
}
let query = {
dataSourceMDSId: dataSourceMDSId
}
const query = {
dataSourceMDSId: dataSourceMDSId,
};
if (setShowTimeoutToast) {

const id = setTimeout(() => setShowTimeoutToast(), 25000); // 25 seconds

try {
Expand All @@ -51,7 +50,6 @@ export async function handleDslRequest(
clearTimeout(id);
}
} else {

try {
return await http.post(TRACE_ANALYTICS_DSL_ROUTE, {
body: JSON.stringify(body),
Expand All @@ -66,14 +64,14 @@ export async function handleDslRequest(
export async function handleJaegerIndicesExistRequest(
http: CoreStart['http'],
setJaegerIndicesExist,
dataSourceMDSId? : string
dataSourceMDSId?: string
) {
let query = {
dataSourceMDSId: dataSourceMDSId
}
const query = {
dataSourceMDSId: dataSourceMDSId,
};
http
.post(TRACE_ANALYTICS_JAEGER_INDICES_ROUTE,{
query
.post(TRACE_ANALYTICS_JAEGER_INDICES_ROUTE, {
query,
})
.then((exists) => setJaegerIndicesExist(exists))
.catch(() => setJaegerIndicesExist(false));
Expand All @@ -82,14 +80,14 @@ export async function handleJaegerIndicesExistRequest(
export async function handleDataPrepperIndicesExistRequest(
http: CoreStart['http'],
setDataPrepperIndicesExist,
dataSourceMDSId? : string
dataSourceMDSId?: string
) {
let query = {
dataSourceMDSId: dataSourceMDSId
}
const query = {
dataSourceMDSId: dataSourceMDSId,
};
http
.post(TRACE_ANALYTICS_DATA_PREPPER_INDICES_ROUTE,{
query
.post(TRACE_ANALYTICS_DATA_PREPPER_INDICES_ROUTE, {
query,
})
.then((exists) => setDataPrepperIndicesExist(exists))
.catch(() => setDataPrepperIndicesExist(false));
Expand Down
2 changes: 1 addition & 1 deletion public/framework/core_refs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class CoreRefs {
public dashboard?: DashboardStart;
public dashboardProviders?: unknown;
public overlays?: OverlayStart;
public dataSource?: DataSourcePluginStart
public dataSource?: DataSourcePluginStart;
private constructor() {
// ...
}
Expand Down
7 changes: 5 additions & 2 deletions public/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
import { SavedObjectsClient } from '../../../src/core/server';
import { DashboardStart } from '../../../src/plugins/dashboard/public';
import { DataPublicPluginSetup, DataPublicPluginStart } from '../../../src/plugins/data/public';
import { DataSourcePluginSetup, DataSourcePluginStart } from '../../../src/plugins/data_source/public';
import {
DataSourcePluginSetup,
DataSourcePluginStart,
} from '../../../src/plugins/data_source/public';
import { DataSourceManagementPluginSetup } from '../../../src/plugins/data_source_management/public';
import { EmbeddableSetup, EmbeddableStart } from '../../../src/plugins/embeddable/public';
import { ManagementOverViewPluginSetup } from '../../../src/plugins/management_overview/public';
Expand Down Expand Up @@ -39,7 +42,7 @@ export interface SetupDependencies {
managementOverview?: ManagementOverViewPluginSetup;
assistantDashboards?: AssistantSetup;
dataSource: DataSourcePluginSetup;
dataSourceManagement: DataSourceManagementPluginSetup
dataSourceManagement: DataSourceManagementPluginSetup;
}

// eslint-disable-next-line @typescript-eslint/no-empty-interface
Expand Down
10 changes: 9 additions & 1 deletion server/routes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,15 @@ import { registerPplRoute } from './ppl';
import { registerQueryAssistRoutes } from './query_assist/routes';
import { registerTraceAnalyticsDslRouter } from './trace_analytics_dsl_router';

export function setupRoutes({ router, client, dataSourceEnabled }: { router: IRouter; client: ILegacyClusterClient, dataSourceEnabled: boolean }) {
export function setupRoutes({
router,
client,
dataSourceEnabled,
}: {
router: IRouter;
client: ILegacyClusterClient;
dataSourceEnabled: boolean;
}) {
PanelsRouter(router);
VisualizationsRouter(router);
registerPplRoute({ router, facet: new PPLFacet(client) });
Expand Down

0 comments on commit 8a357b8

Please sign in to comment.