Skip to content

Commit

Permalink
bug: fix span histogram export + apm version not being set
Browse files Browse the repository at this point in the history
  • Loading branch information
vmarchaud committed Jan 9, 2019
1 parent e9e1f8d commit e5b8767
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
5 changes: 3 additions & 2 deletions src/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,11 @@ export default class Configuration {
}

try {
const pkg = require('../package.json')
const prefix = __dirname.replace(/\\/g,'/').indexOf('/build/') >= 0 ? '../../' : '../'
const pkg = require(prefix + 'package.json')
conf.pmx_version = pkg.version || null
} catch (err) {
// ignore
debug('Failed to fetch current apm version: ', err.message)
}

if (conf.isModule === true) {
Expand Down
14 changes: 7 additions & 7 deletions src/utils/transactionAggregator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,9 @@ export class TransactionAggregator extends EventEmitter2 {

if (!matched) {
this.cache.routes[path] = []
this.mergeTrace(this.cache.routes[path], packet, process)
this.mergeTrace(this.cache.routes[path], packet)
} else {
this.mergeTrace(this.cache.routes[matched], packet, process)
this.mergeTrace(this.cache.routes[matched], packet)
}

return this.cache
Expand All @@ -198,7 +198,7 @@ export class TransactionAggregator extends EventEmitter2 {
* @param {Object} aggregated previous aggregated route
* @param {Object} trace
*/
mergeTrace (aggregated, trace, process) {
mergeTrace (aggregated, trace) {
if (!aggregated || !trace) return

// if the trace doesn't any spans stop aggregation here
Expand Down Expand Up @@ -405,14 +405,14 @@ export class TransactionAggregator extends EventEmitter2 {

// get data for each span
variance.spans.forEach((oldSpan) => {
const span = fclone({
const span: Span = fclone({
name: oldSpan.name,
labels: oldSpan.labels,
kind: oldSpan.kind,
startTime: oldSpan.startTime,
min: oldSpan.histogram.getMin(),
max: oldSpan.histogram.getMax(),
median: oldSpan.histogram.percentiles([0.5])[0.5]
min: oldSpan.histogram ? oldSpan.histogram.getMin() : undefined,
max: oldSpan.histogram ? oldSpan.histogram.getMax() : undefined,
median: oldSpan.histogram ? oldSpan.histogram.percentiles([0.5])[0.5] : undefined
})
tmp.spans.push(span)
})
Expand Down

0 comments on commit e5b8767

Please sign in to comment.