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: Create IdleTransaction class #2720

Merged
merged 6 commits into from Jul 6, 2020

Conversation

AbhiPrasad
Copy link
Member

Dependent on: #2719

As part of the Tracing integration refactor, this PR adds a new IdleTransaction class. By separating the concept of activities/idle transactions from the browser integration, we get some cool benefits.

  1. A lot easier to test
  2. Users of IdleTransaction don't have to worry about "idle". They can just create and add spans as usual.
  3. We can reuse idle transaction later, maybe for electron or react-native?

This is pretty much the same implementation as the one from #2705, just with some added tests and some small quality of life improvements. See the usage there to get an idea what this looks like.

Next steps:

  1. Create basic BrowserTracing integration that allows RoutingInstrumention (what we have with pageload/navigation), and a bunch of span registers, which are functions that will create spans.
  2. Update React/Vue to use this new BrowserTracing integration.

private _finishCallback?: (transactionSpan: IdleTransaction) => void;

public constructor(
transactionContext: TransactionContext,
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here for some of parameters

const popActivity = (id: string) => {
this._popActivity(id);
};
this.spanRecorder = new IdleTransactionSpanRecorder(pushActivity, popActivity, this.spanId, maxlen);
Copy link
Contributor

Choose a reason for hiding this comment

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

Passing these methods is a bit overkill for my taste, but they help to test stuff, so it's fine

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes I couldn't find a better way around this, I'm not the biggest fan of it either.

@kamilogorek
Copy link
Contributor

I didn't review the implementations you moved from previous class, but rather the structure itself. Looks good!

export class IdleTransaction extends Transaction {
// Activities store a list of active spans
// TODO: Can we use `Set()` here?
public activities: Record<string, boolean> = {};
Copy link
Member Author

Choose a reason for hiding this comment

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

@kamilogorek can we use es6 Set() in this codebase? - or do you think we should stay away from this and just use regular JS objects.

Copy link
Member

Choose a reason for hiding this comment

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

Let's use object, Set is only support IE 11

packages/tracing/src/idletransaction.ts Outdated Show resolved Hide resolved
const popActivity = (id: string) => {
this._popActivity(id);
};
this.spanRecorder = new IdleTransactionSpanRecorder(pushActivity, popActivity, this.spanId, maxlen);
Copy link
Member Author

Choose a reason for hiding this comment

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

Yes I couldn't find a better way around this, I'm not the biggest fan of it either.

@AbhiPrasad AbhiPrasad requested a review from HazAT July 6, 2020 11:54
@AbhiPrasad AbhiPrasad merged commit 285d5bd into abhi/ref/add-sentry-tracing Jul 6, 2020
@AbhiPrasad AbhiPrasad deleted the abhi/feat/idle-transaction branch July 6, 2020 12:16
AbhiPrasad added a commit that referenced this pull request Jul 14, 2020
* feat: Adjust hub for idle transaction

* feat: Add IdleTransaction class

* test: IdleTransaction

* ref: Some uneeded code

* ref: Declare class variables in constructor

* chore: Cleanup set() comments
AbhiPrasad added a commit that referenced this pull request Jul 17, 2020
* feat: Create IdleTransaction class (#2720)

* feat: Add BrowserTracing integration (#2723)

* feat: Add span creators to @sentry/tracing package (#2736)

* ref: Convert React and Vue Tracing to use active transaction (#2741)

* build: generate tracing bundles

* fix: Remove circular dependency between span and transaction

* ref: Add side effects true to tracing

* build: Only include @sentry/browser for bundle

* fix: Make sure vue and react are backwards compatible with @sentry/apm
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

3 participants