Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add setting to add tracing to all requests #1218

Merged
merged 1 commit into from
Aug 26, 2024
Merged
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
19 changes: 18 additions & 1 deletion src/services/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ import type {DescribeTopicResult} from '../types/api/topic';
import type {TEvVDiskStateResponse} from '../types/api/vdisk';
import type {TUserToken} from '../types/api/whoami';
import type {QuerySyntax} from '../types/store/query';
import {BINARY_DATA_IN_PLAIN_TEXT_DISPLAY} from '../utils/constants';
import {
BINARY_DATA_IN_PLAIN_TEXT_DISPLAY,
DEV_ENABLE_TRACING_FOR_ALL_REQUESTS,
} from '../utils/constants';
import {prepareSortValue} from '../utils/filters';
import type {Nullable} from '../utils/typecheckers';

Expand All @@ -71,6 +74,20 @@ export class YdbEmbeddedAPI extends AxiosWrapper {
retryDelay: axiosRetry.exponentialDelay,
});

// Make possible manually enable tracing for all requests
// For development purposes
this._axios.interceptors.request.use(function (config) {
const enableTracing = settingsManager.readUserSettingsValue(
DEV_ENABLE_TRACING_FOR_ALL_REQUESTS,
);

if (enableTracing) {
config.headers['X-Want-Trace'] = 1;
}

return config;
});

// Interceptor to process OIDC auth
this._axios.interceptors.response.use(null, function (error) {
const response = error.response;
Expand Down
2 changes: 2 additions & 0 deletions src/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,3 +159,5 @@ export const ENABLE_AUTOCOMPLETE = 'enableAutocomplete';
export const AUTOCOMPLETE_ON_ENTER = 'autocompleteOnEnter';

export const IS_HOTKEYS_HELP_HIDDEN_KEY = 'isHotKeysHelpHidden';

export const DEV_ENABLE_TRACING_FOR_ALL_REQUESTS = 'enable_tracing_for_all_requests';
Loading