-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…2250) * Replace fetch fields with field capabilties for trace filters * add test updates, fix mdsId --------- (cherry picked from commit 6a43f53) Signed-off-by: Shenoy Pratik <[email protected]> Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
- Loading branch information
1 parent
3288817
commit eb74123
Showing
9 changed files
with
184 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
export interface FieldCapAttributes { | ||
type: string; | ||
searchable: boolean; | ||
aggregatable: boolean; | ||
} | ||
|
||
export interface FieldCapResponse { | ||
indices: string[]; | ||
fields: Record<string, Record<string, FieldCapAttributes>>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,12 +6,18 @@ | |
import { configure, mount, shallow } from 'enzyme'; | ||
import Adapter from 'enzyme-adapter-react-16'; | ||
import React from 'react'; | ||
import { TEST_SERVICE_MAP, TEST_SERVICE_MAP_GRAPH } from '../../../../../../test/constants'; | ||
import { | ||
fieldCapQueryResponse1, | ||
fieldCapQueryResponse2, | ||
TEST_SERVICE_MAP, | ||
TEST_SERVICE_MAP_GRAPH, | ||
} from '../../../../../../test/constants'; | ||
import { | ||
calculateTicks, | ||
filtersToDsl, | ||
fixedIntervalToMilli, | ||
fixedIntervalToTickFormat, | ||
getAttributeFieldNames, | ||
getPercentileFilter, | ||
getServiceMapGraph, | ||
getServiceMapScaleColor, | ||
|
@@ -170,4 +176,23 @@ describe('Helper functions', () => { | |
'{"query":{"bool":{"must":[],"filter":[{"range":{"startTime":{"gte":"now-5m","lte":"now"}}},{"query_string":{"query":"order"}}],"should":["test"],"must_not":[],"minimum_should_match":1}},"custom":{"timeFilter":[{"range":{"startTime":{"gte":"now-5m","lte":"now"}}}],"serviceNames":[],"serviceNamesExclude":[],"traceGroup":[],"traceGroupExclude":[],"percentiles":{"query":{"bool":{"should":["test"],"minimum_should_match":1}}}}}' | ||
); | ||
}); | ||
|
||
describe('getAttributeFieldNames', () => { | ||
it("should return only field names starting with 'resource.attributes' or 'span.attributes'", () => { | ||
const expectedFields = [ | ||
'span.attributes.http@url', | ||
'span.attributes.net@peer@ip', | ||
'span.attributes.http@user_agent.keyword', | ||
'resource.attributes.telemetry@[email protected]', | ||
'[email protected]', | ||
]; | ||
const result = getAttributeFieldNames(fieldCapQueryResponse1); | ||
expect(result).toEqual(expectedFields); | ||
}); | ||
|
||
it('should return an empty array if no fields match the specified prefixes', () => { | ||
const result = getAttributeFieldNames(fieldCapQueryResponse2); | ||
expect(result).toEqual([]); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -676,3 +676,71 @@ export const mockSavedObjectActions = ({ get = [], getBulk = [] }) => { | |
getBulk: jest.fn().mockResolvedValue({ observabilityObjectList: getBulk }), | ||
}; | ||
}; | ||
|
||
export const fieldCapQueryResponse1 = { | ||
indices: ['dest1:otel-v1-apm-span-000001', 'dest2:otel-v1-apm-span-000001'], | ||
fields: { | ||
'span.attributes.http@url': { | ||
text: { | ||
type: 'text', | ||
searchable: true, | ||
aggregatable: false, | ||
}, | ||
}, | ||
'span.attributes.net@peer@ip': { | ||
text: { | ||
type: 'text', | ||
searchable: true, | ||
aggregatable: false, | ||
}, | ||
}, | ||
'span.attributes.http@user_agent.keyword': { | ||
keyword: { | ||
type: 'keyword', | ||
searchable: true, | ||
aggregatable: true, | ||
}, | ||
}, | ||
'resource.attributes.telemetry@[email protected]': { | ||
keyword: { | ||
type: 'keyword', | ||
searchable: true, | ||
aggregatable: true, | ||
}, | ||
}, | ||
'[email protected]': { | ||
keyword: { | ||
type: 'keyword', | ||
searchable: true, | ||
aggregatable: true, | ||
}, | ||
}, | ||
'unrelated.field.name': { | ||
text: { | ||
type: 'text', | ||
searchable: true, | ||
aggregatable: false, | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
export const fieldCapQueryResponse2 = { | ||
indices: ['dest1:otel-v1-apm-span-000001', 'dest2:otel-v1-apm-span-000001'], | ||
fields: { | ||
'unrelated.field1': { | ||
text: { | ||
type: 'text', | ||
searchable: true, | ||
aggregatable: false, | ||
}, | ||
}, | ||
'another.unrelated.field': { | ||
keyword: { | ||
type: 'keyword', | ||
searchable: true, | ||
aggregatable: true, | ||
}, | ||
}, | ||
}, | ||
}; |