Skip to content

Commit

Permalink
reflect PR feedback
Browse files Browse the repository at this point in the history
Signed-off-by: Lev Popov <[email protected]>
  • Loading branch information
nabam committed Dec 5, 2019
1 parent 23af4a8 commit fc4377b
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 16 deletions.
1 change: 0 additions & 1 deletion packages/jaeger-ui/src/constants/default-config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ export default deepFreeze(
gaID: null,
trackErrors: true,
},
topTagPrefixes: ['http.'],
},
// fields that should be individually merged vs wholesale replaced
'__mergeFields',
Expand Down
10 changes: 7 additions & 3 deletions packages/jaeger-ui/src/model/transform-trace-data.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,18 @@ describe('orderTags()', () => {
const orderedTags = orderTags(
[
{ key: 'b.ip', value: '8.8.4.4' },
{ key: 'http.status_code', value: '200' },
{ key: 'http.Status_code', value: '200' },
{ key: 'a.ip', value: '8.8.8.8' },
{ key: 'z.ip', value: '8.8.8.16' },
{ key: 'http.message', value: 'ok' },
],
['http.']
['z.', 'a.', 'HTTP.']
);
expect(orderedTags).toEqual([
{ key: 'http.status_code', value: '200' },
{ key: 'z.ip', value: '8.8.8.16' },
{ key: 'a.ip', value: '8.8.8.8' },
{ key: 'http.message', value: 'ok' },
{ key: 'http.Status_code', value: '200' },
{ key: 'b.ip', value: '8.8.4.4' },
]);
});
Expand Down
33 changes: 23 additions & 10 deletions packages/jaeger-ui/src/model/transform-trace-data.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ import { getConfigValue } from '../utils/config/get-config';
import { KeyValuePair, Span, SpanData, Trace, TraceData } from '../types/trace';
import TreeNode from '../utils/TreeNode';

export function deduplicateTags(spanTags: Array<KeyValuePair>) {
// exported for tests
export function deduplicateTags(spanTags: KeyValuePair[]) {
const warningsHash: Map<string, string> = new Map<string, string>();
const tags: Array<KeyValuePair> = spanTags.reduce<Array<KeyValuePair>>((uniqueTags, tag) => {
const tags: KeyValuePair[] = spanTags.reduce<KeyValuePair[]>((uniqueTags, tag) => {
if (!uniqueTags.some(t => t.key === tag.key && t.value === tag.value)) {
uniqueTags.push(tag);
} else {
Expand All @@ -33,20 +34,32 @@ export function deduplicateTags(spanTags: Array<KeyValuePair>) {
return { tags, warnings };
}

export function orderTags(spanTags: Array<KeyValuePair>, topPrefixes: Array<string>) {
const orderedTags: Array<KeyValuePair> = [...spanTags];
// exported for tests
export function orderTags(spanTags: KeyValuePair[], topPrefixes: string[]) {
const orderedTags: KeyValuePair[] = spanTags.slice();
const tp = topPrefixes.map((p: string) => p.toLowerCase());

orderedTags.sort((a, b) => {
for (let i = 0; i < topPrefixes.length; i++) {
const p = topPrefixes[i];
if (a.key.startsWith(p) && !b.key.startsWith(p)) {
const aKey = a.key.toLowerCase();
const bKey = b.key.toLowerCase();

for (let i = 0; i < tp.length; i++) {
const p = tp[i];
if (aKey.startsWith(p) && !bKey.startsWith(p)) {
return -1;
}

if (!a.key.startsWith(p) && b.key.startsWith(p)) {
if (!aKey.startsWith(p) && bKey.startsWith(p)) {
return 1;
}
}
return a.key.localeCompare(b.key);

if (aKey > bKey) {
return 1;
}
if (aKey < bKey) {
return -1;
}
return 0;
});
return orderedTags;
}
Expand Down
4 changes: 2 additions & 2 deletions packages/jaeger-ui/src/setupProxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const proxy = require('http-proxy-middleware');
module.exports = function setupProxy(app) {
app.use(
proxy('/api', {
target: 'http://localhost:16686',
target: 'http://localhost:16686/jaeger',
logLevel: 'silent',
secure: false,
changeOrigin: true,
Expand All @@ -28,7 +28,7 @@ module.exports = function setupProxy(app) {
);
app.use(
proxy('/analytics', {
target: 'http://localhost:16686',
target: 'http://localhost:16686/jaeger',
logLevel: 'silent',
secure: false,
changeOrigin: true,
Expand Down
2 changes: 2 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1543,6 +1543,8 @@
version "1.3.0"
resolved "https://registry.yarnpkg.com/@types%2fobject-hash/-/object-hash-1.3.0.tgz#b20db2074129f71829d61ff404e618c4ac3d73cf"
integrity sha1-sg2yB0Ep9xgp1h/0BOYYxKw9c88=
dependencies:
"@types/node" "*"

"@types/prop-types@*":
version "15.7.0"
Expand Down

0 comments on commit fc4377b

Please sign in to comment.