Skip to content

Commit

Permalink
refactor: remove built in payload truncation logic (elastic#498)
Browse files Browse the repository at this point in the history
This will instead be handled by the elastic-apm-http-client module in
the future.
  • Loading branch information
watson committed Nov 13, 2018
1 parent 6d44905 commit 7dab951
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 136 deletions.
6 changes: 2 additions & 4 deletions lib/agent.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ var Instrumentation = require('./instrumentation')
var parsers = require('./parsers')
var stackman = require('./stackman')
var symbols = require('./symbols')
var truncate = require('./truncate')

var IncomingMessage = http.IncomingMessage
var ServerResponse = http.ServerResponse
Expand Down Expand Up @@ -145,7 +144,8 @@ Agent.prototype.start = function (opts) {
hostname: this._conf.hostname,

// Sanitize conf
truncateStringsAt: config.INTAKE_STRING_MAX_SIZE, // TODO: Do we need to set this (it's the default value)
truncateKeywordsAt: config.INTAKE_STRING_MAX_SIZE,
truncateErrorMessagesAt: this._conf.errorMessageMaxLength,

// HTTP conf
secretToken: this._conf.secretToken,
Expand Down Expand Up @@ -318,8 +318,6 @@ Agent.prototype.captureError = function (err, opts, cb) {
return
}

truncate.error(error, agent._conf)

if (agent._apmServer) {
agent.logger.info(`Sending error ${id} to Elastic APM`)
agent._apmServer.sendError(error, function () {
Expand Down
4 changes: 0 additions & 4 deletions lib/instrumentation/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ var hook = require('require-in-the-middle')
var semver = require('semver')

var Transaction = require('./transaction')
var truncate = require('../truncate')
var shimmer = require('./shimmer')

var MODULES = [
Expand Down Expand Up @@ -98,7 +97,6 @@ Instrumentation.prototype.addEndedTransaction = function (transaction) {
if (this._started) {
var payload = agent._filters.process(transaction._encode()) // TODO: Update filter to expect this format
if (!payload) return agent.logger.debug('transaction ignored by filter %o', { id: transaction.id })
truncate.transaction(payload)
agent.logger.debug('sending transaction %o', { id: transaction.id })
agent._apmServer.sendTransaction(payload)
} else {
Expand All @@ -124,8 +122,6 @@ Instrumentation.prototype.addEndedSpan = function (span) {
return
}

truncate.span(payload)

agent.logger.debug('sending span %o', { trans: span.transaction.id, name: span.name, type: span.type })
if (agent._apmServer) agent._apmServer.sendSpan(payload)
})
Expand Down
127 changes: 0 additions & 127 deletions lib/truncate.js

This file was deleted.

2 changes: 1 addition & 1 deletion test/instrumentation/modules/hapi.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ test('extract URL from request', function (t) {
t.equal(request.url.search, '?foo=bar')
t.equal(request.url.raw, '/captureError?foo=bar')
t.equal(request.url.hostname, 'localhost')
t.equal(request.url.port, String(server.info.port))
t.equal(request.url.port, server.info.port)
t.equal(request.socket.encrypted, false)
server.stop(noop)
t.end()
Expand Down

0 comments on commit 7dab951

Please sign in to comment.