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

feat: Long Tasks instrumentation #757

Merged
merged 8 commits into from
Dec 8, 2021

Conversation

t2t2
Copy link
Contributor

@t2t2 t2t2 commented Nov 25, 2021

Which problem is this PR solving?

This PR adds instrumentation for Long Tasks API (MDN, w3c), automatically generating spans when a task takes longer than 50ms (as of current long task API spec).

Instrumentation wise it's pretty simple - it creates a PerformanceObserver for longtask type (including any buffered = before instrumentation is started) and then creates spans dumping all of the data from PerformanceLongTaskTiming entries

Adding @mhennoch as possible component co-maintainer as we both handle rum at splunk and more likely at least one of us will be available for maintenance (eg Long Task API v2).

resolves open-telemetry/opentelemetry-js#1722

@t2t2 t2t2 requested a review from a team November 25, 2021 09:38
@codecov
Copy link

codecov bot commented Nov 25, 2021

Codecov Report

Merging #757 (62ef9b4) into main (4a3b410) will decrease coverage by 0.61%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##             main     #757      +/-   ##
==========================================
- Coverage   96.87%   96.26%   -0.62%     
==========================================
  Files          11       13       +2     
  Lines         641      697      +56     
  Branches      127      137      +10     
==========================================
+ Hits          621      671      +50     
- Misses         20       26       +6     
Impacted Files Coverage Δ
...entelemetry-instrumentation-long-task/test/util.ts 25.00% <0.00%> (ø)
...y-instrumentation-long-task/src/instrumentation.ts 94.23% <0.00%> (ø)

Copy link
Member

@vmarchaud vmarchaud left a comment

Choose a reason for hiding this comment

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

lgtm

@vmarchaud vmarchaud requested review from obecny and dyladan November 27, 2021 13:42
@t2t2
Copy link
Contributor Author

t2t2 commented Dec 2, 2021

Seems like there was an update to node.js (14 -> 16) & npm (6 -> 8) versions in github actions runners about 4 hours ago causing open-telemetry/opentelemetry-js#2093 to happen on lint task as it uses whatever node/npm is installed (CI run log) however adding --legacy-peer-deps to lerna bootstrap's npm install arguments causes a separate eslint module resolution error

@dyladan
Copy link
Member

dyladan commented Dec 2, 2021

OK. We should work on the latest anyway so i'll look into updating our dependencies to get it up and running. Thanks for looking into it.

For now, we can probably use the setup-js action that the unit tests use to get around this.

Copy link
Member

@dyladan dyladan left a comment

Choose a reason for hiding this comment

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

This seems like an awesome addition and it is very easy to follow since the API is so straightforward. I made a comment about the non-specified attributes but if we don't get any guidance from the TC i'm happy to move forward with this since it is 0.x anyways.

Comment on lines +72 to +75
span.setAttribute('component', this.component);
span.setAttribute('longtask.name', entry.name);
span.setAttribute('longtask.entry_type', entry.entryType);
span.setAttribute('longtask.duration', entry.duration);
Copy link
Member

Choose a reason for hiding this comment

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

I assume there is no spec for these attributes. Can we see if there is any guidance from the spec/TC on how we should handle custom or non-specified attributes? If these are ever specified in the future in a different format it could make us non-compliant.

Copy link
Member

Choose a reason for hiding this comment

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

@dyladan instrumentation are not stable yet so this shouldn't be considered a breaking change if in the future they are in the spec ?

Copy link
Member

Choose a reason for hiding this comment

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

No but in general I think we should try to be consistent.

@dyladan dyladan merged commit 56d332e into open-telemetry:main Dec 8, 2021
This was referenced Feb 25, 2022
@chingor13 chingor13 mentioned this pull request Feb 28, 2022
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.

Automatic instrumentation for long tasks in browser
5 participants