Skip to content

Commit

Permalink
Simplify query structure for getDerivedServiceAnnotations
Browse files Browse the repository at this point in the history
  • Loading branch information
dgieselaar committed May 5, 2020
1 parent a75b37a commit 1dd7a73
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 14 deletions.
2 changes: 1 addition & 1 deletion x-pack/plugins/apm/common/annotations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ export enum AnnotationType {
export interface Annotation {
type: AnnotationType;
id: string;
time: number;
'@timestamp': number;
text: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const style = {
export function AnnotationsPlot(props: Props) {
const { plotValues, annotations } = props;

const tickValues = annotations.map(annotation => annotation.time);
const tickValues = annotations.map(annotation => annotation['@timestamp']);

return (
<>
Expand All @@ -46,12 +46,12 @@ export function AnnotationsPlot(props: Props) {
key={annotation.id}
style={{
position: 'absolute',
left: plotValues.x(annotation.time) - 8,
left: plotValues.x(annotation['@timestamp']) - 8,
top: -2
}}
>
<EuiToolTip
title={asAbsoluteDateTime(annotation.time, 'seconds')}
title={asAbsoluteDateTime(annotation['@timestamp'], 'seconds')}
content={
<EuiFlexGroup>
<EuiFlexItem grow={true}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export async function getDerivedServiceAnnotations({
return {
type: AnnotationType.VERSION,
id: version,
time: firstSeen,
'@timestamp': firstSeen,
text: version
};
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export async function getStoredAnnotations({
return {
type: AnnotationType.VERSION,
id: hit._id,
time: new Date(hit._source['@timestamp']).getTime(),
'@timestamp': hit._source['@timestamp'],
text: hit._source.message
};
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,13 @@ describe('getServiceAnnotations', () => {
{
id: '8.0.0',
text: '8.0.0',
time: 1.5281138e12,
'@timestamp': 1.5281138e12,
type: 'version'
},
{
id: '7.5.0',
text: '7.5.0',
time: 1.5281138e12,
'@timestamp': 1.5281138e12,
type: 'version'
}
]);
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/observability/common/annotations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,5 @@ export interface Annotation {
event: {
created: string;
};
'@timestamp': string;
'@timestamp': number;
}
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,10 @@ export function createAnnotationsClient(params: {
refresh: 'wait_for',
})) as IndexDocumentResponse;

return {
_id: response._id,
_index: response._index,
_source: annotation,
};
return apiCaller('get', {
index,
id: response._id,
});
},
getById: async (getByIdParams: GetByIdParams) => {
const { id } = getByIdParams;
Expand Down

0 comments on commit 1dd7a73

Please sign in to comment.