@opencensus/core
Advanced tools
Comparing version 0.0.14 to 0.0.15
@@ -47,4 +47,6 @@ "use strict"; | ||
this.level = opt.level; | ||
this.logger = | ||
logDriver({ levels: ConsoleLogger.LEVELS, level: opt.level || 'silent' }); | ||
this.logger = logDriver({ | ||
levels: ConsoleLogger.LEVELS, | ||
level: opt.level || 'silent', | ||
}); | ||
} | ||
@@ -51,0 +53,0 @@ /** |
@@ -64,3 +64,3 @@ "use strict"; | ||
seconds: Math.floor(epochMilli / MILLIS_PER_SECOND), | ||
nanos: (epochMilli % MILLIS_PER_SECOND) * NANOS_PER_MILLI | ||
nanos: (epochMilli % MILLIS_PER_SECOND) * NANOS_PER_MILLI, | ||
}; | ||
@@ -72,4 +72,4 @@ } | ||
setHrtimeReference, | ||
resetHrtimeFunctionCache | ||
resetHrtimeFunctionCache, | ||
}; | ||
//# sourceMappingURL=time-util.js.map |
@@ -58,3 +58,3 @@ "use strict"; | ||
const keysAndConstantKeys = new Set([...keys, ...constantLabels.keys()].map(k => k.key)); | ||
if (keysAndConstantKeys.size !== (keys.length + constantLabels.size)) { | ||
if (keysAndConstantKeys.size !== keys.length + constantLabels.size) { | ||
throw new Error(`The keys from LabelKeys should not be present in constantLabels or LabelKeys should not contains duplicate keys`); | ||
@@ -61,0 +61,0 @@ } |
@@ -31,3 +31,3 @@ /** | ||
/** Buffer object to store the spans. */ | ||
private logger?; | ||
logger: loggerTypes.Logger; | ||
private buffer; | ||
@@ -34,0 +34,0 @@ /** |
@@ -19,2 +19,3 @@ "use strict"; | ||
const exporter_buffer_1 = require("./exporter-buffer"); | ||
const logger = require("../common/console-logger"); | ||
/** Do not send span data */ | ||
@@ -38,3 +39,3 @@ class NoopExporter { | ||
this.buffer = new exporter_buffer_1.ExporterBuffer(this, config); | ||
this.logger = config.logger; | ||
this.logger = config.logger || logger.logger(); | ||
} | ||
@@ -58,8 +59,7 @@ onStartSpan(span) { } | ||
publish(spans) { | ||
spans.map((span) => { | ||
spans.map(span => { | ||
const ROOT_STR = `RootSpan: {traceId: ${span.traceId}, spanId: ${span.id}, name: ${span.name} }`; | ||
const SPANS_STR = span.spans.map((child) => [`\t\t{spanId: ${child.id}, name: ${child.name}}`].join('\n')); | ||
const SPANS_STR = span.spans.map(child => [`\t\t{spanId: ${child.id}, name: ${child.name}}`].join('\n')); | ||
const result = []; | ||
result.push(ROOT_STR + '\n\tChildSpans:\n' + | ||
`${SPANS_STR.join('\n')}`); | ||
result.push(ROOT_STR + '\n\tChildSpans:\n' + `${SPANS_STR.join('\n')}`); | ||
console.log(`${result}`); | ||
@@ -66,0 +66,0 @@ }); |
@@ -37,8 +37,8 @@ "use strict"; | ||
this.logger = config.logger || logger.logger(); | ||
this.bufferSize = isNaN(Number(config.bufferSize)) ? | ||
DEFAULT_BUFFER_SIZE : | ||
Number(config.bufferSize); | ||
this.bufferTimeout = isNaN(Number(config.bufferTimeout)) ? | ||
DEFAULT_BUFFER_TIMEOUT : | ||
Number(config.bufferTimeout); | ||
this.bufferSize = isNaN(Number(config.bufferSize)) | ||
? DEFAULT_BUFFER_SIZE | ||
: Number(config.bufferSize); | ||
this.bufferTimeout = isNaN(Number(config.bufferTimeout)) | ||
? DEFAULT_BUFFER_TIMEOUT | ||
: Number(config.bufferTimeout); | ||
return this; | ||
@@ -45,0 +45,0 @@ } |
@@ -27,3 +27,3 @@ /** | ||
export * from './metrics/gauges/types'; | ||
export { Metric, MetricDescriptor, TimeSeries, MetricDescriptorType, LabelKey, LabelValue, Point as TimeSeriesPoint, DistributionValue, BucketOptions, Bucket as DistributionBucket, SummaryValue, Explicit, Exemplar, Timestamp, Snapshot, ValueAtPercentile, MetricProducerManager, MetricProducer } from './metrics/export/types'; | ||
export { Metric, MetricDescriptor, TimeSeries, MetricDescriptorType, LabelKey, LabelValue, Point as TimeSeriesPoint, DistributionValue, BucketOptions, Bucket as DistributionBucket, SummaryValue, Explicit, Exemplar, Timestamp, Snapshot, ValueAtPercentile, MetricProducerManager, MetricProducer, } from './metrics/export/types'; | ||
export * from './trace/model/tracer-base'; | ||
@@ -30,0 +30,0 @@ export * from './trace/model/tracer'; |
@@ -29,3 +29,9 @@ "use strict"; | ||
// A list of well-known EventEmitter methods that add event listeners. | ||
const EVENT_EMITTER_METHODS = ['addListener', 'on', 'once', 'prependListener', 'prependOnceListener']; | ||
const EVENT_EMITTER_METHODS = [ | ||
'addListener', | ||
'on', | ||
'once', | ||
'prependListener', | ||
'prependOnceListener', | ||
]; | ||
class AsyncHooksNamespace { | ||
@@ -83,3 +89,3 @@ get name() { | ||
writable: false, | ||
value: cb.length | ||
value: cb.length, | ||
}); | ||
@@ -95,5 +101,5 @@ return contextWrapper; | ||
const ns = this; | ||
EVENT_EMITTER_METHODS.forEach((method) => { | ||
EVENT_EMITTER_METHODS.forEach(method => { | ||
if (ee[method]) { | ||
shimmer.wrap(ee, method, (oldMethod) => { | ||
shimmer.wrap(ee, method, oldMethod => { | ||
return function (event, cb) { | ||
@@ -100,0 +106,0 @@ return oldMethod.call(this, event, ns.bind(cb)); |
@@ -21,3 +21,5 @@ "use strict"; | ||
// !!process.env.GCLOUD_TRACE_NEW_CONTEXT; | ||
const cls = useAsyncHooks ? require('./cls-ah') : require('continuation-local-storage'); | ||
const cls = useAsyncHooks | ||
? require('./cls-ah') | ||
: require('continuation-local-storage'); | ||
const TRACE_NAMESPACE = 'opencensus.io'; | ||
@@ -24,0 +26,0 @@ /** |
@@ -27,5 +27,5 @@ "use strict"; | ||
const randomBytes = crypto.randomBytes; | ||
const spanRandomBuffer = randomFillSync ? | ||
() => randomFillSync(spanIdBuffer) : | ||
() => randomBytes(SPAN_ID_RANDOM_BYTES); | ||
const spanRandomBuffer = randomFillSync | ||
? () => randomFillSync(spanIdBuffer) | ||
: () => randomBytes(SPAN_ID_RANDOM_BYTES); | ||
function randomSpanId() { | ||
@@ -32,0 +32,0 @@ return spanRandomBuffer().toString('hex'); |
@@ -44,4 +44,9 @@ "use strict"; | ||
this.constantLabelValues = [...constantLabels.values()]; | ||
this.metricDescriptor = | ||
{ name, description, unit, type, labelKeys: keysAndConstantKeys }; | ||
this.metricDescriptor = { | ||
name, | ||
description, | ||
unit, | ||
type, | ||
labelKeys: keysAndConstantKeys, | ||
}; | ||
this.defaultLabelValues = utils_1.initializeDefaultLabels(this.labelKeysLength); | ||
@@ -106,5 +111,8 @@ } | ||
if (this.labelKeysLength !== labelValues.length) { | ||
throw new Error('Label Keys and Label Values don\'t have same size'); | ||
throw new Error("Label Keys and Label Values don't have same size"); | ||
} | ||
const point = new CumulativePointEntry([...labelValues, ...this.constantLabelValues]); | ||
const point = new CumulativePointEntry([ | ||
...labelValues, | ||
...this.constantLabelValues, | ||
]); | ||
this.registeredPoints.set(hash, point); | ||
@@ -125,3 +133,3 @@ return point; | ||
descriptor: this.metricDescriptor, | ||
timeseries: Array.from(this.registeredPoints, ([_, point]) => point.getTimeSeries(now)) | ||
timeseries: Array.from(this.registeredPoints, ([_, point]) => point.getTimeSeries(now)), | ||
}; | ||
@@ -156,3 +164,3 @@ } | ||
} | ||
const incValue = (val === null || val === undefined) ? 1 : val; | ||
const incValue = val === null || val === undefined ? 1 : val; | ||
this.value += incValue; | ||
@@ -170,3 +178,3 @@ } | ||
points: [{ value: this.value, timestamp: now }], | ||
startTimestamp: this.startTimestamp | ||
startTimestamp: this.startTimestamp, | ||
}; | ||
@@ -173,0 +181,0 @@ } |
@@ -44,4 +44,9 @@ "use strict"; | ||
this.constantLabelValues = [...constantLabels.values()]; | ||
this.metricDescriptor = | ||
{ name, description, unit, type, labelKeys: keysAndConstantKeys }; | ||
this.metricDescriptor = { | ||
name, | ||
description, | ||
unit, | ||
type, | ||
labelKeys: keysAndConstantKeys, | ||
}; | ||
this.startTime = startTime; | ||
@@ -70,3 +75,3 @@ } | ||
if (this.labelKeysLength !== labelValues.length) { | ||
throw new Error('Label Keys and Label Values don\'t have same size'); | ||
throw new Error("Label Keys and Label Values don't have same size"); | ||
} | ||
@@ -94,3 +99,7 @@ if (objOrFn instanceof Function) { | ||
} | ||
this.registeredPoints.set(hash, { labelValues, extractor: this.extractor, prevValue: 0 }); | ||
this.registeredPoints.set(hash, { | ||
labelValues, | ||
extractor: this.extractor, | ||
prevValue: 0, | ||
}); | ||
} | ||
@@ -129,14 +138,15 @@ /** | ||
const newValue = cumulativeEntry.extractor(); | ||
const value = newValue > cumulativeEntry.prevValue ? | ||
newValue : | ||
cumulativeEntry.prevValue; | ||
const value = newValue > cumulativeEntry.prevValue | ||
? newValue | ||
: cumulativeEntry.prevValue; | ||
cumulativeEntry.prevValue = value; | ||
return { | ||
labelValues: [ | ||
...cumulativeEntry.labelValues, ...this.constantLabelValues | ||
...cumulativeEntry.labelValues, | ||
...this.constantLabelValues, | ||
], | ||
points: [{ value, timestamp }], | ||
startTimestamp: this.startTime | ||
startTimestamp: this.startTime, | ||
}; | ||
}) | ||
}), | ||
}; | ||
@@ -143,0 +153,0 @@ } |
@@ -41,4 +41,9 @@ "use strict"; | ||
this.constantLabelValues = [...constantLabels.values()]; | ||
this.metricDescriptor = | ||
{ name, description, unit, type, labelKeys: keysAndConstantKeys }; | ||
this.metricDescriptor = { | ||
name, | ||
description, | ||
unit, | ||
type, | ||
labelKeys: keysAndConstantKeys, | ||
}; | ||
} | ||
@@ -123,4 +128,4 @@ /** | ||
labelValues: [...gaugeEntry.labelValues, ...this.constantLabelValues], | ||
points: [{ value: gaugeEntry.extractor(), timestamp }] | ||
})) | ||
points: [{ value: gaugeEntry.extractor(), timestamp }], | ||
})), | ||
}; | ||
@@ -132,3 +137,3 @@ } | ||
DerivedGauge.OBJECT = 'obj'; | ||
DerivedGauge.ERROR_MESSAGE_INVALID_SIZE = 'Label Keys and Label Values don\'t have same size'; | ||
DerivedGauge.ERROR_MESSAGE_INVALID_SIZE = "Label Keys and Label Values don't have same size"; | ||
DerivedGauge.ERROR_MESSAGE_DUPLICATE_TIME_SERIES = 'A different time series with the same labels already exists.'; | ||
@@ -135,0 +140,0 @@ DerivedGauge.ERROR_MESSAGE_UNKNOWN_INTERFACE = 'Unknown interface/object type'; |
@@ -42,4 +42,9 @@ "use strict"; | ||
this.constantLabelValues = [...constantLabels.values()]; | ||
this.metricDescriptor = | ||
{ name, description, unit, type, labelKeys: keysAndConstantKeys }; | ||
this.metricDescriptor = { | ||
name, | ||
description, | ||
unit, | ||
type, | ||
labelKeys: keysAndConstantKeys, | ||
}; | ||
this.defaultLabelValues = utils_1.initializeDefaultLabels(this.labelKeysLength); | ||
@@ -122,3 +127,3 @@ } | ||
descriptor: this.metricDescriptor, | ||
timeseries: Array.from(this.registeredPoints, ([_, point]) => point.getTimeSeries(timestamp)) | ||
timeseries: Array.from(this.registeredPoints, ([_, point]) => point.getTimeSeries(timestamp)), | ||
}; | ||
@@ -129,3 +134,3 @@ } | ||
Gauge.LABEL_VALUES = 'labelValues'; | ||
Gauge.ERROR_MESSAGE_INVALID_SIZE = 'Label Keys and Label Values don\'t have same size'; | ||
Gauge.ERROR_MESSAGE_INVALID_SIZE = "Label Keys and Label Values don't have same size"; | ||
exports.Gauge = Gauge; | ||
@@ -165,3 +170,3 @@ /** | ||
labelValues: this.labelValues, | ||
points: [{ value: this.value, timestamp }] | ||
points: [{ value: this.value, timestamp }], | ||
}; | ||
@@ -168,0 +173,0 @@ } |
@@ -20,3 +20,3 @@ "use strict"; | ||
const UNSET_LABEL_VALUE = { | ||
value: null | ||
value: null, | ||
}; | ||
@@ -30,3 +30,6 @@ /** | ||
function hashLabelValues(labelValues) { | ||
return labelValues.map(lv => lv.value).sort().join(COMMA_SEPARATOR); | ||
return labelValues | ||
.map(lv => lv.value) | ||
.sort() | ||
.join(COMMA_SEPARATOR); | ||
} | ||
@@ -50,4 +53,5 @@ exports.hashLabelValues = hashLabelValues; | ||
// Checks if the specified collection is a LengthAttributeInterface. | ||
function isLengthAttributeInterface( | ||
// tslint:disable-next-line:no-any | ||
function isLengthAttributeInterface(obj) { | ||
obj) { | ||
return obj && typeof obj.length === 'number'; | ||
@@ -57,4 +61,5 @@ } | ||
// Checks if the specified collection is a LengthMethodInterface. | ||
function isLengthMethodInterface( | ||
// tslint:disable-next-line:no-any | ||
function isLengthMethodInterface(obj) { | ||
obj) { | ||
return obj && typeof obj.length === 'function'; | ||
@@ -64,4 +69,5 @@ } | ||
// Checks if the specified collection is a SizeAttributeInterface. | ||
function isSizeAttributeInterface( | ||
// tslint:disable-next-line:no-any | ||
function isSizeAttributeInterface(obj) { | ||
obj) { | ||
return obj && typeof obj.size === 'number'; | ||
@@ -68,0 +74,0 @@ } |
@@ -95,3 +95,6 @@ "use strict"; | ||
key = key.trim(); | ||
value = value.trim().split('^"|"$').join(''); | ||
value = value | ||
.trim() | ||
.split('^"|"$') | ||
.join(''); | ||
if (!CoreResource.isValidAndNotEmpty(key)) { | ||
@@ -124,3 +127,3 @@ throw new Error(`Label key ${CoreResource.ERROR_MESSAGE_INVALID_CHARS}`); | ||
type: resource.type || otherResource.type, | ||
labels: Object.assign({}, otherResource.labels, resource.labels) | ||
labels: Object.assign({}, otherResource.labels, resource.labels), | ||
}; | ||
@@ -136,4 +139,4 @@ } | ||
static isValid(name) { | ||
return name.length <= CoreResource.MAX_LENGTH && | ||
string_utils_1.StringUtils.isPrintableString(name); | ||
return (name.length <= CoreResource.MAX_LENGTH && | ||
string_utils_1.StringUtils.isPrintableString(name)); | ||
} | ||
@@ -152,6 +155,4 @@ /** | ||
static setup() { | ||
CoreResource.ENV_TYPE = | ||
CoreResource.parseResourceType(process.env.OC_RESOURCE_TYPE); | ||
CoreResource.ENV_LABEL_MAP = | ||
CoreResource.parseResourceLabels(process.env.OC_RESOURCE_LABELS); | ||
CoreResource.ENV_TYPE = CoreResource.parseResourceType(process.env.OC_RESOURCE_TYPE); | ||
CoreResource.ENV_LABEL_MAP = CoreResource.parseResourceLabels(process.env.OC_RESOURCE_LABELS); | ||
} | ||
@@ -168,6 +169,8 @@ } | ||
CoreResource.ERROR_MESSAGE_INVALID_CHARS = 'should be a ASCII string with a length greater than 0 and not exceed ' + | ||
CoreResource.MAX_LENGTH + ' characters.'; | ||
CoreResource.MAX_LENGTH + | ||
' characters.'; | ||
CoreResource.ERROR_MESSAGE_INVALID_VALUE = 'should be a ASCII string with a length not exceed ' + | ||
CoreResource.MAX_LENGTH + ' characters.'; | ||
CoreResource.MAX_LENGTH + | ||
' characters.'; | ||
exports.CoreResource = CoreResource; | ||
//# sourceMappingURL=resource.js.map |
@@ -70,3 +70,3 @@ "use strict"; | ||
// TODO(mayurkale): add description | ||
tagKey => ({ key: tagKey.name, description: '' })) | ||
tagKey => ({ key: tagKey.name, description: '' })), | ||
}; | ||
@@ -80,3 +80,5 @@ } | ||
static tagValuesToLabelValues(tagValues) { | ||
return tagValues.map((tagValue) => ({ value: tagValue ? tagValue.value : null })); | ||
return tagValues.map(tagValue => ({ | ||
value: tagValue ? tagValue.value : null, | ||
})); | ||
} | ||
@@ -83,0 +85,0 @@ } |
@@ -23,5 +23,5 @@ "use strict"; | ||
aggregationData.timestamp = Date.now(); | ||
const value = measurement.measure.type === types_1.MeasureType.DOUBLE ? | ||
measurement.value : | ||
Math.trunc(measurement.value); | ||
const value = measurement.measure.type === types_1.MeasureType.DOUBLE | ||
? measurement.value | ||
: Math.trunc(measurement.value); | ||
switch (aggregationData.type) { | ||
@@ -40,4 +40,4 @@ case types_1.AggregationType.DISTRIBUTION: | ||
static getTagValues(tags, columns) { | ||
return columns.map((tagKey) => (tags.get(tagKey) || | ||
/** replace not found key values by null. */ UNKNOWN_TAG_VALUE)); | ||
return columns.map(tagKey => tags.get(tagKey) || | ||
/** replace not found key values by null. */ UNKNOWN_TAG_VALUE); | ||
} | ||
@@ -59,4 +59,5 @@ static addToDistribution(distributionData, value, attachments) { | ||
const oldMean = distributionData.mean; | ||
distributionData.mean = distributionData.mean + | ||
(value - distributionData.mean) / distributionData.count; | ||
distributionData.mean = | ||
distributionData.mean + | ||
(value - distributionData.mean) / distributionData.count; | ||
distributionData.sumOfSquaredDeviation = | ||
@@ -68,3 +69,4 @@ distributionData.sumOfSquaredDeviation + | ||
// (contextual information), don't record exemplars. | ||
if (attachments && distributionData.exemplars && | ||
if (attachments && | ||
distributionData.exemplars && | ||
distributionData.exemplars.length > bucketIndex) { | ||
@@ -74,3 +76,3 @@ distributionData.exemplars[bucketIndex] = { | ||
timestamp: distributionData.timestamp, | ||
attachments | ||
attachments, | ||
}; | ||
@@ -77,0 +79,0 @@ } |
@@ -60,2 +60,3 @@ "use strict"; | ||
for (const exporter of this.statsEventListeners) { | ||
// tslint:disable-next-line:deprecation | ||
exporter.onRegisterView(view); | ||
@@ -86,2 +87,3 @@ } | ||
for (const view of this.registeredViews[measureName]) { | ||
// tslint:disable-next-line:deprecation | ||
exporter.onRegisterView(view); | ||
@@ -174,2 +176,3 @@ } | ||
for (const exporter of this.statsEventListeners) { | ||
// tslint:disable-next-line:deprecation | ||
exporter.onRecord(views, measurement, tags.tags); | ||
@@ -176,0 +179,0 @@ } |
@@ -29,3 +29,3 @@ "use strict"; | ||
MeasureUnit["MS"] = "ms"; | ||
MeasureUnit["NS"] = "ns"; // nanosecond | ||
MeasureUnit["NS"] = "ns"; | ||
})(MeasureUnit = exports.MeasureUnit || (exports.MeasureUnit = {})); | ||
@@ -32,0 +32,0 @@ /** Describes the types of a Measure. It can be Int64 or a Double type. */ |
@@ -17,2 +17,3 @@ /** | ||
import * as defaultLogger from '../common/console-logger'; | ||
import * as loggerTypes from '../common/types'; | ||
import { Metric } from '../metrics/export/types'; | ||
@@ -68,3 +69,3 @@ import { TagMap } from '../tags/tag-map'; | ||
/** An object to log information to */ | ||
private logger; | ||
logger: loggerTypes.Logger; | ||
/** | ||
@@ -71,0 +72,0 @@ * Creates a new View instance. This constructor is used by Stats. User should |
@@ -88,4 +88,3 @@ "use strict"; | ||
if (!this.tagValueAggregationMap[encodedTags]) { | ||
this.tagValueAggregationMap[encodedTags] = | ||
this.createAggregationData(tagValues); | ||
this.tagValueAggregationMap[encodedTags] = this.createAggregationData(tagValues); | ||
} | ||
@@ -99,3 +98,4 @@ recorder_1.Recorder.addMeasurement(this.tagValueAggregationMap[encodedTags], measurement, attachments); | ||
encodeTagValues(tagValues) { | ||
return tagValues.map((tagValue) => tagValue ? tagValue.value : null) | ||
return tagValues | ||
.map(tagValue => (tagValue ? tagValue.value : null)) | ||
.sort() | ||
@@ -201,4 +201,4 @@ .join(RECORD_SEPARATOR); | ||
timestamp: time_util_1.timestampFromMillis(statsExemplar.timestamp), | ||
attachments: statsExemplar.attachments | ||
} | ||
attachments: statsExemplar.attachments, | ||
}, | ||
}; | ||
@@ -212,3 +212,3 @@ } | ||
const tagKeysCopy = Object.assign([], tagKeys); | ||
tagKeysCopy.forEach((tagKey) => { | ||
tagKeysCopy.forEach(tagKey => { | ||
if (!validation_1.isValidTagKey(tagKey)) { | ||
@@ -215,0 +215,0 @@ throw new Error(`Invalid TagKey name: ${tagKey}`); |
@@ -34,3 +34,3 @@ "use strict"; | ||
const UNLIMITED_PROPAGATION_MD = { | ||
tagTtl: types_1.TagTtl.UNLIMITED_PROPAGATION | ||
tagTtl: types_1.TagTtl.UNLIMITED_PROPAGATION, | ||
}; | ||
@@ -52,4 +52,4 @@ /** | ||
totalChars += validateTag(tagKey, tagsWithMetadata.tagValue); | ||
ret += tagKey.name + TAG_KEY_VALUE_DELIMITER + | ||
tagsWithMetadata.tagValue.value; | ||
ret += | ||
tagKey.name + TAG_KEY_VALUE_DELIMITER + tagsWithMetadata.tagValue.value; | ||
totalTags++; | ||
@@ -76,3 +76,3 @@ } | ||
const listOfTags = str.split(TAG_DELIMITER); | ||
listOfTags.forEach((tag) => { | ||
listOfTags.forEach(tag => { | ||
const keyValuePair = tag.split(TAG_KEY_VALUE_DELIMITER); | ||
@@ -79,0 +79,0 @@ if (keyValuePair.length !== 2) |
@@ -22,3 +22,3 @@ "use strict"; | ||
// The REST indicates the lower 7 bits of each byte. | ||
const REST = 0x7F; | ||
const REST = 0x7f; | ||
/** | ||
@@ -33,3 +33,3 @@ * Encodes a number in a variable-length encoding, 7 bits per byte. | ||
value >>>= 7; | ||
const b = bits + ((value !== 0) ? MSB : 0); | ||
const b = bits + (value !== 0 ? MSB : 0); | ||
ret.push(b); | ||
@@ -36,0 +36,0 @@ } while (value !== 0); |
@@ -21,3 +21,3 @@ "use strict"; | ||
const UNLIMITED_PROPAGATION_MD = { | ||
tagTtl: types_1.TagTtl.UNLIMITED_PROPAGATION | ||
tagTtl: types_1.TagTtl.UNLIMITED_PROPAGATION, | ||
}; | ||
@@ -24,0 +24,0 @@ /** TagMap is maps of TagKey -> TagValueWithMetadata */ |
@@ -25,4 +25,5 @@ "use strict"; | ||
} | ||
return isPrintableString(tagKey.name) && tagKey.name.length > 0 && | ||
tagKey.name.length <= TAG_KEY_MAX_LENGTH; | ||
return (isPrintableString(tagKey.name) && | ||
tagKey.name.length > 0 && | ||
tagKey.name.length <= TAG_KEY_MAX_LENGTH); | ||
} | ||
@@ -35,4 +36,4 @@ exports.isValidTagKey = isValidTagKey; | ||
} | ||
return isPrintableString(tagValue.value) && | ||
tagValue.value.length <= TAG_KEY_MAX_LENGTH; | ||
return (isPrintableString(tagValue.value) && | ||
tagValue.value.length <= TAG_KEY_MAX_LENGTH); | ||
} | ||
@@ -39,0 +40,0 @@ exports.isValidTagValue = isValidTagValue; |
@@ -23,5 +23,5 @@ /** | ||
*/ | ||
export declare type ModuleExportsMapping = { | ||
export interface ModuleExportsMapping { | ||
[key: string]: any; | ||
}; | ||
} | ||
/** This class represent the base to patch plugin. */ | ||
@@ -28,0 +28,0 @@ export declare abstract class BasePlugin implements types.Plugin { |
@@ -106,4 +106,3 @@ "use strict"; | ||
this.logger.debug('loading File %s', extraModulesList[moduleName]); | ||
extraModules[moduleName] = | ||
require(path.join(basedir, extraModulesList[moduleName])); | ||
extraModules[moduleName] = require(path.join(basedir, extraModulesList[moduleName])); | ||
} | ||
@@ -110,0 +109,0 @@ catch (e) { |
@@ -41,10 +41,10 @@ /** | ||
} | ||
export declare type PluginConfig = { | ||
export interface PluginConfig { | ||
[key: string]: any; | ||
applyCustomAttributesOnSpan?: CustomAttributeFunction; | ||
}; | ||
export declare type NamedPluginConfig = { | ||
} | ||
export interface NamedPluginConfig { | ||
module: string; | ||
config: PluginConfig; | ||
}; | ||
} | ||
/** | ||
@@ -55,8 +55,8 @@ * Type PluginNames: each key should be the name of the module to trace, | ||
*/ | ||
export declare type PluginNames = { | ||
export interface PluginNames { | ||
[pluginName: string]: string | NamedPluginConfig; | ||
}; | ||
export declare type PluginInternalFilesVersion = { | ||
} | ||
export interface PluginInternalFilesVersion { | ||
[pluginName: string]: string; | ||
}; | ||
} | ||
/** | ||
@@ -66,4 +66,4 @@ * Each key should be the name of the module to trace, and its value | ||
*/ | ||
export declare type PluginInternalFiles = { | ||
export interface PluginInternalFiles { | ||
[versions: string]: PluginInternalFilesVersion; | ||
}; | ||
} |
@@ -10,4 +10,2 @@ import { Logger } from '../../../common/types'; | ||
private endedLocal; | ||
/** Indicates if this span was forced to end */ | ||
private truncated; | ||
/** The Span ID of this span */ | ||
@@ -14,0 +12,0 @@ readonly id: string; |
@@ -22,3 +22,3 @@ "use strict"; | ||
const STATUS_OK = { | ||
code: types.CanonicalCode.OK | ||
code: types.CanonicalCode.OK, | ||
}; | ||
@@ -33,5 +33,2 @@ /** Implementation for the SpanBase class that does not record trace events. */ | ||
this.endedLocal = false; | ||
/** Indicates if this span was forced to end */ | ||
// @ts-ignore | ||
this.truncated = false; | ||
/** An object to log information to */ | ||
@@ -128,3 +125,3 @@ this.logger = noop_logger_1.noopLogger; | ||
options: 0, | ||
traceState: this.traceState | ||
traceState: this.traceState, | ||
}; | ||
@@ -131,0 +128,0 @@ } |
@@ -15,4 +15,2 @@ import { Logger } from '../../common/types'; | ||
private endedLocal; | ||
/** Indicates if this span was forced to end */ | ||
private truncated; | ||
/** A list of child spans which are immediate, local children of this span */ | ||
@@ -19,0 +17,0 @@ private spansLocal; |
@@ -24,3 +24,3 @@ "use strict"; | ||
const STATUS_OK = { | ||
code: types.CanonicalCode.OK | ||
code: types.CanonicalCode.OK, | ||
}; | ||
@@ -35,5 +35,2 @@ /** Defines a base model for spans. */ | ||
this.endedLocal = false; | ||
/** Indicates if this span was forced to end */ | ||
// @ts-ignore | ||
this.truncated = false; | ||
/** An object to log information to */ | ||
@@ -166,3 +163,3 @@ this.logger = noop_logger_1.noopLogger; | ||
options: 0x1, | ||
traceState: this.traceState | ||
traceState: this.traceState, | ||
}; | ||
@@ -263,3 +260,3 @@ } | ||
parentSpanId: this.parentSpanId, | ||
traceState: this.traceState | ||
traceState: this.traceState, | ||
}); | ||
@@ -294,5 +291,7 @@ if (this.isRootSpan()) | ||
truncate() { | ||
this.truncated = true; | ||
this.end(); | ||
this.logger.debug('truncating %s %o', this.className, { id: this.id, name: this.name }); | ||
this.logger.debug('truncating %s %o', this.className, { | ||
id: this.id, | ||
name: this.name, | ||
}); | ||
} | ||
@@ -299,0 +298,0 @@ /** |
@@ -60,13 +60,8 @@ "use strict"; | ||
this.logger = this.config.logger || logger.logger(); | ||
this.sampler = | ||
sampler_1.SamplerBuilder.getSampler(config.samplingRate || sampler_1.DEFAULT_SAMPLING_RATE); | ||
this.sampler = sampler_1.SamplerBuilder.getSampler(config.samplingRate || sampler_1.DEFAULT_SAMPLING_RATE); | ||
if (config.traceParams) { | ||
this.activeTraceParams.numberOfAnnontationEventsPerSpan = | ||
sampler_1.TraceParamsBuilder.getNumberOfAnnotationEventsPerSpan(config.traceParams); | ||
this.activeTraceParams.numberOfAttributesPerSpan = | ||
sampler_1.TraceParamsBuilder.getNumberOfAttributesPerSpan(config.traceParams); | ||
this.activeTraceParams.numberOfMessageEventsPerSpan = | ||
sampler_1.TraceParamsBuilder.getNumberOfMessageEventsPerSpan(config.traceParams); | ||
this.activeTraceParams.numberOfLinksPerSpan = | ||
sampler_1.TraceParamsBuilder.getNumberOfLinksPerSpan(config.traceParams); | ||
this.activeTraceParams.numberOfAnnontationEventsPerSpan = sampler_1.TraceParamsBuilder.getNumberOfAnnotationEventsPerSpan(config.traceParams); | ||
this.activeTraceParams.numberOfAttributesPerSpan = sampler_1.TraceParamsBuilder.getNumberOfAttributesPerSpan(config.traceParams); | ||
this.activeTraceParams.numberOfMessageEventsPerSpan = sampler_1.TraceParamsBuilder.getNumberOfMessageEventsPerSpan(config.traceParams); | ||
this.activeTraceParams.numberOfLinksPerSpan = sampler_1.TraceParamsBuilder.getNumberOfLinksPerSpan(config.traceParams); | ||
} | ||
@@ -94,4 +89,9 @@ return this; | ||
startRootSpan(options, fn) { | ||
const spanContext = options.spanContext || | ||
{ spanId: '', traceId: uuid.v4().split('-').join('') }; | ||
const spanContext = options.spanContext || { | ||
spanId: '', | ||
traceId: uuid | ||
.v4() | ||
.split('-') | ||
.join(''), | ||
}; | ||
const parentSpanId = spanContext.spanId; | ||
@@ -111,3 +111,3 @@ const traceId = spanContext.traceId; | ||
if (defaultAttributes) { | ||
Object.keys(defaultAttributes).forEach((key) => { | ||
Object.keys(defaultAttributes).forEach(key => { | ||
rootSpan.addAttribute(key, defaultAttributes[key]); | ||
@@ -183,3 +183,3 @@ }); | ||
if (defaultAttributes) { | ||
Object.keys(defaultAttributes).forEach((key) => { | ||
Object.keys(defaultAttributes).forEach(key => { | ||
span.addAttribute(key, defaultAttributes[key]); | ||
@@ -193,6 +193,6 @@ }); | ||
// If users set a specific sampler in the TraceOptions, use it. | ||
if (options && options.samplingRate !== undefined && | ||
if (options && | ||
options.samplingRate !== undefined && | ||
options.samplingRate !== null) { | ||
return sampler_1.SamplerBuilder.getSampler(options.samplingRate) | ||
.shouldSample(traceId); | ||
return sampler_1.SamplerBuilder.getSampler(options.samplingRate).shouldSample(traceId); | ||
} | ||
@@ -199,0 +199,0 @@ let propagatedSample = null; |
@@ -59,3 +59,3 @@ "use strict"; | ||
return self.contextManager.runAndReturn(() => { | ||
return super.startRootSpan(options, (root) => { | ||
return super.startRootSpan(options, root => { | ||
return fn(root); | ||
@@ -87,5 +87,5 @@ }); | ||
clearCurrentTrace() { | ||
// TODO: Remove null reference and ts-ignore check. | ||
//@ts-ignore | ||
this.currentRootSpan = null; | ||
if (this.contextManager.active) { | ||
this.contextManager.set('rootspan', null); | ||
} | ||
} | ||
@@ -92,0 +92,0 @@ /** |
@@ -28,3 +28,6 @@ "use strict"; | ||
return { | ||
traceId: uuid.v4().split('-').join(''), | ||
traceId: uuid | ||
.v4() | ||
.split('-') | ||
.join(''), | ||
spanId: crypto.randomBytes(8).toString('hex'), | ||
@@ -31,0 +34,0 @@ }; |
@@ -59,3 +59,5 @@ "use strict"; | ||
shouldSample(traceId) { | ||
const LOWER_BYTES = traceId ? ('0000000000000' + traceId).slice(-LOWER_BYTE_COUNT) : '0'; | ||
const LOWER_BYTES = traceId | ||
? ('0000000000000' + traceId).slice(-LOWER_BYTE_COUNT) | ||
: '0'; | ||
// tslint:disable-next-line:ban Needed to parse hexadecimal. | ||
@@ -62,0 +64,0 @@ const LOWER_LONG = parseInt(LOWER_BYTES, 16); |
{ | ||
"name": "@opencensus/core", | ||
"version": "0.0.14", | ||
"version": "0.0.15", | ||
"description": "OpenCensus is a toolkit for collecting application performance and behavior data.", | ||
@@ -62,4 +62,4 @@ "main": "build/src/index.js", | ||
"@types/uuid": "^3.4.3", | ||
"codecov": "^3.4.0", | ||
"gts": "^0.9.0", | ||
"codecov": "^3.5.0", | ||
"gts": "^1.0.0", | ||
"intercept-stdout": "^0.1.2", | ||
@@ -66,0 +66,0 @@ "mocha": "^6.1.0", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
380046
9428