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

Wrong time reported for secure connection start #3848

Closed
1 of 2 tasks
Abinet18 opened this issue Jun 1, 2023 · 6 comments
Closed
1 of 2 tasks

Wrong time reported for secure connection start #3848

Abinet18 opened this issue Jun 1, 2023 · 6 comments
Assignees
Labels

Comments

@Abinet18
Copy link
Contributor

Abinet18 commented Jun 1, 2023

As part of navigation and resource events, secureConnectionStart is added to the spans generated by instrumentations like document_load, xhr and fetch. The value reported by browser is 0 when the page is not secure (http) but the instrumentation reports a value that is lower than fetchStart (probably using timeOrigin) , which can result in wrong metrics by backend. Can we avoid reporting this metric when the page is not secure.

Here is a sample payload from documentFetchSpan for a non-secure(http) page
"events": [ { "attributes": [], "name": "fetchStart", "timeUnixNano": 1678483372712300000, "droppedAttributesCount": 0 }, { "attributes": [], "name": "domainLookupStart", "timeUnixNano": 1678483372712300000, "droppedAttributesCount": 0 }, { "attributes": [], "name": "domainLookupEnd", "timeUnixNano": 1678483372712300000, "droppedAttributesCount": 0 }, { "attributes": [], "name": "connectStart", "timeUnixNano": 1678483372712300000, "droppedAttributesCount": 0 }, { "attributes": [], "name": "secureConnectionStart", "timeUnixNano": 1678483372707100200, "droppedAttributesCount": 0 }, { "attributes": [], "name": "connectEnd", "timeUnixNano": 1678483372712300000, "droppedAttributesCount": 0 }, { "attributes": [], "name": "requestStart", "timeUnixNano": 1678483372716800300, "droppedAttributesCount": 0 }, { "attributes": [], "name": "responseStart", "timeUnixNano": 1678483372733600300, "droppedAttributesCount": 0 }, { "attributes": [], "name": "responseEnd", "timeUnixNano": 1678483372739200300, "droppedAttributesCount": 0 } ],
We can have sth like this in the instrumentation for the document fetch span to avoid adding this metric when page is not secure,
if (window.location.protocol === 'https') { addSpanNetworkEvent(span, PTN.SECURE_CONNECTION_START, resource); }
but this may not work for resources and xhr/fetch .

  • This only affects the JavaScript OpenTelemetry library
  • This may affect other libraries, but I would like to get opinions here first
@t2t2
Copy link
Contributor

t2t2 commented Jun 7, 2023

Same issue applies for cors: #3199 (and I know it is assigned to me but I just haven't had time to do it)

@t2t2
Copy link
Contributor

t2t2 commented Jun 7, 2023

Instead of window.location.protocol you could check resource.name (PerformanceEntry.name, provides absolute URL of the resource being loaded including protocol) to make an instrumentation agnostic solution (as this method is also used by other instrumentations)

@Abinet18
Copy link
Contributor Author

Abinet18 commented Jun 7, 2023

@t2t2 , https://github.com/open-telemetry/opentelemetry-js/blob/main/packages/opentelemetry-sdk-trace-web/src/utils.ts#L82 , the resource here doesn't have the name property. It is a different type. We may have to pass the url to this function

@t2t2
Copy link
Contributor

t2t2 commented Jun 7, 2023

That just means otel has incomplete typings, because it definitely does exist in reality (sandbox)
image

And in typescript's standard dom definitions

@github-actions
Copy link

github-actions bot commented Aug 7, 2023

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 14 days.

@github-actions github-actions bot added the stale label Aug 7, 2023
@pichlermarc
Copy link
Member

Fixed in #3879

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants