Skip to content

Commit

Permalink
Merge branch 'master' into fix-console-error
Browse files Browse the repository at this point in the history
  • Loading branch information
kibanamachine authored Oct 18, 2021
2 parents 0871f7b + a4f6988 commit f6b40ca
Show file tree
Hide file tree
Showing 85 changed files with 1,007 additions and 1,107 deletions.
2 changes: 1 addition & 1 deletion docs/getting-started/quick-start-guide.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ image::images/dashboard_sampleDataAddFilter_7.15.0.png[The [eCommerce] Revenue D
[[quick-start-whats-next]]
== What's next?

*Add your own data.* Ready to add your own data? Go to {fleet-guide}/fleet-quick-start.html[Quick start: Get logs and metrics into the Elastic Stack] to learn how to ingest your data, or go to <<connect-to-elasticsearch,Add data to {kib}>> and learn about all the other ways you can add data.
*Add your own data.* Ready to add your own data? Go to {observability-guide}/ingest-logs-metrics-uptime.html[Ingest logs, metrics, and uptime data with {agent}], or go to <<connect-to-elasticsearch,Add data to {kib}>> and learn about all the other ways you can add data.

*Explore your own data in Discover.* Ready to learn more about exploring your data in *Discover*? Go to <<discover, Discover>>.

Expand Down
2 changes: 1 addition & 1 deletion docs/osquery/osquery.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ The following is an example of an **error response** for an undefined action que
== System requirements

* {fleet-guide}/fleet-overview.html[Fleet] is enabled on your cluster, and
one or more {fleet-guide}/elastic-agent-installation-configuration.html[Elastic Agents] is enrolled.
one or more {fleet-guide}/elastic-agent-installation.html[Elastic Agents] is enrolled.
* The https://docs.elastic.co/en/integrations/osquery_manager[*Osquery Manager*] integration
has been added and configured
for an agent policy through Fleet.
Expand Down
2 changes: 1 addition & 1 deletion docs/setup/connect-to-elasticsearch.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ so you can quickly get insights into your data, and {fleet} mode offers several
image::images/addData_fleet_7.15.0.png[Add data using Fleet]

To get started, refer to
{fleet-guide}/fleet-quick-start.html[Quick start: Get logs and metrics into the Elastic Stack].
{observability-guide}/ingest-logs-metrics-uptime.html[Ingest logs, metrics, and uptime data with {agent}].

[discrete]
[[upload-data-kibana]]
Expand Down
2 changes: 1 addition & 1 deletion docs/setup/settings.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ that the {kib} server uses to perform maintenance on the {kib} index at startup.
is an alternative to `elasticsearch.username` and `elasticsearch.password`.

| `enterpriseSearch.host`
| The URL of your Enterprise Search instance
| The http(s) URL of your Enterprise Search instance. For example, in a local self-managed setup, set this to `http://localhost:3002`. Authentication between Kibana and the Enterprise Search host URL, such as via OAuth, is not supported. You can also {enterprise-search-ref}/configure-ssl-tls.html#configure-ssl-tls-in-kibana[configure Kibana to trust your Enterprise Search TLS certificate authority].

| `interpreter.enableInVisualize`
| Enables use of interpreter in Visualize. *Default: `true`*
Expand Down
1 change: 1 addition & 0 deletions src/plugins/custom_integrations/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export const INTEGRATION_CATEGORY_DISPLAY = {
project_management: 'Project Management',
software_development: 'Software Development',
upload_file: 'Upload a file',
website_search: 'Website Search',
};

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,7 @@
* 2.0.
*/

import {
FieldValuePair,
HistogramItem,
RawResponseBase,
SearchStrategyClientParams,
} from '../types';
import { FieldValuePair, HistogramItem } from '../types';

import { FAILED_TRANSACTIONS_IMPACT_THRESHOLD } from './constants';
import { FieldStats } from '../field_stats_types';
Expand All @@ -33,11 +28,7 @@ export interface FailedTransactionsCorrelationsParams {
percentileThreshold: number;
}

export type FailedTransactionsCorrelationsRequestParams =
FailedTransactionsCorrelationsParams & SearchStrategyClientParams;

export interface FailedTransactionsCorrelationsRawResponse
extends RawResponseBase {
export interface FailedTransactionsCorrelationsRawResponse {
log: string[];
failedTransactionsCorrelations?: FailedTransactionsCorrelation[];
percentileThresholdValue?: number;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,7 @@
* 2.0.
*/

import {
FieldValuePair,
HistogramItem,
RawResponseBase,
SearchStrategyClientParams,
} from '../types';
import { FieldValuePair, HistogramItem } from '../types';
import { FieldStats } from '../field_stats_types';

export interface LatencyCorrelation extends FieldValuePair {
Expand All @@ -33,10 +28,7 @@ export interface LatencyCorrelationsParams {
analyzeCorrelations: boolean;
}

export type LatencyCorrelationsRequestParams = LatencyCorrelationsParams &
SearchStrategyClientParams;

export interface LatencyCorrelationsRawResponse extends RawResponseBase {
export interface LatencyCorrelationsRawResponse {
log: string[];
overallHistogram?: HistogramItem[];
percentileThresholdValue?: number;
Expand Down
12 changes: 11 additions & 1 deletion x-pack/plugins/apm/common/search_strategies/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,26 @@ export interface RawResponseBase {
took: number;
}

export interface SearchStrategyClientParams {
export interface SearchStrategyClientParamsBase {
environment: string;
kuery: string;
serviceName?: string;
transactionName?: string;
transactionType?: string;
}

export interface RawSearchStrategyClientParams
extends SearchStrategyClientParamsBase {
start?: string;
end?: string;
}

export interface SearchStrategyClientParams
extends SearchStrategyClientParamsBase {
start: number;
end: number;
}

export interface SearchStrategyServerParams {
index: string;
includeFrozen?: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import type { IKibanaSearchResponse } from 'src/plugins/data/public';
import { EuiThemeProvider } from 'src/plugins/kibana_react/common';
import { createKibanaReactContext } from 'src/plugins/kibana_react/public';
import type { LatencyCorrelationsRawResponse } from '../../../../common/search_strategies/latency_correlations/types';
import type { RawResponseBase } from '../../../../common/search_strategies/types';
import { MockUrlParamsContextProvider } from '../../../context/url_params_context/mock_url_params_context_provider';
import { ApmPluginContextValue } from '../../../context/apm_plugin/apm_plugin_context';
import {
Expand All @@ -34,7 +35,9 @@ function Wrapper({
dataSearchResponse,
}: {
children?: ReactNode;
dataSearchResponse: IKibanaSearchResponse<LatencyCorrelationsRawResponse>;
dataSearchResponse: IKibanaSearchResponse<
LatencyCorrelationsRawResponse & RawResponseBase
>;
}) {
const mockDataSearch = jest.fn(() => of(dataSearchResponse));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,43 +8,24 @@
import { render, screen, waitFor } from '@testing-library/react';
import { createMemoryHistory } from 'history';
import React, { ReactNode } from 'react';
import { of } from 'rxjs';

import { CoreStart } from 'kibana/public';
import { merge } from 'lodash';
import { dataPluginMock } from 'src/plugins/data/public/mocks';
import type { IKibanaSearchResponse } from 'src/plugins/data/public';
import { EuiThemeProvider } from 'src/plugins/kibana_react/common';
import { createKibanaReactContext } from 'src/plugins/kibana_react/public';
import type { LatencyCorrelationsRawResponse } from '../../../../../common/search_strategies/latency_correlations/types';
import { MockUrlParamsContextProvider } from '../../../../context/url_params_context/mock_url_params_context_provider';
import { ApmPluginContextValue } from '../../../../context/apm_plugin/apm_plugin_context';
import {
mockApmPluginContextValue,
MockApmPluginContextWrapper,
} from '../../../../context/apm_plugin/mock_apm_plugin_context';
import * as useFetcherModule from '../../../../hooks/use_fetcher';
import { fromQuery } from '../../../shared/Links/url_helpers';

import { getFormattedSelection, TransactionDistribution } from './index';

function Wrapper({
children,
dataSearchResponse,
}: {
children?: ReactNode;
dataSearchResponse: IKibanaSearchResponse<LatencyCorrelationsRawResponse>;
}) {
const mockDataSearch = jest.fn(() => of(dataSearchResponse));

const dataPluginMockStart = dataPluginMock.createStartContract();
function Wrapper({ children }: { children?: ReactNode }) {
const KibanaReactContext = createKibanaReactContext({
data: {
...dataPluginMockStart,
search: {
...dataPluginMockStart.search,
search: mockDataSearch,
},
},
usageCollection: { reportUiCounter: () => {} },
} as Partial<CoreStart>);

Expand Down Expand Up @@ -105,18 +86,14 @@ describe('transaction_details/distribution', () => {

describe('TransactionDistribution', () => {
it('shows loading indicator when the service is running and returned no results yet', async () => {
jest.spyOn(useFetcherModule, 'useFetcher').mockImplementation(() => ({
data: {},
refetch: () => {},
status: useFetcherModule.FETCH_STATUS.LOADING,
}));

render(
<Wrapper
dataSearchResponse={{
isRunning: true,
rawResponse: {
ccsWarning: false,
took: 1234,
latencyCorrelations: [],
log: [],
},
}}
>
<Wrapper>
<TransactionDistribution
onChartSelection={jest.fn()}
onClearSelection={jest.fn()}
Expand All @@ -132,18 +109,14 @@ describe('transaction_details/distribution', () => {
});

it("doesn't show loading indicator when the service isn't running", async () => {
jest.spyOn(useFetcherModule, 'useFetcher').mockImplementation(() => ({
data: { percentileThresholdValue: 1234, overallHistogram: [] },
refetch: () => {},
status: useFetcherModule.FETCH_STATUS.SUCCESS,
}));

render(
<Wrapper
dataSearchResponse={{
isRunning: false,
rawResponse: {
ccsWarning: false,
took: 1234,
latencyCorrelations: [],
log: [],
},
}}
>
<Wrapper>
<TransactionDistribution
onChartSelection={jest.fn()}
onClearSelection={jest.fn()}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,20 @@ import { i18n } from '@kbn/i18n';
import { useUiTracker } from '../../../../../../observability/public';

import { getDurationFormatter } from '../../../../../common/utils/formatters';
import {
APM_SEARCH_STRATEGIES,
DEFAULT_PERCENTILE_THRESHOLD,
} from '../../../../../common/search_strategies/constants';
import { DEFAULT_PERCENTILE_THRESHOLD } from '../../../../../common/search_strategies/constants';

import { useApmPluginContext } from '../../../../context/apm_plugin/use_apm_plugin_context';
import { useSearchStrategy } from '../../../../hooks/use_search_strategy';
import { useApmServiceContext } from '../../../../context/apm_service/use_apm_service_context';
import { useUrlParams } from '../../../../context/url_params_context/use_url_params';
import { FETCH_STATUS } from '../../../../hooks/use_fetcher';
import { useApmParams } from '../../../../hooks/use_apm_params';
import { useFetcher, FETCH_STATUS } from '../../../../hooks/use_fetcher';
import { useTimeRange } from '../../../../hooks/use_time_range';

import {
TransactionDistributionChart,
TransactionDistributionChartData,
} from '../../../shared/charts/transaction_distribution_chart';
import { isErrorMessage } from '../../correlations/utils/is_error_message';
import { getOverallHistogram } from '../../correlations/utils/get_overall_histogram';

import type { TabContentProps } from '../types';
import { useWaterfallFetcher } from '../use_waterfall_fetcher';
Expand Down Expand Up @@ -73,11 +71,14 @@ export function TransactionDistribution({
selection,
traceSamples,
}: TransactionDistributionProps) {
const { serviceName, transactionType } = useApmServiceContext();

const {
core: { notifications },
} = useApmPluginContext();

const { urlParams } = useUrlParams();
const { transactionName } = urlParams;

const { waterfall, status: waterfallStatus } = useWaterfallFetcher();

Expand All @@ -98,31 +99,67 @@ export function TransactionDistribution({
}
);

const { progress, response } = useSearchStrategy(
APM_SEARCH_STRATEGIES.APM_LATENCY_CORRELATIONS,
{
percentileThreshold: DEFAULT_PERCENTILE_THRESHOLD,
analyzeCorrelations: false,
}
);
const { overallHistogram, hasData, status } = getOverallHistogram(
response,
progress.isRunning
const {
query: { kuery, environment, rangeFrom, rangeTo },
} = useApmParams('/services/{serviceName}/transactions/view');

const { start, end } = useTimeRange({ rangeFrom, rangeTo });

const {
data = { log: [] },
status,
error,
} = useFetcher(
(callApmApi) => {
if (serviceName && environment && start && end) {
return callApmApi({
endpoint: 'GET /internal/apm/latency/overall_distribution',
params: {
query: {
serviceName,
transactionName,
transactionType,
kuery,
environment,
start,
end,
percentileThreshold: DEFAULT_PERCENTILE_THRESHOLD,
},
},
});
}
},
[
serviceName,
transactionName,
transactionType,
kuery,
environment,
start,
end,
]
);

const overallHistogram =
data.overallHistogram === undefined && status !== FETCH_STATUS.LOADING
? []
: data.overallHistogram;
const hasData =
Array.isArray(overallHistogram) && overallHistogram.length > 0;

useEffect(() => {
if (isErrorMessage(progress.error)) {
if (isErrorMessage(error)) {
notifications.toasts.addDanger({
title: i18n.translate(
'xpack.apm.transactionDetails.distribution.errorTitle',
{
defaultMessage: 'An error occurred fetching the distribution',
}
),
text: progress.error.toString(),
text: error.toString(),
});
}
}, [progress.error, notifications.toasts]);
}, [error, notifications.toasts]);

const trackApmEvent = useUiTracker({ app: 'apm' });

Expand Down Expand Up @@ -213,7 +250,7 @@ export function TransactionDistribution({
data={transactionDistributionChartData}
markerCurrentTransaction={markerCurrentTransaction}
markerPercentile={DEFAULT_PERCENTILE_THRESHOLD}
markerValue={response.percentileThresholdValue ?? 0}
markerValue={data.percentileThresholdValue ?? 0}
onChartSelection={onTrackedChartSelection as BrushEndListener}
hasData={hasData}
selection={selection}
Expand Down
Loading

0 comments on commit f6b40ca

Please sign in to comment.