Skip to content

Commit d7df777

Browse files
feat: add setting to add tracing to all requests (#1218)
1 parent 027c668 commit d7df777

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

src/services/api.ts

+18-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@ import type {DescribeTopicResult} from '../types/api/topic';
4646
import type {TEvVDiskStateResponse} from '../types/api/vdisk';
4747
import type {TUserToken} from '../types/api/whoami';
4848
import type {QuerySyntax} from '../types/store/query';
49-
import {BINARY_DATA_IN_PLAIN_TEXT_DISPLAY} from '../utils/constants';
49+
import {
50+
BINARY_DATA_IN_PLAIN_TEXT_DISPLAY,
51+
DEV_ENABLE_TRACING_FOR_ALL_REQUESTS,
52+
} from '../utils/constants';
5053
import {prepareSortValue} from '../utils/filters';
5154
import type {Nullable} from '../utils/typecheckers';
5255

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

77+
// Make possible manually enable tracing for all requests
78+
// For development purposes
79+
this._axios.interceptors.request.use(function (config) {
80+
const enableTracing = settingsManager.readUserSettingsValue(
81+
DEV_ENABLE_TRACING_FOR_ALL_REQUESTS,
82+
);
83+
84+
if (enableTracing) {
85+
config.headers['X-Want-Trace'] = 1;
86+
}
87+
88+
return config;
89+
});
90+
7491
// Interceptor to process OIDC auth
7592
this._axios.interceptors.response.use(null, function (error) {
7693
const response = error.response;

src/utils/constants.ts

+2
Original file line numberDiff line numberDiff line change
@@ -159,3 +159,5 @@ export const ENABLE_AUTOCOMPLETE = 'enableAutocomplete';
159159
export const AUTOCOMPLETE_ON_ENTER = 'autocompleteOnEnter';
160160

161161
export const IS_HOTKEYS_HELP_HIDDEN_KEY = 'isHotKeysHelpHidden';
162+
163+
export const DEV_ENABLE_TRACING_FOR_ALL_REQUESTS = 'enable_tracing_for_all_requests';

0 commit comments

Comments
 (0)