-
Notifications
You must be signed in to change notification settings - Fork 8.1k
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
Block requests to ui_metric API if telemetry is disabled #35268
Block requests to ui_metric API if telemetry is disabled #35268
Conversation
Pinging @elastic/kibana-platform |
a8a3c09
to
79dca6a
Compare
- Export track helper method from ui_metric app. - Remove createUiMetricUri helper.
79dca6a
to
c981758
Compare
const currentSignature = response.headers('kbn-xpack-sig'); | ||
const cachedSignature = xpackInfoSignature.get(); | ||
// If another interceptor has rejected a request, then headers will be undefined. | ||
if (response.headers) { |
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
@@ -65,7 +65,9 @@ module.config(($httpProvider) => { | |||
|
|||
function interceptorFactory(responseHandler) { | |||
return function interceptor(response) { | |||
if (!isUnauthenticated && !isSystemApiRequest(response.config) && sessionTimeout !== null) { | |||
// If another interceptor has rejected a request, then config will be undefined. | |||
const isSystemRequest = response.config ? isSystemApiRequest(response.config) : false; |
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
💔 Build Failed |
CC @tylersmalley as I believe this is the first instance of statically importing OSS code into production X-Pack code, as enabled by #32722. |
💔 Build Failed |
}); | ||
|
||
module.config(($httpProvider) => { | ||
$httpProvider.interceptors.push(($q) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we using an interceptor to accomplish this? Would it be possible to just not make the calls when telemetry is disabled instead of trying to block them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haha, yes! I implemented the interceptor solution before creating the common track
method, so completely overlooked the obvious. I'll update the code to just perform the check there.
…rceptors. - Add support for an array of metric types. - Update README.
19100f5
to
d084eaa
Compare
Thanks @kobelb, I've applied your suggestion. |
💔 Build Failed |
💚 Build Succeeded |
… containing a colon.
💔 Build Failed |
💔 Build Failed |
0b60e90
to
80ababd
Compare
💚 Build Succeeded |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! I am still not convinced about spreading the code across folders but it's ok 😊
I was wondering if we shouldn't create all new plugins with the new platform architecture and create a shim until the migration is done?
Thanks, Seb! I'm handing this off to @Bamieh, who is on the Platform team, so I'll let him decide how to handle integration with the NP. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! LGTM
to worry about exceeding the 1000-field soft limit in Elasticsearch. | ||
|
||
// TODO: Clarify that colons are NOT allowed in metric names or app types possibly reject request in trackUiMetric; disallow commas too? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this todo is no longer needed as you have already addressed it on line 37
💚 Build Succeeded |
* Block requests to ui_metric API if telemetry is disabled - Export trackUiMetric helper method from ui_metric app. - Remove createUiMetricUri helper. - Add support for an array of metric types. - Update README. * Throw error if trackUiMetric is called with a string containing a colon.
…5629) * Block requests to ui_metric API if telemetry is disabled - Export trackUiMetric helper method from ui_metric app. - Remove createUiMetricUri helper. - Add support for an array of metric types. - Update README. * Throw error if trackUiMetric is called with a string containing a colon.
* Block requests to ui_metric API if telemetry is disabled - Export trackUiMetric helper method from ui_metric app. - Remove createUiMetricUri helper. - Add support for an array of metric types. - Update README. * Throw error if trackUiMetric is called with a string containing a colon.
Fixes #34387
We need to prevent requests to the
ui_metric
API from being sent if telemetry is disabled; otherwise users might assume we're still gathering telemetry. This change adds an interceptor to the$http
service which blocks the request, and also introduces some hackery to ensure all requests to the API go through$http
and that blocked requests don't bubble up warnings to the console.To test:
api/ui_metric
.I've also tested this by creating a build of Kibana and checking that the
ui_metric
requests were and were not being set with/without telemetry, just to verify that X-Pack was still consuming the OSS code as expected.NOTE: A bug currently prevents users from toggling telemetry under Advanced Settings, so you may need to test this by clearing out and restarting your cluster. The bug will be fixed by #35250.
This PR also throws an error if the user calls
trackUiMetric
with an app name or metric type that contains a colon. I expect people to test new metrics by performing an action and verifying it in the/stats
output, at which point they'll see this error.