[APM] Fix agent marks (#25717)

* [APM] Fix agent marks

* Address feedback
This commit is contained in:
Søren Louv-Jansen 2018-11-16 08:51:15 +01:00 committed by GitHub
parent aca61f3fd7
commit 83d5a7a147
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 3 deletions

View file

@ -8,7 +8,7 @@ import { Transaction } from 'x-pack/plugins/apm/typings/Transaction';
import { getAgentMarks } from './get_agent_marks';
describe('getAgentMarks', () => {
it('should sort the marks', () => {
it('should sort the marks by time', () => {
const transaction: Transaction = {
transaction: {
marks: {
@ -33,4 +33,11 @@ describe('getAgentMarks', () => {
} as any;
expect(getAgentMarks(transaction)).toEqual([]);
});
it('should return empty array if agent marks are missing', () => {
const transaction: Transaction = {
transaction: { marks: {} }
} as any;
expect(getAgentMarks(transaction)).toEqual([]);
});
});

View file

@ -13,7 +13,7 @@ export interface AgentMark {
}
export function getAgentMarks(transaction: Transaction): AgentMark[] {
if (!transaction.transaction.marks) {
if (!(transaction.transaction.marks && transaction.transaction.marks.agent)) {
return [];
}

View file

@ -37,7 +37,7 @@ interface Context {
}
interface Marks {
agent: {
agent?: {
[name: string]: number;
};
}