mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
* Adds traces overview with mock data (#22628) * Updates service overview snapshots * Adds tests for ManagedTable and ImpactBar * Refactored transaction overview to use new managed table component * Removed jsconfig file in apm * [APM] Distributed tracing - Trace details (waterfall) (#22763) * [APM] Add typescript to waterfall (#23635) * [APM] Migrate get_trace and constants to Typescript (#23634) * [APM] Add types for setup_request (#23762) * [APM] Adds trace overview queries and some refactoring (#23605) * ImpactBar component to align EuiProgress usage for impact bars * Sharing some logic between transaction and trace queries * Typescript support * Quick fix ‘banana’ * [APM] Ensure backwards compatibility for v1 and v2 (#23636) * Make interfaces versioned * Rename eventType to docType * Fixes trace links on traces overview (#24089) * [APM] use react-redux-request (#24117) * Updated yarn lockfile for new yarn version * Updated dependency issues for react-router-dom types * [APM] Display transaction info on span flyout (#24189) * [APM] Display transaction info on span flyout * Brings in real location and url param data for transaction flyout * Converts flyout to TS * Adds query param state for flyouts with ts support * Updates styles and uses EuiTabs for transaction flyout * [APM] Transaction flyout * [APM] Minor docs cleanup (#24325) * [APM] Minor docs cleanup * [APM] Fix issues with v1 spans (#24332) * [APM] Add agent marks (#24361) * [APM] Typescript migration for the transaction endpoints (#24397) * [APM] DT transaction sample header (#24294) Transaction sample header completed * Fixes link target for traces overview to include trans/trace ids as query params * Converts Transaction index file to TS * Adds trace link to sample section * Refactors the trace link and applies it to two usages * Implements transaction sample action context menu * Calculates and implements duration percentage * Re-typed how transaction groups work * Fixes transaction flyout links and context menu * Removes unnecessary ms multiplication * Removes unused commented code * Finalizes infra links * Fixes some type shenanigans
140 lines
2.8 KiB
TypeScript
140 lines
2.8 KiB
TypeScript
/*
|
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
* or more contributor license agreements. Licensed under the Elastic License;
|
|
* you may not use this file except in compliance with the Elastic License.
|
|
*/
|
|
|
|
import _ from 'lodash';
|
|
import React from 'react';
|
|
import styled from 'styled-components';
|
|
|
|
import { StringMap } from '../../../../typings/common';
|
|
import {
|
|
colors,
|
|
fontFamilyCode,
|
|
fontSizes,
|
|
px,
|
|
units
|
|
} from '../../../style/variables';
|
|
|
|
export type KeySorter = (data: StringMap<any>, parentKey?: string) => string[];
|
|
|
|
const Table = styled.table`
|
|
font-family: ${fontFamilyCode};
|
|
font-size: ${fontSizes.small};
|
|
width: 100%;
|
|
`;
|
|
|
|
const Row = styled.tr`
|
|
border-bottom: ${px(1)} solid ${colors.gray4};
|
|
&:last-child {
|
|
border: 0;
|
|
}
|
|
`;
|
|
|
|
const Cell = styled.td`
|
|
vertical-align: top;
|
|
padding: ${px(units.half)} 0;
|
|
|
|
${Row}:first-child> & {
|
|
padding-top: 0;
|
|
}
|
|
|
|
${Row}:last-child> & {
|
|
padding-bottom: 0;
|
|
}
|
|
|
|
&:first-child {
|
|
width: ${px(units.unit * 20)};
|
|
font-weight: bold;
|
|
}
|
|
`;
|
|
|
|
const EmptyValue = styled.span`
|
|
color: ${colors.gray3};
|
|
`;
|
|
|
|
export function FormattedKey({
|
|
k,
|
|
value
|
|
}: {
|
|
k: string;
|
|
value: any;
|
|
}): JSX.Element {
|
|
if (value == null) {
|
|
return <EmptyValue>{k}</EmptyValue>;
|
|
}
|
|
|
|
return <React.Fragment>{k}</React.Fragment>;
|
|
}
|
|
|
|
export function FormattedValue({ value }: { value: any }): JSX.Element {
|
|
if (_.isObject(value)) {
|
|
return <pre>{JSON.stringify(value, null, 4)}</pre>;
|
|
} else if (_.isBoolean(value) || _.isNumber(value)) {
|
|
return <React.Fragment>{String(value)}</React.Fragment>;
|
|
} else if (!value) {
|
|
return <EmptyValue>N/A</EmptyValue>;
|
|
}
|
|
|
|
return <React.Fragment>{value}</React.Fragment>;
|
|
}
|
|
|
|
export function NestedValue({
|
|
parentKey,
|
|
value,
|
|
depth,
|
|
keySorter
|
|
}: {
|
|
value: any;
|
|
depth: number;
|
|
parentKey?: string;
|
|
keySorter?: KeySorter;
|
|
}): JSX.Element {
|
|
if (depth > 0 && _.isObject(value)) {
|
|
return (
|
|
<NestedKeyValueTable
|
|
data={value}
|
|
parentKey={parentKey}
|
|
keySorter={keySorter}
|
|
depth={depth - 1}
|
|
/>
|
|
);
|
|
}
|
|
|
|
return <FormattedValue value={value} />;
|
|
}
|
|
|
|
export function NestedKeyValueTable({
|
|
data,
|
|
parentKey,
|
|
keySorter = Object.keys,
|
|
depth = 0
|
|
}: {
|
|
data: StringMap<any>;
|
|
parentKey?: string;
|
|
keySorter?: KeySorter;
|
|
depth?: number;
|
|
}): JSX.Element {
|
|
return (
|
|
<Table>
|
|
<tbody>
|
|
{keySorter(data, parentKey).map(key => (
|
|
<Row key={key}>
|
|
<Cell>
|
|
<FormattedKey k={key} value={data[key]} />
|
|
</Cell>
|
|
<Cell>
|
|
<NestedValue
|
|
parentKey={key}
|
|
value={data[key]}
|
|
keySorter={keySorter}
|
|
depth={depth}
|
|
/>
|
|
</Cell>
|
|
</Row>
|
|
))}
|
|
</tbody>
|
|
</Table>
|
|
);
|
|
}
|