Skip to content

Commit

Permalink
Remove service logs endpoint (#135885)
Browse files Browse the repository at this point in the history
  • Loading branch information
MiriamAparicio authored Jul 7, 2022
1 parent d4139a1 commit ef06d41
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 137 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@ describe('service logs', () => {
expect(
getInfrastructureKQLFilter(
{
serviceInfrastructure: {
containerIds: [],
hostNames: [],
},
containerIds: [],
hostNames: [],
podNames: [],
},
serviceName
)
Expand All @@ -28,10 +27,9 @@ describe('service logs', () => {
expect(
getInfrastructureKQLFilter(
{
serviceInfrastructure: {
containerIds: ['foo', 'bar'],
hostNames: ['baz', `quz`],
},
containerIds: ['foo', 'bar'],
hostNames: ['baz', `quz`],
podNames: [],
},
serviceName
)
Expand All @@ -44,10 +42,9 @@ describe('service logs', () => {
expect(
getInfrastructureKQLFilter(
{
serviceInfrastructure: {
containerIds: [],
hostNames: ['baz', `quz`],
},
containerIds: [],
hostNames: ['baz', `quz`],
podNames: [],
},
serviceName
)
Expand Down
13 changes: 5 additions & 8 deletions x-pack/plugins/apm/public/components/app/service_logs/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export function ServiceLogs() {
(callApmApi) => {
if (start && end) {
return callApmApi(
'GET /internal/apm/services/{serviceName}/infrastructure_attributes_for_logs',
'GET /internal/apm/services/{serviceName}/infrastructure_attributes',
{
params: {
path: { serviceName },
Expand All @@ -55,10 +55,7 @@ export function ServiceLogs() {
);

const noInfrastructureData = useMemo(() => {
return (
isEmpty(data?.serviceInfrastructure?.containerIds) &&
isEmpty(data?.serviceInfrastructure?.hostNames)
);
return isEmpty(data?.containerIds) && isEmpty(data?.hostNames);
}, [data]);

if (status === FETCH_STATUS.LOADING) {
Expand Down Expand Up @@ -98,12 +95,12 @@ export function ServiceLogs() {

export const getInfrastructureKQLFilter = (
data:
| APIReturnType<'GET /internal/apm/services/{serviceName}/infrastructure_attributes_for_logs'>
| APIReturnType<'GET /internal/apm/services/{serviceName}/infrastructure_attributes'>
| undefined,
serviceName: string
) => {
const containerIds = data?.serviceInfrastructure?.containerIds ?? [];
const hostNames = data?.serviceInfrastructure?.hostNames ?? [];
const containerIds = data?.containerIds ?? [];
const hostNames = data?.hostNames ?? [];

const infraAttributes = containerIds.length
? containerIds.map((id) => `${CONTAINER_ID}: "${id}"`)
Expand Down

This file was deleted.

39 changes: 0 additions & 39 deletions x-pack/plugins/apm/server/routes/services/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import { getServiceTransactionTypes } from './get_service_transaction_types';
import { getThroughput } from './get_throughput';
import { getServiceProfilingStatistics } from './profiling/get_service_profiling_statistics';
import { getServiceProfilingTimeline } from './profiling/get_service_profiling_timeline';
import { getServiceInfrastructure } from './get_service_infrastructure';
import { withApmSpan } from '../../utils/with_apm_span';
import { createApmServerRoute } from '../apm_routes/create_apm_server_route';
import {
Expand Down Expand Up @@ -1130,43 +1129,6 @@ const serviceProfilingStatisticsRoute = createApmServerRoute({
},
});

// TODO: remove this endpoint in favour of
const serviceInfrastructureRoute = createApmServerRoute({
endpoint:
'GET /internal/apm/services/{serviceName}/infrastructure_attributes_for_logs',
params: t.type({
path: t.type({
serviceName: t.string,
}),
query: t.intersection([kueryRt, rangeRt, environmentRt]),
}),
options: { tags: ['access:apm'] },
handler: async (
resources
): Promise<{
serviceInfrastructure: { containerIds: string[]; hostNames: string[] };
}> => {
const setup = await setupRequest(resources);

const { params } = resources;

const {
path: { serviceName },
query: { environment, kuery, start, end },
} = params;

const serviceInfrastructure = await getServiceInfrastructure({
setup,
serviceName,
environment,
kuery,
start,
end,
});
return { serviceInfrastructure };
},
});

const serviceAnomalyChartsRoute = createApmServerRoute({
endpoint: 'GET /internal/apm/services/{serviceName}/anomaly_charts',
params: t.type({
Expand Down Expand Up @@ -1298,7 +1260,6 @@ export const serviceRouteRepository = {
...serviceDependenciesBreakdownRoute,
...serviceProfilingTimelineRoute,
...serviceProfilingStatisticsRoute,
...serviceInfrastructureRoute,
...serviceAnomalyChartsRoute,
...sortedAndFilteredServicesRoute,
};

0 comments on commit ef06d41

Please sign in to comment.