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: implement web-tracing-framework support #2610
Changes from all commits
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 |
---|---|---|
|
@@ -8,6 +8,10 @@ import {ProtoRecord} from './proto_record'; | |
import {Locals} from './parser/locals'; | ||
import {Pipes} from './pipes/pipes'; | ||
import {CHECK_ALWAYS, CHECK_ONCE, CHECKED, DETACHED, ON_PUSH} from './constants'; | ||
import {wtfCreateScope, wtfLeave, ScopeEventFactory} from 'angular2/src/core/wtf'; | ||
|
||
var _scope_check: ScopeEventFactory = | ||
wtfCreateScope(`ChangeDetector_#check(ascii id, bool throwOnChange)`); | ||
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. remove |
||
|
||
class _Context { | ||
constructor(public element: any, public componentElement: any, public instance: any, | ||
|
@@ -64,6 +68,8 @@ export class AbstractChangeDetector<T> implements ChangeDetector { | |
runDetectChanges(throwOnChange: boolean): void { | ||
if (this.mode === DETACHED || this.mode === CHECKED) return; | ||
|
||
var s = _scope_check(this.id, throwOnChange); | ||
|
||
this.detectChangesInRecords(throwOnChange); | ||
|
||
this._detectChangesInLightDomChildren(throwOnChange); | ||
|
@@ -73,6 +79,7 @@ export class AbstractChangeDetector<T> implements ChangeDetector { | |
this._detectChangesInShadowDomChildren(throwOnChange); | ||
|
||
if (this.mode === CHECK_ONCE) this.mode = CHECKED; | ||
wtfLeave(s); | ||
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. add extra space |
||
} | ||
|
||
detectChangesInRecords(throwOnChange: boolean): void {} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
export {ScopeEventFactory} from './wtf_impl'; | ||
|
||
import * as impl from "./wtf_impl"; | ||
|
||
// Change exports to const once https://github.com/angular/ts2dart/issues/150 | ||
|
||
/** | ||
* True if WTF is enabled. | ||
*/ | ||
export var wtfEnabled = impl.detectWTF(); | ||
|
||
/** | ||
* Create trace scope. | ||
* | ||
* Scopes must be strictly nested and are analogous to stack frames, but | ||
* do not have to follow the stack frames. Instead it is recommended that they follow logical | ||
* nesting. You may want to use | ||
* [Event | ||
* Signatures](http://google.github.io/tracing-framework/instrumenting-code.html#custom-events) | ||
* as they are defined in WTF. | ||
* | ||
* Used to mark scope entry. The return value is used to leave the scope. | ||
* | ||
* final myScope = wtfCreateScope('MyClass#myMethod(ascii someVal)'); | ||
* | ||
* someMethod() { | ||
* var s = myScope('Foo'); // 'Foo' gets stored in tracing UI | ||
* // DO SOME WORK HERE | ||
* return wtfLeave(s, 123); // Return value 123 | ||
* } | ||
* | ||
* Note, adding try-finally block around the work to ensure that `wtfLeave` gets called can | ||
* negatively impact the performance of your application. For this reason we recommend that | ||
* you don't add them to ensure that `wtfLeave` gets called. In production `wtfLeave` is a noop and | ||
* so try-finally block has no value. When debugging perf issues, skipping `wtfLeave`, do to | ||
* exception, will produce incorrect trace, but presence of exception signifies logic error which | ||
* needs to be fixed before the app should be profiled. Add try-finally only when you expect that | ||
* an exception is expected during normal execution while profiling. | ||
* | ||
*/ | ||
export var wtfCreateScope: (signature: string, flags?: any) => impl.ScopeEventFactory = | ||
wtfEnabled ? impl.createScope : (signature: string, flags?: any) => (arg0?: any, arg1?: any) => | ||
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. have the return value share instance to conserve memory. |
||
null; | ||
|
||
/** | ||
* Used to mark end of Scope. | ||
* | ||
* - `scope` to end. | ||
* - `returnValue` (optional) to be passed to the WTF. | ||
* | ||
* Returns the `returnValue for easy chaining. | ||
*/ | ||
export var wtfLeave:<T>(scope: any, returnValue?: T) => T = wtfEnabled ? impl.leave : (s, r?) => r; | ||
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. save instance, add types |
||
|
||
/** | ||
* Used to mark Async start. Async are similar to scope but they don't have to be strictly nested. | ||
* The return value is used in the call to [endAsync]. Async ranges only work if WTF has been | ||
* enabled. | ||
* | ||
* someMethod() { | ||
* var s = wtfStartTimeRange('HTTP:GET', 'some.url'); | ||
* var future = new Future.delay(5).then((_) { | ||
* wtfEndTimeRange(s); | ||
* }); | ||
* } | ||
*/ | ||
export var wtfStartTimeRange: (rangeType: string, action: string) => any = | ||
wtfEnabled ? impl.startTimeRange : (rangeType: string, action: string) => null; | ||
|
||
/** | ||
* Ends a async time range operation. | ||
* [range] is the return value from [wtfStartTimeRange] Async ranges only work if WTF has been | ||
* enabled. | ||
*/ | ||
export var wtfEndTimeRange: (range: any) => void = wtfEnabled ? impl.endTimeRange : (r: any) => | ||
null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pull WTF into separate module