Skip to content

Commit

Permalink
[APM] fixes elastic#20145 by displaying span.context.http.url in the …
Browse files Browse the repository at this point in the history
…span details flyout (elastic#26238)
  • Loading branch information
ogupte committed Nov 27, 2018
1 parent f795b93 commit c142031
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* 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 React, { Fragment } from 'react';
import styled from 'styled-components';
import {
borderRadius,
colors,
fontFamilyCode,
px,
unit,
units
} from '../../../../../../../style/variables';

import { EuiTitle } from '@elastic/eui';
import { HttpContext } from '../../../../../../../../typings/Span';

const DatabaseStatement = styled.div`
margin-top: ${px(unit)};
padding: ${px(units.half)} ${px(unit)};
background: ${colors.gray5};
border-radius: ${borderRadius};
border: 1px solid ${colors.gray4};
font-family: ${fontFamilyCode};
`;

interface Props {
httpContext?: HttpContext;
}

export function HttpContext({ httpContext }: Props) {
if (!httpContext || !httpContext.url) {
return null;
}

return (
<Fragment>
<EuiTitle size="xs">
<h3>HTTP URL</h3>
</EuiTitle>
<DatabaseStatement>{httpContext.url}</DatabaseStatement>
</Fragment>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import { px, unit } from '../../../../../../../style/variables';
import Stacktrace from '../../../../../../shared/Stacktrace';

import { DatabaseContext } from './DatabaseContext';
import { HttpContext } from './HttpContext';
import { StickySpanProperties } from './StickySpanProperties';

import { Transaction } from 'x-pack/plugins/apm/typings/Transaction';
Expand Down Expand Up @@ -75,6 +76,7 @@ export function SpanFlyout({
const stackframes = span.span.stacktrace;
const codeLanguage: string = get(span, SERVICE_LANGUAGE_NAME);
const dbContext = span.context.db;
const httpContext = span.context.http;

return (
<EuiPortal>
Expand All @@ -99,6 +101,7 @@ export function SpanFlyout({
<EuiHorizontalRule />
<StickySpanProperties span={span} totalDuration={totalDuration} />
<EuiHorizontalRule />
<HttpContext httpContext={httpContext} />
<DatabaseContext dbContext={dbContext} />
<StackTraceContainer>
<Stacktrace stackframes={stackframes} codeLanguage={codeLanguage} />
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 @@ -18,8 +18,13 @@ interface Processor {
event: 'span';
}

export interface HttpContext {
url?: string;
}

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

0 comments on commit c142031

Please sign in to comment.