Skip to content

Commit

Permalink
Make changes to allow for /api/quality-metrics to work (#2641)
Browse files Browse the repository at this point in the history
## Which problem is this PR solving?
- Resolves #2640 
- jaegertracing/jaeger#6607

## Description of the changes
- introduce config option for the API endpoint and change it to
`/api/quality-metrics' as implemented in
jaegertracing/jaeger#6608

## How was this change tested?
- manually

## Checklist
- [ ] I have read
https://github.com/jaegertracing/jaeger/blob/master/CONTRIBUTING_GUIDELINES.md
- [ ] I have signed all commits
- [ ] I have added unit tests for the new functionality
- [ ] 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: cs-308-2023 <adityaruhela2003@gmail.com>
Signed-off-by: Yuri Shkuro <github@ysh.us>
Co-authored-by: Yuri Shkuro <yurishkuro@users.noreply.github.com>
Co-authored-by: Yuri Shkuro <github@ysh.us>
  • Loading branch information
3 people authored Feb 15, 2025
1 parent 625a57a commit 655f2b7
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 3 deletions.
4 changes: 3 additions & 1 deletion packages/jaeger-ui/src/api/jaeger.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import dayjs from 'dayjs';
import _duration from 'dayjs/plugin/duration';
import queryString from 'query-string';

import getConfig from '../utils/config/get-config';
import prefixUrl from '../utils/prefix-url';

dayjs.extend(_duration);
Expand Down Expand Up @@ -81,6 +82,7 @@ function getJSON(url, options = {}) {

export const DEFAULT_API_ROOT = prefixUrl('/api/');
export const ANALYTICS_ROOT = prefixUrl('/analytics/');
export const QUALITY_METRICS_ROOT = prefixUrl(getConfig().qualityMetrics.apiEndpoint);
export const DEFAULT_DEPENDENCY_LOOKBACK = dayjs.duration(1, 'weeks').asMilliseconds();

const JaegerAPI = {
Expand All @@ -98,7 +100,7 @@ const JaegerAPI = {
return getJSON(`${this.apiRoot}dependencies`, { query: { endTs, lookback } });
},
fetchQualityMetrics(service, hours) {
return getJSON(`/qualitymetrics-v2`, { query: { hours, service } });
return getJSON(QUALITY_METRICS_ROOT, { query: { hours, service } });
},
fetchServiceOperations(serviceName) {
return getJSON(`${this.apiRoot}services/${encodeURIComponent(serviceName)}/operations`);
Expand Down
2 changes: 1 addition & 1 deletion packages/jaeger-ui/src/api/jaeger.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ describe('fetchQualityMetrics', () => {
const service = 'test-service';
JaegerAPI.fetchQualityMetrics(service, hours);
expect(fetchMock).toHaveBeenLastCalledWith(
`/qualitymetrics-v2?${queryString.stringify({ service, hours })}`,
`/api/quality-metrics?${queryString.stringify({ service, hours })}`,
defaultOptions
);
});
Expand Down
1 change: 1 addition & 0 deletions packages/jaeger-ui/src/constants/default-config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ const defaultConfig: Config = {
qualityMetrics: {
menuEnabled: false,
menuLabel: 'Trace Quality',
apiEndpoint: '/api/quality-metrics',
},
};

Expand Down
1 change: 1 addition & 0 deletions packages/jaeger-ui/src/types/config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -200,5 +200,6 @@ export type Config = {
qualityMetrics?: {
menuEnabled?: boolean;
menuLabel?: string;
apiEndpoint?: string;
};
};
3 changes: 2 additions & 1 deletion packages/jaeger-ui/src/utils/config/get-config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import _get from 'lodash/get';
import memoizeOne from 'memoize-one';

import { Config } from '../../types/config';
import processDeprecation from './process-deprecation';
import defaultConfig, { deprecations, mergeFields } from '../../constants/default-config';

Expand All @@ -38,7 +39,7 @@ function getCapabilities() {
* Merge the embedded config from the query service (if present) with the
* default config from `../../constants/default-config`.
*/
const getConfig = memoizeOne(function getConfig() {
const getConfig = memoizeOne(function getConfig(): Config {
const capabilities = getCapabilities();

const embedded = getUiConfig();
Expand Down

0 comments on commit 655f2b7

Please sign in to comment.