<commit_before>'use strict'

var uuid = require('node-uuid')
var debug = require('debug')('opbeat')
var Trace = require('./trace')

module.exports = Transaction

function Transaction (agent, name, type, result) {
  Object.defineProperty(this, 'name', {
    configurable: true,
    enumerable: true,
    get: function () {
      return this._customName || this._defaultName
    },
    set: function (name) {
      if (this.ended) {
        debug('tried to set transaction.name on already ended transaction %o', { uuid: this._uuid })
        return
      }
      debug('setting transaction name %o', { uuid: this._uuid, name: name })
      this._customName = name
    }
  })

  this._defaultName = name || ''
  this._customName = ''
  this.type = type
  this.result = result
  this.traces = []
  this.ended = false
  this._abortTime = 0<commit_msg>core: freeze transaction result when ended<commit_after>'use strict'

var uuid = require('node-uuid')
var debug = require('debug')('opbeat')
var Trace = require('./trace')

module.exports = Transaction

function Transaction (agent, name, type, result) {
  Object.defineProperty(this, 'name', {
    configurable: true,
    enumerable: true,
    get: function () {
      return this._customName || this._defaultName
    },
    set: function (name) {
      if (this.ended) {
        debug('tried to set transaction.name on already ended transaction %o', { uuid: this._uuid })
        return
      }
      debug('setting transaction name %o', { uuid: this._uuid, name: name })
      this._customName = name
    }
  })

  Object.defineProperty(this, 'result', {
    configurable: true,
    enumerable: true,
    get: function () {
      return this._result
    },
    set: function (result) {
      if (this.ended) {
        debug('tried to set transaction.result on already ended transaction %o', { uuid: this._uuid })
        return
      }
      debug('setting transaction result %o', { uuid: this._uuid, result: result })
      this._result = result
    }
  })

  this._defaultName = name || ''
  this._customName = ''
  this.type = type
  this.result = result
  this.traces = []
  this.ended = false
  this._abortTime = 0
{'fraction_non_alphanumeric': 0.1319796954314721, 'fraction_numerical': 0.0009229349330872173, 'mean_word_length': 2.8783542039355994, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2628535', 'n_tokens_mistral': 640, 'n_tokens_neox': 644, 'n_words': 179}