-
Notifications
You must be signed in to change notification settings - Fork 937
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
Changes from 10 commits
591c769
e86086a
3a704dd
3d5342a
8d505a7
cdc8501
26ea86b
ba78d97
4f025e4
b787386
8b8c321
4180537
0e69357
eb1bcba
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
# Unreleased | ||
- [changed] Update the transport mechanism of Fireperf events. | ||
|
||
# 0.2.30 | ||
- [changed] Internal transport protocol update from proto2 to proto3. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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'; | ||
|
@@ -301,5 +302,82 @@ describe('Performance Monitoring > perf_logger', () => { | |
EXPECTED_NETWORK_MESSAGE | ||
); | ||
}); | ||
|
||
// Performance SDK doesn't instrument requests sent from SDK itself, therefore blacklist | ||
// requests sent to cc endpoint. | ||
it('skips performance collection if domain is cc', () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why we want to skip the collection in this case? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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; | ||
}); | ||
|
||
// Performance SDK doesn't instrument requests sent from SDK itself, therefore blacklist | ||
// requests sent to fl endpoint. | ||
it('skips performance collection if domain is fl', () => { | ||
const FL_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', | ||
zijianjoy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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(FL_NETWORK_PERFORMANCE_ENTRY); | ||
clock.tick(1); | ||
|
||
expect(addToQueueStub).not.called; | ||
}); | ||
zijianjoy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. | ||
// Because Performance SDK doesn't instrument requests sent from SDK itself. | ||
const logEndpointHostName = new URL(settingsService.logEndPointUrl).hostname; | ||
zijianjoy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
const flEndpointHostName = new URL(settingsService.flTransportEndpointUrl) | ||
.hostname; | ||
if ( | ||
networkRequestHostName === logEndpointHostName || | ||
networkRequestHostName === flEndpointHostName | ||
visumickey marked this conversation as resolved.
Show resolved
Hide resolved
|
||
) { | ||
return; | ||
} | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.