Skip to content
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

Record logged network requests as completed spans #748

Merged
merged 1 commit into from
Apr 18, 2024

Conversation

priettt
Copy link
Contributor

@priettt priettt commented Apr 17, 2024

  • Record network requests as spans.

  • Consolidate logNetworkCall and logNetworkError methods

EmbraceNetworkLoggingService had two methods: logNetworkCall and logNetworkError. They were both doing essentially the same, but with a different NetworkCallV2 object: strip the URL, sanitize the TraceId, logging the networkCapturedData, and processing the network call.

We don't need a NetworkCallV2 object anymore, and the EmbraceNetworkRequest is the same for both network call and network error, so we can just use one method.

  • Remove unused methods.

Questions:

  • Why do we need to strip the URL?
  • Why are we stripping the URL for the span, but not for the networkCapturedData?

@priettt priettt marked this pull request as ready for review April 17, 2024 15:00
@priettt priettt requested a review from a team as a code owner April 17, 2024 15:00
endTime,
networkCaptureData,
errorMessage
networkRequest.url, //TODO: This used the non-stripped URL, is that correct?
Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah, we want to log the entire URL when capturing the entire request/response in case there are parameters are that important. We aren't aggregating by this so we don't need to reduce the cardinality by tweaking the URL

} ?: return
val domain = getDomain(
stripUrl(networkRequest.url)
) ?: return

synchronized(callsStorageLastUpdate) {
Copy link
Collaborator

@bidetofevil bidetofevil Apr 17, 2024

Choose a reason for hiding this comment

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

we can remove this synchronization and only block if we are counting against the same domain

We can change this in a separate PR though - this locking has always sucked and now we can remove it

callsStorageLastUpdate.incrementAndGet()
sessionNetworkCalls[callId] = networkCall

//TODO: Why do we want to strip the URL?
Copy link
Collaborator

Choose a reason for hiding this comment

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

We strip because we want to aggregate all the calls to this base URL without parameters and hash section links (or whenever they are called). I guess the idea is that foo.com/#first and foo.com/#second is close enough that they should be looked at together.

return null
}

fun stripUrl(url: String): String {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can move this. method to the logging service? It's only called there and in the test, and the test could just validate the URL is stripped without using that method to get the expected match?

@@ -140,7 +140,7 @@ internal class NetworkUtilsTest {

@Test
fun stripUrl() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

rip it out!

Copy link
Collaborator

@bidetofevil bidetofevil left a comment

Choose a reason for hiding this comment

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

LGTM. If we can move the stripUrl method from NetworkUtils, that would be great

Copy link
Collaborator

bidetofevil commented Apr 18, 2024

Merge activity

  • Apr 18, 7:50 PM EDT: @bidetofevil started a stack merge that includes this pull request via Graphite.
  • Apr 18, 7:58 PM EDT: Graphite rebased this pull request as part of a merge.
  • Apr 18, 7:59 PM EDT: @bidetofevil merged this pull request with Graphite.

Base automatically changed from request-schema-type to master April 18, 2024 23:57
@bidetofevil bidetofevil merged commit 93f6b0b into master Apr 18, 2024
1 of 2 checks passed
@bidetofevil bidetofevil deleted the record-network-span branch April 18, 2024 23:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants