Skip to content

Commit d33db45

Browse files
Merge branch 'main' into reverting-memory-fix-for-cypress
2 parents 4dda4b2 + 4c07f9c commit d33db45

18 files changed

Lines changed: 235 additions & 84 deletions

File tree

.github/workflows/create-deploy-tag.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@ jobs:
102102
"<https://github.com/elastic/kibana/actions/runs/${{ github.run_id }}|GitHub Workflow run>",
103103
"<https://buildkite.com/elastic/kibana-serverless-release/builds?branch=${{ env.TAG_NAME }}|Kibana Serverless Release pipeline>",
104104
"<https://argo-workflows.us-central1.gcp.qa.cld.elstc.co/workflows?label=hash%3D${{ env.COMMIT }}|Argo Workflow> (use Elastic Cloud Staging VPN)",
105-
"<https://overview.qa.cld.elstc.co/app/dashboards#/view/serverless-tooling-gpctl-deployment-status?_g=(refreshInterval:(pause:!t,value:0),time:(from:now-1d,to:now))&service-name=kibana&_a=(controlGroupInput:(chainingSystem:HIERARCHICAL,controlStyle:oneLine,ignoreParentSettings:(ignoreFilters:!f,ignoreQuery:!f,ignoreTimerange:!f,ignoreValidations:!f),panels:('18201b8e-3aae-4459-947d-21e007b6a3a5':(explicitInput:(dataViewId:'serverless.logs-*',enhancements:(),fieldName:commit-hash,id:'18201b8e-3aae-4459-947d-21e007b6a3a5',selectedOptions:!('${{ env.COMMIT }}'),title:commit-hash),grow:!t,order:1,type:optionsListControl,width:medium),'41060e65-ce4c-414e-b8cf-492ccb19245f':(explicitInput:(dataViewId:'serverless.logs-*',enhancements:(),fieldName:service-name,id:'41060e65-ce4c-414e-b8cf-492ccb19245f',selectedOptions:!(kibana),title:service-name),grow:!t,order:0,type:optionsListControl,width:medium),ed96828e-efe9-43ad-be3f-0e04218f79af:(explicitInput:(dataViewId:'serverless.logs-*',enhancements:(),fieldName:to-env,id:ed96828e-efe9-43ad-be3f-0e04218f79af,selectedOptions:!(qa),title:to-env),grow:!t,order:2,type:optionsListControl,width:medium))))|GPCTL Deployment Status dashboard>",
105+
"<https://overview.qa.cld.elstc.co/app/dashboards#/view/serverless-tooling-gpctl-deployment-status?_g=(refreshInterval:(pause:!t,value:0),time:(from:now-1d,to:now))&service-name=kibana&_a=(controlGroupInput:(chainingSystem:HIERARCHICAL,controlStyle:oneLine,ignoreParentSettings:(ignoreFilters:!f,ignoreQuery:!f,ignoreTimerange:!f,ignoreValidations:!f),panels:('18201b8e-3aae-4459-947d-21e007b6a3a5':(explicitInput:(dataViewId:'serverless.logs-*',enhancements:(),fieldName:commit-hash,id:'18201b8e-3aae-4459-947d-21e007b6a3a5',selectedOptions:!('${{ env.COMMIT }}'),title:commit-hash),grow:!t,order:1,type:optionsListControl,width:medium),'41060e65-ce4c-414e-b8cf-492ccb19245f':(explicitInput:(dataViewId:'serverless.logs-*',enhancements:(),fieldName:service-name,id:'41060e65-ce4c-414e-b8cf-492ccb19245f',selectedOptions:!(kibana),title:service-name),grow:!t,order:0,type:optionsListControl,width:medium),ed96828e-efe9-43ad-be3f-0e04218f79af:(explicitInput:(dataViewId:'serverless.logs-*',enhancements:(),fieldName:to-env,id:ed96828e-efe9-43ad-be3f-0e04218f79af,selectedOptions:!(qa),title:to-env),grow:!t,order:2,type:optionsListControl,width:medium))))|GPCTL Deployment Status dashboard for nonprod >",
106+
"<https://overview.elastic-cloud.com/app/dashboards#/view/serverless-tooling-gpctl-deployment-status?_g=(refreshInterval:(pause:!t,value:0),time:(from:now-1d,to:now))&service-name=kibana&_a=(controlGroupInput:(chainingSystem:HIERARCHICAL,controlStyle:oneLine,ignoreParentSettings:(ignoreFilters:!f,ignoreQuery:!f,ignoreTimerange:!f,ignoreValidations:!f),panels:('18201b8e-3aae-4459-947d-21e007b6a3a5':(explicitInput:(dataViewId:'serverless.logs-*',enhancements:(),fieldName:commit-hash,id:'18201b8e-3aae-4459-947d-21e007b6a3a5',selectedOptions:!('${{ env.COMMIT }}'),title:commit-hash),grow:!t,order:1,type:optionsListControl,width:medium),'41060e65-ce4c-414e-b8cf-492ccb19245f':(explicitInput:(dataViewId:'serverless.logs-*',enhancements:(),fieldName:service-name,id:'41060e65-ce4c-414e-b8cf-492ccb19245f',selectedOptions:!(kibana),title:service-name),grow:!t,order:0,type:optionsListControl,width:medium),ed96828e-efe9-43ad-be3f-0e04218f79af:(explicitInput:(dataViewId:'serverless.logs-*',enhancements:(),fieldName:to-env,id:ed96828e-efe9-43ad-be3f-0e04218f79af,selectedOptions:!(production),title:to-env),grow:!t,order:2,type:optionsListControl,width:medium))))|GPCTL Deployment Status dashboard>",
106107
"<https://buildkite.com/elastic/kibana-tests/builds?branch=main|Quality Gate pipeline>"
107108
]
108109
- name: Post Slack failure message

x-pack/plugins/apm/public/components/app/transaction_details/waterfall_with_summary/transaction_tabs.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ function TimelineTabContent({
154154
}
155155

156156
function MetadataTabContent({ transaction }: { transaction: Transaction }) {
157-
return <TransactionMetadata transactionId={transaction.transaction.id} />;
157+
return <TransactionMetadata transaction={transaction} />;
158158
}
159159

160160
function LogsTabContent({

x-pack/plugins/apm/public/components/app/transaction_details/waterfall_with_summary/waterfall_container/waterfall/span_flyout/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ function SpanFlyoutBody({
228228
content: (
229229
<Fragment>
230230
<EuiSpacer size="m" />
231-
<SpanMetadata spanId={span.span.id} />
231+
<SpanMetadata span={span} />
232232
</Fragment>
233233
),
234234
},

x-pack/plugins/apm/public/components/app/transaction_details/waterfall_with_summary/waterfall_container/waterfall/transaction_flyout/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ function TransactionFlyoutBody({
141141
content: (
142142
<>
143143
<EuiSpacer size="m" />
144-
<TransactionMetadata transactionId={transaction.transaction.id} />
144+
<TransactionMetadata transaction={transaction} />
145145
</>
146146
),
147147
},

x-pack/plugins/apm/public/components/shared/metadata_table/error_metadata/index.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,15 @@ export function ErrorMetadata({ error }: Props) {
2727
processorEvent: ProcessorEvent.error,
2828
id: error.error.id,
2929
},
30+
query: {
31+
start: error['@timestamp'],
32+
end: error['@timestamp'],
33+
},
3034
},
3135
}
3236
);
3337
},
34-
[error.error.id]
38+
[error]
3539
);
3640

3741
const sections = useMemo(

x-pack/plugins/apm/public/components/shared/metadata_table/span_metadata/index.tsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,16 @@
77

88
import React, { useMemo } from 'react';
99
import { ProcessorEvent } from '@kbn/observability-plugin/common';
10+
import { Span } from '../../../../../typings/es_schemas/ui/span';
1011
import { getSectionsFromFields } from '../helper';
1112
import { MetadataTable } from '..';
1213
import { FETCH_STATUS, useFetcher } from '../../../../hooks/use_fetcher';
1314

1415
interface Props {
15-
spanId: string;
16+
span: Span;
1617
}
1718

18-
export function SpanMetadata({ spanId }: Props) {
19+
export function SpanMetadata({ span }: Props) {
1920
const { data: spanEvent, status } = useFetcher(
2021
(callApmApi) => {
2122
return callApmApi(
@@ -24,13 +25,17 @@ export function SpanMetadata({ spanId }: Props) {
2425
params: {
2526
path: {
2627
processorEvent: ProcessorEvent.span,
27-
id: spanId,
28+
id: span.span.id,
29+
},
30+
query: {
31+
start: span['@timestamp'],
32+
end: span['@timestamp'],
2833
},
2934
},
3035
}
3136
);
3237
},
33-
[spanId]
38+
[span]
3439
);
3540

3641
const sections = useMemo(

x-pack/plugins/apm/public/components/shared/metadata_table/transaction_metadata/index.tsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,16 @@
77

88
import React, { useMemo } from 'react';
99
import { ProcessorEvent } from '@kbn/observability-plugin/common';
10+
import { Transaction } from '../../../../../typings/es_schemas/ui/transaction';
1011
import { getSectionsFromFields } from '../helper';
1112
import { MetadataTable } from '..';
1213
import { FETCH_STATUS, useFetcher } from '../../../../hooks/use_fetcher';
1314

1415
interface Props {
15-
transactionId: string;
16+
transaction: Transaction;
1617
}
1718

18-
export function TransactionMetadata({ transactionId }: Props) {
19+
export function TransactionMetadata({ transaction }: Props) {
1920
const { data: transactionEvent, status } = useFetcher(
2021
(callApmApi) => {
2122
return callApmApi(
@@ -24,13 +25,17 @@ export function TransactionMetadata({ transactionId }: Props) {
2425
params: {
2526
path: {
2627
processorEvent: ProcessorEvent.transaction,
27-
id: transactionId,
28+
id: transaction.transaction.id,
29+
},
30+
query: {
31+
start: transaction['@timestamp'],
32+
end: transaction['@timestamp'],
2833
},
2934
},
3035
}
3136
);
3237
},
33-
[transactionId]
38+
[transaction]
3439
);
3540

3641
const sections = useMemo(

x-pack/plugins/apm/server/plugin.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
Logger,
1212
Plugin,
1313
PluginInitializerContext,
14+
SavedObjectsClient,
1415
} from '@kbn/core/server';
1516
import { isEmpty, mapValues } from 'lodash';
1617
import { Dataset } from '@kbn/rule-registry-plugin/server';
@@ -48,6 +49,7 @@ import { scheduleSourceMapMigration } from './routes/source_maps/schedule_source
4849
import { createApmSourceMapIndexTemplate } from './routes/source_maps/create_apm_source_map_index_template';
4950
import { addApiKeysToEveryPackagePolicyIfMissing } from './routes/fleet/api_keys/add_api_keys_to_policies_if_missing';
5051
import { apmTutorialCustomIntegration } from '../common/tutorial/tutorials';
52+
import { APM_STATIC_DATA_VIEW_ID } from '../common/data_view_constants';
5153

5254
export class APMPlugin
5355
implements
@@ -119,6 +121,26 @@ export class APMPlugin
119121
],
120122
});
121123

124+
// ensure that the APM data view is globally available
125+
getCoreStart()
126+
.then(async (coreStart) => {
127+
const soClient = new SavedObjectsClient(
128+
coreStart.savedObjects.createInternalRepository()
129+
);
130+
131+
await soClient.updateObjectsSpaces(
132+
[{ id: APM_STATIC_DATA_VIEW_ID, type: 'index-pattern' }],
133+
['*'],
134+
[]
135+
);
136+
})
137+
.catch((e) => {
138+
this.logger?.error(
139+
'Failed to make APM data view available globally',
140+
e
141+
);
142+
});
143+
122144
const resourcePlugins = mapValues(plugins, (value, key) => {
123145
return {
124146
setup: value,

x-pack/plugins/apm/server/routes/event_metadata/get_event_metadata.ts

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
* 2.0.
66
*/
77

8-
import { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
98
import { ProcessorEvent } from '@kbn/observability-plugin/common';
9+
import { rangeQuery } from '@kbn/observability-plugin/server';
1010
import {
1111
ERROR_ID,
1212
SPAN_ID,
@@ -18,43 +18,26 @@ export async function getEventMetadata({
1818
apmEventClient,
1919
processorEvent,
2020
id,
21+
start,
22+
end,
2123
}: {
2224
apmEventClient: APMEventClient;
2325
processorEvent: ProcessorEvent;
2426
id: string;
27+
start: number;
28+
end: number;
2529
}) {
26-
const filter: QueryDslQueryContainer[] = [];
27-
28-
switch (processorEvent) {
29-
case ProcessorEvent.error:
30-
filter.push({
31-
term: { [ERROR_ID]: id },
32-
});
33-
break;
34-
35-
case ProcessorEvent.transaction:
36-
filter.push({
37-
term: {
38-
[TRANSACTION_ID]: id,
39-
},
40-
});
41-
break;
42-
43-
case ProcessorEvent.span:
44-
filter.push({
45-
term: { [SPAN_ID]: id },
46-
});
47-
break;
48-
}
49-
30+
const fieldName = getFieldName(processorEvent);
5031
const response = await apmEventClient.search('get_event_metadata', {
5132
apm: {
5233
events: [processorEvent],
5334
},
5435
body: {
5536
track_total_hits: false,
5637
query: {
57-
bool: { filter },
38+
bool: {
39+
filter: [...rangeQuery(start, end), { term: { [fieldName]: id } }],
40+
},
5841
},
5942
size: 1,
6043
_source: false,
@@ -65,3 +48,19 @@ export async function getEventMetadata({
6548

6649
return response.hits.hits[0].fields;
6750
}
51+
52+
function getFieldName(processorEvent: ProcessorEvent) {
53+
switch (processorEvent) {
54+
case ProcessorEvent.error:
55+
return ERROR_ID;
56+
57+
case ProcessorEvent.transaction:
58+
return TRANSACTION_ID;
59+
60+
case ProcessorEvent.span:
61+
return SPAN_ID;
62+
63+
default:
64+
throw new Error('Unknown processor event');
65+
}
66+
}

x-pack/plugins/apm/server/routes/event_metadata/route.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { createApmServerRoute } from '../apm_routes/create_apm_server_route';
1010
import { getEventMetadata } from './get_event_metadata';
1111
import { processorEventRt } from '../../../common/processor_event';
1212
import { getApmEventClient } from '../../lib/helpers/get_apm_event_client';
13+
import { rangeRt } from '../default_api_types';
1314

1415
const eventMetadataRoute = createApmServerRoute({
1516
endpoint: 'GET /internal/apm/event_metadata/{processorEvent}/{id}',
@@ -19,20 +20,22 @@ const eventMetadataRoute = createApmServerRoute({
1920
processorEvent: processorEventRt,
2021
id: t.string,
2122
}),
23+
query: rangeRt,
2224
}),
2325
handler: async (
2426
resources
2527
): Promise<{ metadata: Partial<Record<string, unknown[]>> }> => {
2628
const apmEventClient = await getApmEventClient(resources);
27-
28-
const {
29-
path: { processorEvent, id },
30-
} = resources.params;
29+
const { params } = resources;
30+
const { start, end } = params.query;
31+
const { processorEvent, id } = params.path;
3132

3233
const metadata = await getEventMetadata({
3334
apmEventClient,
3435
processorEvent,
3536
id,
37+
start,
38+
end,
3639
});
3740

3841
return {

0 commit comments

Comments
 (0)