-
Notifications
You must be signed in to change notification settings - Fork 524
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add config option to allow displaying full traceID (#2536)
## Which problem is this PR solving? - Resolves: #2092 ## Description of the changes - I've added a funtion to show the full trace ID in the trace details page ## How was this change tested? - here is the screenshot of the function Full ID ![Screenshot from 2025-01-03 18-00-08](https://github.com/user-attachments/assets/f3c414d2-7706-427e-94fc-0786c42b4d3d) - after clicking the Full ID ![Screenshot from 2025-01-03 17-59-45](https://github.com/user-attachments/assets/b7a50362-faba-407b-88f9-883cf7ae9e67) ## Checklist - [x] I have read https://github.com/jaegertracing/jaeger/blob/master/CONTRIBUTING_GUIDELINES.md - [x] I have signed all commits - [x] I have added unit tests for the new functionality - [x] I have run lint and test steps successfully - for `jaeger`: `make lint test` - for `jaeger-ui`: `npm run lint` and `npm run test` --------- Signed-off-by: Avinash <[email protected]> Signed-off-by: avinash <[email protected]> Signed-off-by: Avinash Chowdhury <[email protected]> Signed-off-by: Yuri Shkuro <[email protected]> Co-authored-by: Yuri Shkuro <[email protected]>
- Loading branch information
1 parent
e3776db
commit dc4a95b
Showing
9 changed files
with
173 additions
and
9 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
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
Copyright (c) 2025 The Jaeger Authors | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
.TraceIDLength { | ||
display: inline-block; | ||
vertical-align: middle; | ||
} | ||
.TraceIDLength--short { | ||
font-size: 16px; | ||
padding: 3px 4px; | ||
} | ||
.TraceIDLength--full { | ||
font-size: 14px; | ||
padding: 3px 4px; | ||
letter-spacing: 0.1px; | ||
} |
100 changes: 100 additions & 0 deletions
100
packages/jaeger-ui/src/components/common/TraceId.test.js
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,100 @@ | ||
// Copyright (c) 2025 The Jaeger Authors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
import React from 'react'; | ||
import { shallow } from 'enzyme'; | ||
import { TraceId } from './TraceId'; | ||
import { getConfigValue } from '../../utils/config/get-config'; | ||
|
||
jest.mock('../../utils/config/get-config', () => ({ | ||
getConfigValue: jest.fn(), | ||
})); | ||
|
||
describe('TraceIdDisplayLength', () => { | ||
const DEFAULT_LENGTH = 7; | ||
const MOCK_TRACE_ID = '12345678901234567890'; | ||
const CUSTOM_CLASS = 'custom-class'; | ||
|
||
let wrapper; | ||
|
||
const defaultProps = { | ||
traceId: MOCK_TRACE_ID, | ||
}; | ||
|
||
beforeEach(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
|
||
const createWrapper = (props = {}) => { | ||
return shallow(<TraceId {...defaultProps} {...props} />); | ||
}; | ||
|
||
describe('TraceIdDisplayLength Component', () => { | ||
it('renders the default traceIdLength 7', () => { | ||
getConfigValue.mockReturnValue(undefined); | ||
wrapper = createWrapper(); | ||
|
||
const displayedText = wrapper.text(); | ||
expect(displayedText).toEqual(MOCK_TRACE_ID.slice(0, DEFAULT_LENGTH)); | ||
}); | ||
|
||
it('renders the config length when provided', () => { | ||
const configuredLength = 5; | ||
getConfigValue.mockReturnValue(configuredLength); | ||
wrapper = createWrapper(); | ||
|
||
const displayedText = wrapper.text(); | ||
expect(displayedText).toEqual(MOCK_TRACE_ID.slice(0, configuredLength)); | ||
}); | ||
}); | ||
|
||
describe('Edge case handling', () => { | ||
it('renders the full traceId when it is shorter then configured length', () => { | ||
const shortTraceId = '12345'; | ||
const configuredLength = 10; | ||
getConfigValue.mockReturnValue(configuredLength); | ||
|
||
wrapper = createWrapper({ traceId: shortTraceId }); | ||
expect(wrapper.text()).toEqual(shortTraceId); | ||
}); | ||
|
||
it('renders when traceId is undefiend', () => { | ||
wrapper = createWrapper({ traceId: '' }); | ||
expect(wrapper.text()).toEqual(''); | ||
}); | ||
}); | ||
|
||
describe('Style handling', () => { | ||
it('applies custom className when provided', () => { | ||
wrapper = createWrapper({ className: CUSTOM_CLASS }); | ||
expect(wrapper.hasClass(CUSTOM_CLASS)).toBe(true); | ||
}); | ||
|
||
it('default classes for styling', () => { | ||
wrapper = createWrapper(); | ||
expect(wrapper.hasClass('TraceIDLength')).toBe(true); | ||
expect(wrapper.hasClass('u-tx-muted')).toBe(true); | ||
}); | ||
|
||
it('adds a length-based class depending on the configuration', () => { | ||
getConfigValue.mockReturnValue(DEFAULT_LENGTH); | ||
wrapper = createWrapper(); | ||
expect(wrapper.hasClass('TraceIDLength--short')).toBe(true); | ||
|
||
getConfigValue.mockReturnValue(32); | ||
wrapper = createWrapper(); | ||
expect(wrapper.hasClass('TraceIDLength--full')).toBe(true); | ||
}); | ||
}); | ||
}); |
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,32 @@ | ||
// Copyright (c) 2025 The Jaeger Authors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
import React from 'react'; | ||
import { getConfigValue } from '../../utils/config/get-config'; | ||
import './TraceId.css'; | ||
|
||
type Props = { | ||
traceId: string; | ||
className?: string; | ||
}; | ||
|
||
export function TraceId({ traceId, className = '' }: Props) { | ||
const traceIdDisplayLength = getConfigValue('traceIdDisplayLength') || 7; | ||
const traceIdDisplay = traceId ? traceId.slice(0, traceIdDisplayLength) : ''; | ||
const lengthClass = traceIdDisplayLength === 7 ? 'TraceIDLength--short' : 'TraceIDLength--full'; | ||
|
||
return <small className={`TraceIDLength ${lengthClass} u-tx-muted ${className} `}>{traceIdDisplay}</small>; | ||
} | ||
|
||
export default TraceId; |
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