Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,11 @@ export interface ObservabilityElasticsearchClient {
operationName: string,
request: Required<FieldCapsRequest, 'index_filter' | 'fields' | 'index'>
): Promise<FieldCapsResponse>;
esql<TOutput extends EsqlOutput = EsqlOutput>(
esql<TOutput extends {} = EsqlOutput>(
operationName: string,
parameters: ObservabilityEsQueryRequest
): Promise<InferEsqlResponseOf<TOutput, { transform: 'none' }>>;
esql<
TOutput extends EsqlOutput = EsqlOutput,
TEsqlOptions extends EsqlOptions = { transform: 'none' }
>(
esql<TOutput extends {} = EsqlOutput, TEsqlOptions extends EsqlOptions = { transform: 'none' }>(
operationName: string,
parameters: ObservabilityEsQueryRequest,
options: TEsqlOptions
Expand Down
40 changes: 19 additions & 21 deletions x-pack/solutions/observability/plugins/apm/common/service_map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,33 +9,26 @@ import { i18n } from '@kbn/i18n';
import type cytoscape from 'cytoscape';
import type { Coordinate } from '../typings/timeseries';
import type { ServiceAnomalyStats } from './anomaly_detection';

// These should be imported, but until TypeScript 4.2 we're inlining them here.
// All instances of "agent.name", "service.name", "service.environment", "span.type",
// "span.subtype", and "span.destination.service.resource" need to be changed
// back to using the constants.
// See https://github.com/microsoft/TypeScript/issues/37888
//
// import {
// AGENT_NAME,
// SERVICE_ENVIRONMENT,
// SERVICE_NAME,
// SPAN_DESTINATION_SERVICE_RESOURCE,
// SPAN_SUBTYPE,
// SPAN_TYPE,
// } from './es_fields/apm';
import type {
AGENT_NAME,
SERVICE_ENVIRONMENT,
SERVICE_NAME,
SPAN_DESTINATION_SERVICE_RESOURCE,
SPAN_SUBTYPE,
} from './es_fields/apm';
import type { SPAN_TYPE } from './es_fields/apm';

export interface ServiceConnectionNode extends cytoscape.NodeDataDefinition {
'service.name': string;
'service.environment': string | null;
'agent.name': string;
[SERVICE_NAME]: string;
[SERVICE_ENVIRONMENT]: string | null;
[AGENT_NAME]: string;
serviceAnomalyStats?: ServiceAnomalyStats;
label?: string;
}
export interface ExternalConnectionNode extends cytoscape.NodeDataDefinition {
'span.destination.service.resource': string;
'span.type': string;
'span.subtype': string;
[SPAN_DESTINATION_SERVICE_RESOURCE]: string;
[SPAN_SUBTYPE]: string;
[SPAN_TYPE]: string;
label?: string;
}

Expand Down Expand Up @@ -108,3 +101,8 @@ export function isSpanGroupingSupported(type?: string, subtype?: string) {
}

export const SERVICE_MAP_TIMEOUT_ERROR = 'ServiceMapTimeoutError';

export interface DiscoveredService {
from: ExternalConnectionNode;
to: ServiceConnectionNode;
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { useChartThemes } from '@kbn/observability-shared-plugin/public';
import { uniqueId } from 'lodash';
import React, { useMemo, useRef } from 'react';
import { i18n } from '@kbn/i18n';
import type { FETCH_STATUS } from '../../../hooks/use_fetcher';
import { FETCH_STATUS } from '../../../hooks/use_fetcher';
import { useFetcher, isPending } from '../../../hooks/use_fetcher';
import { CriticalPathFlamegraphTooltip } from './critical_path_flamegraph_tooltip';
import { criticalPathToFlamegraph } from './critical_path_to_flamegraph';
Expand Down Expand Up @@ -44,7 +44,7 @@ export function CriticalPathFlamegraph(
const { data: { criticalPath } = { criticalPath: null }, status: criticalPathFetchStatus } =
useFetcher(
(callApmApi) => {
if (!traceIds.length) {
if (!traceIds.length || traceIdsFetchStatus === FETCH_STATUS.LOADING) {
return Promise.resolve({ criticalPath: null });
}

Expand All @@ -60,7 +60,7 @@ export function CriticalPathFlamegraph(
},
});
},
[timerange, traceIds, serviceName, transactionName]
[timerange, traceIdsFetchStatus, traceIds, serviceName, transactionName]
);

const chartThemes = useChartThemes();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import {
type ObservabilityElasticsearchClient,
createObservabilityEsClient,
} from '@kbn/observability-utils-server/es/client/create_observability_es_client';
import type { APMIndices } from '@kbn/apm-data-access-plugin/server';
import { APM_SERVER_FEATURE_ID } from '../../../common/rules/apm_rule_types';
import type { MinimalAPMRouteHandlerResources } from '../../routes/apm_routes/register_apm_server_routes';

export interface EsClient extends ObservabilityElasticsearchClient {
indices: APMIndices;
}

export async function getEsClient({
context,
logger,
getApmIndices,
}: Pick<
MinimalAPMRouteHandlerResources,
'context' | 'getApmIndices' | 'logger'
>): Promise<EsClient> {
const [coreContext, indices] = await Promise.all([context.core, getApmIndices()]);

return {
indices,
...createObservabilityEsClient({
client: coreContext.elasticsearch.client.asCurrentUser,
logger,
plugin: `@kbn/${APM_SERVER_FEATURE_ID}-plugin`,
}),
};
}
Loading