Skip to content

Switch performance event traffic to transport endpoint #2593

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

Merged
merged 14 commits into from
Apr 8, 2020
Merged
Show file tree
Hide file tree
Changes from 6 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
3 changes: 3 additions & 0 deletions packages/performance/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
# Unreleased
- [changed] Enable new performance monitoring users to onboard in real time.

# 0.2.30
- [changed] Internal transport protocol update from proto2 to proto3.
74 changes: 74 additions & 0 deletions packages/performance/src/services/perf_logger.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { SDK_VERSION } from '../constants';
import * as attributeUtils from '../utils/attributes_utils';
import { createNetworkRequestEntry } from '../resources/network_request';
import '../../test/setup';
import { mergeStrings } from '../utils/string_merger';

describe('Performance Monitoring > perf_logger', () => {
const IID = 'idasdfsffe';
Expand Down Expand Up @@ -301,5 +302,78 @@ describe('Performance Monitoring > perf_logger', () => {
EXPECTED_NETWORK_MESSAGE
);
});

it('skips performance collection if domain is cc', () => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why we want to skip the collection in this case?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fireperf automatically collects network request (including request to cc). However, to avoid infinite loop of network request collection (request to CC -> request is captured as performance resource -> another request to CC), if the domain is cc, then we will not collect the network request.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks James. Based on our offline discussion this is validating that we don't instrument Network Request to CC/FL sent by our own SDK.

Since it took a while to understand this scenario it would be good to add some documentation to make it clear.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you Raman! Added comments to explain that we don't instrument requests sent from SDK itself in both production code and test code.

const CC_NETWORK_PERFORMANCE_ENTRY: PerformanceResourceTiming = {
connectEnd: 0,
connectStart: 0,
decodedBodySize: 0,
domainLookupEnd: 0,
domainLookupStart: 0,
duration: 39.610000094398856,
encodedBodySize: 0,
entryType: 'resource',
fetchStart: 5645.689999917522,
initiatorType: 'fetch',
name: 'http://firebaselogging.googleapis.com/some/path?message=a',
nextHopProtocol: 'http/2+quic/43',
redirectEnd: 0,
redirectStart: 0,
requestStart: 0,
responseEnd: 5685.300000011921,
responseStart: 0,
secureConnectionStart: 0,
startTime: 5645.689999917522,
transferSize: 0,
workerStart: 0,
toJSON: () => {}
};
getIidStub.returns(IID);
SettingsService.getInstance().loggingEnabled = true;
SettingsService.getInstance().logNetworkAfterSampling = true;
// Calls logNetworkRequest under the hood.
createNetworkRequestEntry(CC_NETWORK_PERFORMANCE_ENTRY);
clock.tick(1);

expect(addToQueueStub).not.called;
});

it('skips performance collection if domain is transport', () => {
const TRANSPORT_NETWORK_PERFORMANCE_ENTRY: PerformanceResourceTiming = {
connectEnd: 0,
connectStart: 0,
decodedBodySize: 0,
domainLookupEnd: 0,
domainLookupStart: 0,
duration: 39.610000094398856,
encodedBodySize: 0,
entryType: 'resource',
fetchStart: 5645.689999917522,
initiatorType: 'fetch',
name: mergeStrings(
'hts/frbslgigp.ogepscmti/sapt?aa=2',
'tp:/ieaeogn-agolai.o/hsi//ahprm13'
),
nextHopProtocol: 'http/2+quic/43',
redirectEnd: 0,
redirectStart: 0,
requestStart: 0,
responseEnd: 5685.300000011921,
responseStart: 0,
secureConnectionStart: 0,
startTime: 5645.689999917522,
transferSize: 0,
workerStart: 0,
toJSON: () => {}
};
getIidStub.returns(IID);
SettingsService.getInstance().loggingEnabled = true;
SettingsService.getInstance().logNetworkAfterSampling = true;
// Calls logNetworkRequest under the hood.
createNetworkRequestEntry(TRANSPORT_NETWORK_PERFORMANCE_ENTRY);
clock.tick(1);

expect(addToQueueStub).not.called;
});
});
});
16 changes: 14 additions & 2 deletions packages/performance/src/services/perf_logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,20 @@ export function logNetworkRequest(networkRequest: NetworkRequest): void {
if (!settingsService.instrumentationEnabled) {
return;
}
// Do not log the js sdk's call to cc service to avoid unnecessary cycle.
if (networkRequest.url === settingsService.logEndPointUrl.split('?')[0]) {

// Do not log the js sdk's call to transport service domain to avoid unnecessary cycle.
// Need to blacklist both old and new endpoints to avoid migration gap.
const networkRequestHostName = new URL(networkRequest.url).hostname;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

URL API is not available in IE11. Are you able to just use string parsing? I'm reluctant to ask people to add an additional polyfill unless there is a strong reason.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the heads-up! Decided not to use URL API and match the full URL without search parameter for cc and fl endpoints.


// Blacklist old log endpoint and new transport endpoint.
const logEndpointHostName = new URL(settingsService.logEndPointUrl).hostname;
const transportEndpointHostName = new URL(
settingsService.transportEndpointUrl
).hostname;
if (
networkRequestHostName === logEndpointHostName ||
networkRequestHostName === transportEndpointHostName
) {
return;
}

Expand Down
Loading