Method: NewRelic::Agent::Configuration::Manager#truncate

Defined in:
lib/new_relic/agent/configuration/manager.rb

#truncate(text, key = nil) ⇒ Object

[View source]

347
348
349
350
351
352
353
354
355
356
357
358
359
# File 'lib/new_relic/agent/configuration/manager.rb', line 347

def truncate(text, key = nil)
  if text.length > MAX_LABEL_LENGTH
    if key
      msg = "The value for the label '#{key}' is longer than the allowed #{MAX_LABEL_LENGTH} and will be truncated. Value = '#{text}'"
    else
      msg = "Label name longer than the allowed #{MAX_LABEL_LENGTH} will be truncated. Name = '#{text}'"
    end
    NewRelic::Agent.logger.warn(msg)
    text[0..MAX_LABEL_LENGTH - 1]
  else
    text
  end
end