Skip to content

Commit

Permalink
adding message to transaction and span metadata (#54017)
Browse files Browse the repository at this point in the history
  • Loading branch information
cauemarcondes committed Jan 7, 2020
1 parent 9aa2341 commit 6398e22
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,15 @@ describe('SpanMetadata', () => {
name: 'opbeans-java'
},
span: {
id: '7efbc7056b746fcb'
id: '7efbc7056b746fcb',
message: {
age: { ms: 1577958057123 },
queue: { name: 'queue name' }
}
}
} as unknown) as Span;
const output = render(<SpanMetadata span={span} />, renderOptions);
expectTextsInDocument(output, ['Service', 'Agent']);
expectTextsInDocument(output, ['Service', 'Agent', 'Message']);
});
});
describe('when a span is presented', () => {
Expand All @@ -55,11 +59,15 @@ describe('SpanMetadata', () => {
response: { status_code: 200 }
},
subtype: 'http',
type: 'external'
type: 'external',
message: {
age: { ms: 1577958057123 },
queue: { name: 'queue name' }
}
}
} as unknown) as Span;
const output = render(<SpanMetadata span={span} />, renderOptions);
expectTextsInDocument(output, ['Service', 'Agent', 'Span']);
expectTextsInDocument(output, ['Service', 'Agent', 'Span', 'Message']);
});
});
describe('when there is no id inside span', () => {
Expand All @@ -83,7 +91,7 @@ describe('SpanMetadata', () => {
} as unknown) as Span;
const output = render(<SpanMetadata span={span} />, renderOptions);
expectTextsInDocument(output, ['Service', 'Agent']);
expectTextsNotInDocument(output, ['Span']);
expectTextsNotInDocument(output, ['Span', 'Message']);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import {
SPAN,
LABELS,
TRANSACTION,
TRACE
TRACE,
MESSAGE_SPAN
} from '../sections';

export const SPAN_METADATA_SECTIONS: Section[] = [
Expand All @@ -20,5 +21,6 @@ export const SPAN_METADATA_SECTIONS: Section[] = [
TRANSACTION,
TRACE,
SERVICE,
MESSAGE_SPAN,
AGENT
];
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ function getTransaction() {
notIncluded: 'transaction not included value',
custom: {
someKey: 'custom value'
},
message: {
age: { ms: 1577958057123 },
queue: { name: 'queue name' }
}
}
} as unknown) as Transaction;
Expand All @@ -59,7 +63,8 @@ describe('TransactionMetadata', () => {
'Agent',
'URL',
'User',
'Custom'
'Custom',
'Message'
]);
});

Expand All @@ -81,7 +86,9 @@ describe('TransactionMetadata', () => {
'agent.someKey',
'url.someKey',
'user.someKey',
'transaction.custom.someKey'
'transaction.custom.someKey',
'transaction.message.age.ms',
'transaction.message.queue.name'
]);

// excluded keys
Expand Down Expand Up @@ -109,7 +116,9 @@ describe('TransactionMetadata', () => {
'agent value',
'url value',
'user value',
'custom value'
'custom value',
'1577958057123',
'queue name'
]);

// excluded values
Expand Down Expand Up @@ -138,7 +147,8 @@ describe('TransactionMetadata', () => {
'Process',
'Agent',
'URL',
'Custom'
'Custom',
'Message'
]);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ import {
PAGE,
USER,
USER_AGENT,
CUSTOM_TRANSACTION
CUSTOM_TRANSACTION,
MESSAGE_TRANSACTION
} from '../sections';

export const TRANSACTION_METADATA_SECTIONS: Section[] = [
Expand All @@ -29,6 +30,7 @@ export const TRANSACTION_METADATA_SECTIONS: Section[] = [
CONTAINER,
SERVICE,
PROCESS,
MESSAGE_TRANSACTION,
AGENT,
URL,
{ ...PAGE, key: 'transaction.page' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,3 +136,20 @@ export const CUSTOM_TRANSACTION: Section = {
key: 'transaction.custom',
label: customLabel
};

const messageLabel = i18n.translate(
'xpack.apm.metadataTable.section.messageLabel',
{
defaultMessage: 'Message'
}
);

export const MESSAGE_TRANSACTION: Section = {
key: 'transaction.message',
label: messageLabel
};

export const MESSAGE_SPAN: Section = {
key: 'span.message',
label: messageLabel
};
6 changes: 6 additions & 0 deletions x-pack/legacy/plugins/apm/typings/es_schemas/raw/SpanRaw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ export interface SpanRaw extends APMBaseDoc {
statement?: string;
type?: string;
};
message?: {
queue?: { name: string };
age?: { ms: number };
body?: string;
headers?: Record<string, unknown>;
};
};
transaction?: {
id: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ export interface TransactionRaw extends APMBaseDoc {
};
type: string;
custom?: Record<string, unknown>;
message?: {
queue?: { name: string };
age?: { ms: number };
body?: string;
headers?: Record<string, unknown>;
};
};

// Shared by errors and transactions
Expand Down

0 comments on commit 6398e22

Please sign in to comment.