Skip to content
Merged
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
3 changes: 2 additions & 1 deletion src/platform/packages/shared/kbn-discover-utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export {
convertValueToString,
createLogsContextService,
createTracesContextService,
createApmErrorsContextService,
createDegradedDocsControl,
createStacktraceControl,
fieldConstants,
Expand Down Expand Up @@ -66,7 +67,7 @@ export {
LogLevelBadge,
} from './src';

export type { LogsContextService, TracesContextService } from './src';
export type { LogsContextService, TracesContextService, ApmErrorsContextService } from './src';

export * from './src/types';

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
* 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", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/

import { getApmErrorsContextService } from '../data_types';

export const createApmErrorsContextServiceMock = () => getApmErrorsContextService('errors-*');
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ export * from './es_hits';
export * from './additional_field_groups';
export * from './logs_context_service';
export * from './traces_context_service';
export * from './apm_errors_context_service';
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* 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", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/

import type { ApmSourceAccessPluginStart } from '@kbn/apm-sources-access-plugin/public';

export interface ApmErrorsContextService {
getErrorsIndexPattern(): string;
}

export interface ApmErrorsContextServiceDeps {
apmSourcesAccess?: ApmSourceAccessPluginStart;
}

// should we have defaults here?
export const DEFAULT_ALLOWED_APM_ERRORS_BASE_PATTERNS = [];

export const createApmErrorsContextService = async ({
apmSourcesAccess,
}: ApmErrorsContextServiceDeps): Promise<ApmErrorsContextService> => {
if (!apmSourcesAccess) {
return defaultApmErrorsContextService;
}

try {
const indices = await apmSourcesAccess.getApmIndices();

if (!indices) {
return defaultApmErrorsContextService;
}

const { error } = indices;
return getApmErrorsContextService(error);
} catch (error) {
return defaultApmErrorsContextService;
}
};

export const getApmErrorsContextService = (error: string) => ({
getErrorsIndexPattern: () => error,
});

const defaultApmErrorsContextService = getApmErrorsContextService(
DEFAULT_ALLOWED_APM_ERRORS_BASE_PATTERNS.join()
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*
* 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", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/

export * from './errors/errors_context_service';
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@

export * from './logs';
export * from './traces';
export * from './apm';
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import type { ProfileProviderServices } from '../profile_providers/profile_provi
import { ProfilesManager } from '../profiles_manager';
import { DiscoverEBTManager } from '../../plugin_imports/discover_ebt_manager';
import {
createApmErrorsContextServiceMock,
createLogsContextServiceMock,
createTracesContextServiceMock,
} from '@kbn/discover-utils/src/__mocks__';
Expand Down Expand Up @@ -198,6 +199,7 @@ const createProfileProviderServicesMock = () => {
logsContextService: createLogsContextServiceMock(),
discoverShared: discoverSharedPluginMock.createStartContract(),
tracesContextService: createTracesContextServiceMock(),
apmErrorsContextService: createApmErrorsContextServiceMock(),
core: {
pricing: pricingServiceMock.createStartContract() as ReturnType<
typeof pricingServiceMock.createStartContract
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ import type { DocumentProfileProvider } from '../../../../../profiles';
import type { DocViewerExtensionParams, DocViewerExtension } from '../../../../../types';

export const createGetDocViewer =
(tracesIndexPattern: string): DocumentProfileProvider['profile']['getDocViewer'] =>
(indexes: {
apm: { errors: string; traces: string };
logs: string;
}): DocumentProfileProvider['profile']['getDocViewer'] =>
(prev: (params: DocViewerExtensionParams) => DocViewerExtension) =>
(params: DocViewerExtensionParams) => {
const prevDocViewer = prev(params);
Expand All @@ -30,12 +33,7 @@ export const createGetDocViewer =
}),
order: 0,
component: (props) => {
return (
<UnifiedDocViewerObservabilityTracesSpanOverview
{...props}
tracesIndexPattern={tracesIndexPattern}
/>
);
return <UnifiedDocViewerObservabilityTracesSpanOverview {...props} indexes={indexes} />;
},
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,20 @@ const OBSERVABILITY_TRACES_SPAN_DOCUMENT_PROFILE_ID = 'observability-traces-span

export const createObservabilityTracesSpanDocumentProfileProvider = ({
tracesContextService,
apmErrorsContextService,
logsContextService,
}: ProfileProviderServices): DocumentProfileProvider => ({
isExperimental: true,
profileId: OBSERVABILITY_TRACES_SPAN_DOCUMENT_PROFILE_ID,
restrictedToProductFeature: TRACES_PRODUCT_FEATURE_ID,
profile: {
getDocViewer: createGetDocViewer(tracesContextService.getAllTracesIndexPattern()),
getDocViewer: createGetDocViewer({
apm: {
errors: apmErrorsContextService.getErrorsIndexPattern(),
traces: tracesContextService.getAllTracesIndexPattern(),
},
logs: logsContextService.getAllLogsIndexPattern() ?? '',
}),
},
resolve: ({ record, rootContext }) => {
const isObservabilitySolutionView = rootContext.solutionType === SolutionType.Observability;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ import type { DocumentProfileProvider } from '../../../../..';
import type { DocViewerExtensionParams, DocViewerExtension } from '../../../../../types';

export const createGetDocViewer =
(tracesIndexPattern: string): DocumentProfileProvider['profile']['getDocViewer'] =>
(indexes: {
apm: { errors: string; traces: string };
logs: string;
}): DocumentProfileProvider['profile']['getDocViewer'] =>
(prev: (params: DocViewerExtensionParams) => DocViewerExtension) =>
(params: DocViewerExtensionParams) => {
const prevDocViewer = prev(params);
Expand All @@ -36,7 +39,7 @@ export const createGetDocViewer =
return (
<UnifiedDocViewerObservabilityTracesTransactionOverview
{...props}
tracesIndexPattern={tracesIndexPattern}
indexes={indexes}
/>
);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,20 @@ const OBSERVABILITY_TRACES_TRANSACTION_DOCUMENT_PROFILE_ID =

export const createObservabilityTracesTransactionDocumentProfileProvider = ({
tracesContextService,
apmErrorsContextService,
logsContextService,
}: ProfileProviderServices): DocumentProfileProvider => ({
isExperimental: true,
profileId: OBSERVABILITY_TRACES_TRANSACTION_DOCUMENT_PROFILE_ID,
restrictedToProductFeature: TRACES_PRODUCT_FEATURE_ID,
profile: {
getDocViewer: createGetDocViewer(tracesContextService.getAllTracesIndexPattern() || ''),
getDocViewer: createGetDocViewer({
apm: {
errors: apmErrorsContextService.getErrorsIndexPattern(),
traces: tracesContextService.getAllTracesIndexPattern(),
},
logs: logsContextService.getAllLogsIndexPattern() ?? '',
}),
},
resolve: ({ record, rootContext }) => {
const isObservabilitySolutionView = rootContext.solutionType === SolutionType.Observability;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import {
type LogsContextService,
createTracesContextService,
type TracesContextService,
createApmErrorsContextService,
type ApmErrorsContextService,
} from '@kbn/discover-utils';

import type { LogsDataAccessPluginStart } from '@kbn/logs-data-access-plugin/public';
Expand All @@ -35,6 +37,7 @@ export interface ProfileProviderServices extends DiscoverServices {
*/
logsContextService: LogsContextService;
tracesContextService: TracesContextService;
apmErrorsContextService: ApmErrorsContextService;
}

/**
Expand All @@ -53,5 +56,8 @@ export const createProfileProviderServices = async (
tracesContextService: await createTracesContextService({
apmSourcesAccess: discoverServices.apmSourcesAccess,
}),
apmErrorsContextService: await createApmErrorsContextService({
apmSourcesAccess: discoverServices.apmSourcesAccess,
}),
};
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* 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", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/

import React, { useCallback } from 'react';
import { EuiButtonIcon, EuiWindowEvent } from '@elastic/eui';
export interface ExitFullScreenButtonProps {
ariaLabel: string;
dataTestSubj: string;
onExitFullScreen: () => void;
}

export const ExitFullScreenButton = ({
ariaLabel,
dataTestSubj,
onExitFullScreen,
}: ExitFullScreenButtonProps) => {
const onKeyDown = useCallback(
(event: KeyboardEvent) => {
if (event.key === 'Escape') {
event.preventDefault();

onExitFullScreen();
}
},
[onExitFullScreen]
);
return (
<>
<EuiWindowEvent event="keydown" handler={onKeyDown} />
<EuiButtonIcon
data-test-subj={dataTestSubj}
display="base"
iconSize="m"
iconType="fullScreenExit"
aria-label={ariaLabel}
onClick={onExitFullScreen}
/>
</>
);
};
Loading