mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
# Backport This will backport the following commits from `main` to `8.17`: - [[Feature Flags] Remove `apm.captureError` on slow setup (#212037)](https://github.com/elastic/kibana/pull/212037) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Alejandro Fernández Haro","email":"alejandro.haro@elastic.co"},"sourceCommit":{"committedDate":"2025-02-21T12:20:37Z","message":"[Feature Flags] Remove `apm.captureError` on slow setup (#212037)","sha":"f4d3652832c557f68890aca68df12003de7a1652","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:Core","technical debt","release_note:skip","backport:prev-major","v9.1.0"],"title":"[Feature Flags] Remove `apm.captureError` on slow setup","number":212037,"url":"https://github.com/elastic/kibana/pull/212037","mergeCommit":{"message":"[Feature Flags] Remove `apm.captureError` on slow setup (#212037)","sha":"f4d3652832c557f68890aca68df12003de7a1652"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/212037","number":212037,"mergeCommit":{"message":"[Feature Flags] Remove `apm.captureError` on slow setup (#212037)","sha":"f4d3652832c557f68890aca68df12003de7a1652"}}]}] BACKPORT--> Co-authored-by: Alejandro Fernández Haro <alejandro.haro@elastic.co>
This commit is contained in:
parent
c1220342a6
commit
bb810fa05b
2 changed files with 8 additions and 5 deletions
|
@ -83,7 +83,11 @@ describe('FeatureFlagsService Browser', () => {
|
|||
const spy = jest.spyOn(OpenFeature, 'setProviderAndWait').mockImplementation(async () => {
|
||||
await new Promise(() => {}); // never resolves
|
||||
});
|
||||
const apmCaptureErrorSpy = jest.spyOn(apm, 'captureError');
|
||||
const addLabelsMock = jest.fn();
|
||||
jest
|
||||
.spyOn(apm, 'getCurrentTransaction')
|
||||
// @ts-expect-error incomplete signature, but we don't care at this point
|
||||
.mockImplementationOnce(() => ({ addLabels: addLabelsMock }));
|
||||
const fakeProvider = {} as Provider;
|
||||
setProvider(fakeProvider);
|
||||
expect(spy).toHaveBeenCalledWith(fakeProvider);
|
||||
|
@ -91,9 +95,7 @@ describe('FeatureFlagsService Browser', () => {
|
|||
await expect(isSettledPromise(startPromise)).resolves.toBe(false);
|
||||
await new Promise((resolve) => setTimeout(resolve, 2100)); // A bit longer than 2 seconds
|
||||
await expect(isSettledPromise(startPromise)).resolves.toBe(true);
|
||||
expect(apmCaptureErrorSpy).toHaveBeenCalledWith(
|
||||
expect.stringContaining('The feature flags provider took too long to initialize.')
|
||||
);
|
||||
expect(addLabelsMock).toHaveBeenCalledWith({ slow_setup: true });
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -154,7 +154,8 @@ export class FeatureFlagsService {
|
|||
Won't hold the page load any longer.
|
||||
Feature flags will return the provided fallbacks until the provider is eventually initialized.`;
|
||||
this.logger.warn(msg);
|
||||
apm.captureError(msg);
|
||||
// Flag the transaction as slow so that we can quantify how often it happens
|
||||
apm.getCurrentTransaction()?.addLabels({ slow_setup: true });
|
||||
}),
|
||||
]);
|
||||
clearTimeout(timeoutId);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue