-
Notifications
You must be signed in to change notification settings - Fork 97
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
refactor: ts conversion of tracing-policy and cls #559
Conversation
src/constants.ts
Outdated
@@ -16,25 +16,23 @@ | |||
|
|||
'use strict'; | |||
|
|||
module.exports = { | |||
export namespace Constants { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
src/span-data.ts
Outdated
* @param {string} name The name of the span. | ||
* @param {number} parentSpanId The id of the parent span, 0 for root spans. | ||
* @param {boolean} isRoot Whether this is a root span. | ||
* @param {number} skipFrames the number of frames to remove from the top of the stack. |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
src/span-data.ts
Outdated
} | ||
|
||
// Auto-incrementing integer | ||
let uid: number = 1; |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
src/trace-span.ts
Outdated
/** | ||
* Sets or updates a label value. | ||
* @param {string} key The label key to set. | ||
* @param {string} value The new value of the label. |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
src/trace-span.ts
Outdated
public readonly labels: TraceSpanLabels = {}; | ||
public readonly startTime: string; | ||
public endTime: string = ''; | ||
public kind: string = 'RPC_CLIENT'; |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
src/trace.ts
Outdated
* @constructor | ||
*/ | ||
constructor( | ||
public projectId: string, |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
src/util.ts
Outdated
@@ -61,19 +77,19 @@ var moduleRegex = new RegExp( | |||
* @return {?{traceId: string, spanId: string, options: number}} |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
src/util.ts
Outdated
@@ -115,11 +131,11 @@ function packageNameFromPath(path) { | |||
* @param {string} request The name of the module to be loaded. | |||
* @param {object} parent The module into which the requested module will be loaded. |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
test/test-trace-writer.ts
Outdated
projectId: 'fake project', | ||
serviceContext: {}, | ||
onUncaughtException: 'ignore', | ||
forceNewAgent_: true | ||
}); | ||
} as createTraceWriterOptions); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
test/test-trace-writer.ts
Outdated
@@ -109,8 +113,8 @@ describe('TraceWriter', function() { | |||
assert.ok(trace && trace.spans && trace.spans[0]); | |||
var span = trace.spans[0]; | |||
assert.strictEqual(span.name, 'fake span'); | |||
assert.ok(span.closed_); | |||
assert.strictEqual((spanData.labels_ as any).fakeKey, 'value'); | |||
assert.ok((span as any).closed_); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
@ofrobots Oops, I removed review requests since the last commit in this PR (which should have been the only unique changes) is dependent on other PRs that have yet to be merged. Sorry, should have been clearer. Will address your comments in the relevant PRs. |
3b073fb
to
2ec9ada
Compare
src/cls-ah.ts
Outdated
Namespace.prototype.get = function(k) { | ||
return current[k]; | ||
}; | ||
class Namespace implements CLSNamespace { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
src/cls.ts
Outdated
|
||
/** @const {string} */ | ||
var TRACE_NAMESPACE = 'com.google.cloud.trace'; | ||
const cls: typeof CLS = semver.satisfies(process.version, '>=8') && |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
src/cls.ts
Outdated
|
||
setRootContext: function setRootContext(rootContext) { | ||
getNamespace().set('root', rootContext); | ||
export function getRootContext(): any { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
src/cls.ts
Outdated
|
||
export default {}; | ||
export function setRootContext(rootContext: any): void { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
src/tracing-policy.ts
Outdated
/** | ||
* An object that determines whether a request should be traced. | ||
*/ | ||
export interface Policy { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
No description provided.