Skip to content

Commit

Permalink
Merge branch 'master' into cti-fix-cypress
Browse files Browse the repository at this point in the history
  • Loading branch information
kibanamachine authored Aug 18, 2021
2 parents 1e23668 + f21115f commit 88a9290
Show file tree
Hide file tree
Showing 121 changed files with 3,057 additions and 773 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export interface EmbeddableEditorState
| --- | --- | --- |
| [embeddableId](./kibana-plugin-plugins-embeddable-public.embeddableeditorstate.embeddableid.md) | <code>string</code> | |
| [originatingApp](./kibana-plugin-plugins-embeddable-public.embeddableeditorstate.originatingapp.md) | <code>string</code> | |
| [originatingPath](./kibana-plugin-plugins-embeddable-public.embeddableeditorstate.originatingpath.md) | <code>string</code> | |
| [searchSessionId](./kibana-plugin-plugins-embeddable-public.embeddableeditorstate.searchsessionid.md) | <code>string</code> | Pass current search session id when navigating to an editor, Editors could use it continue previous search session |
| [valueInput](./kibana-plugin-plugins-embeddable-public.embeddableeditorstate.valueinput.md) | <code>EmbeddableInput</code> | |

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-plugins-embeddable-public](./kibana-plugin-plugins-embeddable-public.md) &gt; [EmbeddableEditorState](./kibana-plugin-plugins-embeddable-public.embeddableeditorstate.md) &gt; [originatingPath](./kibana-plugin-plugins-embeddable-public.embeddableeditorstate.originatingpath.md)

## EmbeddableEditorState.originatingPath property

<b>Signature:</b>

```typescript
originatingPath?: string;
```
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
"dependencies": {
"@elastic/apm-rum": "^5.8.0",
"@elastic/apm-rum-react": "^1.2.11",
"@elastic/charts": "33.2.2",
"@elastic/charts": "34.0.0",
"@elastic/datemath": "link:bazel-bin/packages/elastic-datemath",
"@elastic/elasticsearch": "npm:@elastic/elasticsearch-canary@^8.0.0-canary.17",
"@elastic/ems-client": "7.15.0",
Expand Down Expand Up @@ -379,6 +379,7 @@
"redux-saga": "^1.1.3",
"redux-thunk": "^2.3.0",
"redux-thunks": "^1.0.0",
"remark-stringify": "^9.0.0",
"regenerator-runtime": "^0.13.3",
"request": "^2.88.0",
"require-in-the-middle": "^5.0.2",
Expand Down
1 change: 1 addition & 0 deletions src/plugins/embeddable/public/lib/state_transfer/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export const EMBEDDABLE_EDITOR_STATE_KEY = 'embeddable_editor_state';
*/
export interface EmbeddableEditorState {
originatingApp: string;
originatingPath?: string;
embeddableId?: string;
valueInput?: EmbeddableInput;

Expand Down
2 changes: 2 additions & 0 deletions src/plugins/embeddable/public/public.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,8 @@ export interface EmbeddableEditorState {
embeddableId?: string;
// (undocumented)
originatingApp: string;
// (undocumented)
originatingPath?: string;
searchSessionId?: string;
// (undocumented)
valueInput?: EmbeddableInput;
Expand Down
1 change: 1 addition & 0 deletions src/plugins/saved_objects/public/finder/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
export {
SavedObjectMetaData,
SavedObjectFinderUi,
SavedObjectFinderUiProps,
getSavedObjectFinder,
} from './saved_object_finder';
7 changes: 6 additions & 1 deletion src/plugins/saved_objects/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ export {
SaveResult,
showSaveModal,
} from './save_modal';
export { getSavedObjectFinder, SavedObjectFinderUi, SavedObjectMetaData } from './finder';
export {
getSavedObjectFinder,
SavedObjectFinderUi,
SavedObjectFinderUiProps,
SavedObjectMetaData,
} from './finder';
export {
SavedObjectLoader,
SavedObjectLoaderFindOptions,
Expand Down
8 changes: 6 additions & 2 deletions x-pack/examples/embedded_lens_example/public/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,9 @@ export const App = (props: {
timeRange: time,
attributes: getLensAttributes(props.defaultIndexPattern!, color),
},
true
{
openInNewTab: true,
}
);
// eslint-disable-next-line no-bitwise
const newColor = '#' + ((Math.random() * 0xffffff) << 0).toString(16);
Expand All @@ -195,7 +197,9 @@ export const App = (props: {
timeRange: time,
attributes: getLensAttributes(props.defaultIndexPattern!, color),
},
false
{
openInNewTab: false,
}
);
}}
>
Expand Down
4 changes: 4 additions & 0 deletions x-pack/plugins/apm/common/agent_name.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,7 @@ export function isIosAgentName(agentName?: string) {
const lowercased = agentName && agentName.toLowerCase();
return lowercased === 'ios/swift' || lowercased === 'opentelemetry/swift';
}

export function isJRubyAgent(agentName?: string, runtimeName?: string) {
return agentName === 'ruby' && runtimeName?.toLowerCase() === 'jruby';
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { UrlParamsProvider } from '../../../context/url_params_context/url_param
import { IUrlParams } from '../../../context/url_params_context/types';
import * as useFetcherHook from '../../../hooks/use_fetcher';
import * as useServiceTransactionTypesHook from '../../../context/apm_service/use_service_transaction_types_fetcher';
import * as useServiceAgentNameHook from '../../../context/apm_service/use_service_agent_name_fetcher';
import * as useServiceAgentNameHook from '../../../context/apm_service/use_service_agent_fetcher';
import {
disableConsoleWarning,
renderWithTheme,
Expand Down Expand Up @@ -52,9 +52,10 @@ function setup({

// mock agent
jest
.spyOn(useServiceAgentNameHook, 'useServiceAgentNameFetcher')
.spyOn(useServiceAgentNameHook, 'useServiceAgentFetcher')
.mockReturnValue({
agentName: 'nodejs',
runtimeName: 'node',
error: undefined,
status: useFetcherHook.FETCH_STATUS.SUCCESS,
});
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/*
* 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 { isMetricsTabHidden, isJVMsTabHidden } from './';

describe('APM service template', () => {
describe('isMetricsTabHidden', () => {
describe('hides metrics tab', () => {
[
{ agentName: undefined },
{ agentName: 'js-base' },
{ agentName: 'rum-js' },
{ agentName: 'opentelemetry/webjs' },
{ agentName: 'java' },
{ agentName: 'opentelemetry/java' },
{ agentName: 'ios/swift' },
{ agentName: 'opentelemetry/swift' },
{ agentName: 'ruby', runtimeName: 'jruby' },
].map((input) => {
it(`when input ${JSON.stringify(input)}`, () => {
expect(isMetricsTabHidden(input)).toBeTruthy();
});
});
});
describe('shows metrics tab', () => {
[
{ agentName: 'ruby', runtimeName: 'ruby' },
{ agentName: 'ruby' },
{ agentName: 'dotnet' },
{ agentName: 'go' },
{ agentName: 'nodejs' },
{ agentName: 'php' },
{ agentName: 'python' },
].map((input) => {
it(`when input ${JSON.stringify(input)}`, () => {
expect(isMetricsTabHidden(input)).toBeFalsy();
});
});
});
});
describe('isJVMsTabHidden', () => {
describe('hides JVMs tab', () => {
[
{ agentName: undefined },
{ agentName: 'ruby', runtimeName: 'ruby' },
{ agentName: 'ruby' },
{ agentName: 'dotnet' },
{ agentName: 'go' },
{ agentName: 'nodejs' },
{ agentName: 'php' },
{ agentName: 'python' },
].map((input) => {
it(`when input ${JSON.stringify(input)}`, () => {
expect(isJVMsTabHidden(input)).toBeTruthy();
});
});
});
describe('shows JVMs tab', () => {
[
{ agentName: 'java' },
{ agentName: 'opentelemetry/java' },
{ agentName: 'ruby', runtimeName: 'jruby' },
].map((input) => {
it(`when input ${JSON.stringify(input)}`, () => {
expect(isJVMsTabHidden(input)).toBeFalsy();
});
});
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import React from 'react';
import {
isIosAgentName,
isJavaAgentName,
isJRubyAgent,
isRumAgentName,
} from '../../../../../common/agent_name';
import { useApmPluginContext } from '../../../../context/apm_plugin/use_apm_plugin_context';
Expand Down Expand Up @@ -118,8 +119,34 @@ function TemplateWithContext({
);
}

export function isMetricsTabHidden({
agentName,
runtimeName,
}: {
agentName?: string;
runtimeName?: string;
}) {
return (
!agentName ||
isRumAgentName(agentName) ||
isJavaAgentName(agentName) ||
isIosAgentName(agentName) ||
isJRubyAgent(agentName, runtimeName)
);
}

export function isJVMsTabHidden({
agentName,
runtimeName,
}: {
agentName?: string;
runtimeName?: string;
}) {
return !(isJavaAgentName(agentName) || isJRubyAgent(agentName, runtimeName));
}

function useTabs({ selectedTab }: { selectedTab: Tab['key'] }) {
const { agentName } = useApmServiceContext();
const { agentName, runtimeName } = useApmServiceContext();
const { config } = useApmPluginContext();

const router = useApmRouter();
Expand Down Expand Up @@ -189,11 +216,7 @@ function useTabs({ selectedTab }: { selectedTab: Tab['key'] }) {
label: i18n.translate('xpack.apm.serviceDetails.metricsTabLabel', {
defaultMessage: 'Metrics',
}),
hidden:
!agentName ||
isRumAgentName(agentName) ||
isJavaAgentName(agentName) ||
isIosAgentName(agentName),
hidden: isMetricsTabHidden({ agentName, runtimeName }),
},
{
key: 'nodes',
Expand All @@ -204,7 +227,7 @@ function useTabs({ selectedTab }: { selectedTab: Tab['key'] }) {
label: i18n.translate('xpack.apm.serviceDetails.nodesTabLabel', {
defaultMessage: 'JVMs',
}),
hidden: !isJavaAgentName(agentName),
hidden: isJVMsTabHidden({ agentName, runtimeName }),
},
{
key: 'service-map',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
RecursivePartial,
ScaleType,
Settings,
LineAnnotationStyle,
} from '@elastic/charts';

import euiVars from '@elastic/eui/dist/eui_theme_light.json';
Expand Down Expand Up @@ -91,7 +92,7 @@ interface CorrelationsChartProps {
selection?: [number, number];
}

const getAnnotationsStyle = (color = 'gray') => ({
const getAnnotationsStyle = (color = 'gray'): LineAnnotationStyle => ({
line: {
strokeWidth: 1,
stroke: color,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
TRANSACTION_REQUEST,
} from '../../../common/transaction_types';
import { useServiceTransactionTypesFetcher } from './use_service_transaction_types_fetcher';
import { useServiceAgentNameFetcher } from './use_service_agent_name_fetcher';
import { useServiceAgentFetcher } from './use_service_agent_fetcher';
import { APIReturnType } from '../../services/rest/createCallApmApi';
import { useServiceAlertsFetcher } from './use_service_alerts_fetcher';
import { useApmParams } from '../../hooks/use_apm_params';
Expand All @@ -28,6 +28,7 @@ export const APMServiceContext = createContext<{
transactionType?: string;
transactionTypes: string[];
alerts: APMServiceAlert[];
runtimeName?: string;
}>({ serviceName: '', transactionTypes: [], alerts: [] });

export function ApmServiceContextProvider({
Expand All @@ -40,7 +41,7 @@ export function ApmServiceContextProvider({
query,
} = useApmParams('/services/:serviceName');

const { agentName } = useServiceAgentNameFetcher(serviceName);
const { agentName, runtimeName } = useServiceAgentFetcher(serviceName);

const transactionTypes = useServiceTransactionTypesFetcher(serviceName);

Expand All @@ -65,6 +66,7 @@ export function ApmServiceContextProvider({
transactionType,
transactionTypes,
alerts,
runtimeName,
}}
children={children}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,19 @@
import { useFetcher } from '../../hooks/use_fetcher';
import { useUrlParams } from '../url_params_context/use_url_params';

export function useServiceAgentNameFetcher(serviceName?: string) {
const INITIAL_STATE = {
agentName: undefined,
runtimeName: undefined,
};

export function useServiceAgentFetcher(serviceName?: string) {
const { urlParams } = useUrlParams();
const { start, end } = urlParams;
const { data, error, status } = useFetcher(
const { data = INITIAL_STATE, error, status } = useFetcher(
(callApmApi) => {
if (serviceName && start && end) {
return callApmApi({
endpoint: 'GET /api/apm/services/{serviceName}/agent_name',
endpoint: 'GET /api/apm/services/{serviceName}/agent',
params: {
path: { serviceName },
query: { start, end },
Expand All @@ -26,5 +31,5 @@ export function useServiceAgentNameFetcher(serviceName?: string) {
[serviceName, start, end]
);

return { agentName: data?.agentName, status, error };
return { ...data, status, error };
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 88a9290

Please sign in to comment.