Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ import {
useServerMapSearchParameters,
} from '@pinpoint-fe/ui/src/hooks';
import { useTranslation } from 'react-i18next';
import { getBaseNodeId, getServerImagePath, parseBaseNodeId } from '@pinpoint-fe/ui/src/utils';
import {
getBaseNodeId,
getServerImagePath,
parseBaseNodeId,
resolveUseStatisticsAgentState,
} from '@pinpoint-fe/ui/src/utils';
import { ServerMapCore, ServerMapCoreProps } from './ServerMapCore';

export interface ServerMapFetcherProps extends Pick<
Expand All @@ -28,7 +33,9 @@ export const ServerMapFetcher = ({ shouldPoll, ...props }: ServerMapFetcherProps
const setServerMapCurrentTarget = useSetAtom(serverMapCurrentTargetAtom);
const { application } = useServerMapSearchParameters();
const experimentalOption = useExperimentals();
const useStatisticsAgentState = experimentalOption.statisticsAgentState.value || true;
const useStatisticsAgentState = resolveUseStatisticsAgentState(
experimentalOption.statisticsAgentState.value,
);

const { data, isLoading, error } = useGetServerMapDataV2({
shouldPoll: !!shouldPoll,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,37 @@ import {
getBaseNodeId,
getServerImagePath,
parseBaseNodeId,
resolveUseStatisticsAgentState,
toBasicISOString,
} from '@pinpoint-fe/ui/src/utils';
import { ServerMapCore, ServerMapCoreProps } from '../ServerMap/ServerMapCore';

export interface ServiceMapFetcherProps
extends Pick<ServerMapCoreProps, 'onClickMenuItem' | 'onApplyChangedOption' | 'queryOption'> {
export interface ServiceMapFetcherProps extends Pick<
ServerMapCoreProps,
'onClickMenuItem' | 'onApplyChangedOption' | 'queryOption'
> {
shouldPoll?: boolean;
}

export const ServiceMapFetcher = ({ shouldPoll: _shouldPoll, ...props }: ServiceMapFetcherProps) => {
export const ServiceMapFetcher = ({
shouldPoll: _shouldPoll,
...props
}: ServiceMapFetcherProps) => {
const setDataAtom = useSetAtom(serverMapDataAtom);
const setCurrentServer = useSetAtom(currentServerAtom);
const setServerMapCurrentTarget = useSetAtom(serverMapCurrentTargetAtom);
const serverMapCurrentTarget = useAtomValue(serverMapCurrentTargetAtom);
const { application, dateRange } = useServerMapSearchParameters();
const experimentalOption = useExperimentals();
const useStatisticsAgentState =
experimentalOption[EXPERIMENTAL_CONFIG_KEYS.USE_STATISTICS_AGENT_STATE].value || true;
const useStatisticsAgentState = resolveUseStatisticsAgentState(
experimentalOption[EXPERIMENTAL_CONFIG_KEYS.USE_STATISTICS_AGENT_STATE].value,
);

const { data: rawData, isLoading, error } = useGetServiceMap({
const {
data: rawData,
isLoading,
error,
} = useGetServiceMap({
applicationName: application?.applicationName ?? '',
serviceTypeName: application?.serviceType,
from: toBasicISOString(dateRange.from),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,27 @@
import { getBaseNodeId, getTimeSeriesApdexInfo } from './serverMap';
import { getBaseNodeId, getTimeSeriesApdexInfo, resolveUseStatisticsAgentState } from './serverMap';
import {
ApplicationType,
GetServerMap,
FilteredMapType as FilteredMap,
} from '@pinpoint-fe/ui/src/constants';

describe('Test serverMap helper utils', () => {
describe('Test "resolveUseStatisticsAgentState"', () => {
test('Preserve an explicitly disabled option', () => {
expect(resolveUseStatisticsAgentState(false)).toBe(false);
});

test('Preserve an explicitly enabled option', () => {
expect(resolveUseStatisticsAgentState(true)).toBe(true);
});

test.each([null, undefined])('Use the fallback when the option is %s', (value) => {
expect(resolveUseStatisticsAgentState(value)).toBe(true);
});
});

describe('Test "getTimeSeriesApdexInfo"', () => {
const makeNode = (
overrides: Partial<GetServerMap.NodeData> = {},
): GetServerMap.NodeData =>
const makeNode = (overrides: Partial<GetServerMap.NodeData> = {}): GetServerMap.NodeData =>
({
isAuthorized: true,
apdexSlot: [],
Expand Down Expand Up @@ -56,7 +68,6 @@ describe('Test serverMap helper utils', () => {
});
});


describe('Test "getBaseNodeId"', () => {
test('Return base node ID when node list is empty', () => {
const application: ApplicationType = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ import { Edge as ServerMapEdge, Node as ServerMapNode } from '@pinpoint-fe/serve
export type Edge = ServerMapEdge;
export type Node = ServerMapNode;

export const resolveUseStatisticsAgentState = (value: boolean | null | undefined): boolean =>
value ?? true;

// node/link key는 2-part(applicationName^serviceType) 또는 3-part(serviceName^applicationName^serviceType)로 들어올 수 있다.
// 마지막 두 토큰이 항상 [applicationName, serviceType]이므로 뒤에서 잘라낸다.
export const parseBaseNodeId = (
Expand Down