Skip to content

Commit

Permalink
[APM] Show tags in span details
Browse files Browse the repository at this point in the history
  • Loading branch information
ogupte committed Nov 29, 2018
1 parent 5550364 commit d46c3ab
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,20 @@
*/

import {
EuiBasicTable,
EuiFlexGroup,
EuiFlexItem,
EuiFlyout,
EuiFlyoutBody,
EuiFlyoutHeader,
EuiHorizontalRule,
EuiPortal,
// @ts-ignore otherwise TS complains "Module ''@elastic/eui'' has no exported member 'EuiTabbedContent'"
EuiTabbedContent,
EuiTitle
} from '@elastic/eui';
import { get } from 'lodash';
import React from 'react';
import { get, keys } from 'lodash';
import React, { Fragment } from 'react';
import styled from 'styled-components';

// @ts-ignore
Expand All @@ -42,6 +45,10 @@ const StackTraceContainer = styled.div`
margin-top: ${px(unit)};
`;

const TagName = styled.div`
font-weight: bold;
`;

function getDiscoverQuery(span: Span) {
return {
_a: {
Expand Down Expand Up @@ -77,6 +84,7 @@ export function SpanFlyout({
const codeLanguage: string = get(span, SERVICE_LANGUAGE_NAME);
const dbContext = span.context.db;
const httpContext = span.context.http;
const tagContext = span.context.tags;

return (
<EuiPortal>
Expand All @@ -101,11 +109,47 @@ export function SpanFlyout({
<EuiHorizontalRule />
<StickySpanProperties span={span} totalDuration={totalDuration} />
<EuiHorizontalRule />
<HttpContext httpContext={httpContext} />
<DatabaseContext dbContext={dbContext} />
<StackTraceContainer>
<Stacktrace stackframes={stackframes} codeLanguage={codeLanguage} />
</StackTraceContainer>
<EuiTabbedContent
tabs={[
{
id: 'stack-trace',
name: 'Strack Trace',
content: (
<Fragment>
<HttpContext httpContext={httpContext} />
<DatabaseContext dbContext={dbContext} />
<StackTraceContainer>
<Stacktrace
stackframes={stackframes}
codeLanguage={codeLanguage}
/>
</StackTraceContainer>
</Fragment>
)
},
{
id: 'tags',
name: 'Tags',
content: (
<Fragment>
<EuiBasicTable
columns={[
{
field: 'key',
render: (key: string) => <TagName>{key}</TagName>
},
{ field: 'value' }
]}
items={keys(tagContext).map(key => ({
key,
value: get(tagContext, key)
}))}
/>
</Fragment>
)
}
]}
/>
</EuiFlyoutBody>
</EuiFlyout>
</EuiPortal>
Expand Down
5 changes: 5 additions & 0 deletions x-pack/plugins/apm/typings/Span.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,14 @@ export interface HttpContext {
url?: string;
}

export interface TagsContext {
[key: string]: string;
}

interface Context {
db?: DbContext;
http?: HttpContext;
tags?: TagsContext;
service: ContextService;
[key: string]: unknown;
}
Expand Down

0 comments on commit d46c3ab

Please sign in to comment.