class SemanticLogger::Metric::Signalfx

def batch(logs)

Logs in batches
def batch(logs)
  message = formatter.batch(logs, self)
  logger.trace(message)
  post(message, full_url)
end

def initialize(token:,

end
sleep 1
logger.measure_info(metric: 'Common/User/authorize') do
Similarly with a measure block which automatically supplies the duration:

logger.info(metric: 'Application.counter', metric_amount: 1, dimensions: {class: 'Common::User', action: 'authorize'})
logger.info(metric: 'Application.average', metric_amount: 1.4, dimensions: {class: 'Common::User', action: 'authorize'})
Then it is translated into the following 2 log entries under the covers:

logger.info(metric: 'Common/User/authorize', duration: 1.4)
When a duration is supplied and no dimensions are supplied:

logger.info(metric: 'Filters.count', metric_amount: 23, dimensions: {user: 'jbloggs'})
Example, Counter metric with a count other than 1:

logger.info(metric: 'Filters.count', dimensions: {user: 'jbloggs'})
Example, Counter metric:

logger.info(metric: 'Filters.average', metric_amount: 1.2, dimensions: {user: 'jbloggs'})
Example, Gauge metric, supplying the duration in `metric_amount`:

the above logic will _not_ be applied.
If dimensions are added to the metric, then the metric will be sent as-is and

Using a `count` of a `gauge` in a chart will significantly under-count the number of occurrences.
Unfortunately this doubles the number of metrics, but it is the way Signalfx works.
duration is included in the metric, otherwise it is not possible to chart counts of the metric.
When sending a metric to Signalfx, it is necessary to send both a `gauge` and a `counter` when a

Notes:

Default: https://ingest.signalfx.com
For historical data use: https://backfill.signalfx.com/v1/backfill
Override the SignalFx service url.
url: [String]

Default: SemanticLogger.application
Name of this application to send as a dimension.
application: [String]

Default: SemanticLogger.host
Name of this host to send as a dimension.
host: [String]

The Proc must return true or false.
Proc: Only include log messages where the supplied Proc returns true.
regular expression. All other messages will be ignored.
RegExp: Only include log messages where the class name matches the supplied
filter: [Regexp|Proc]

Example: [:user_id, :state]
By default `application` and `host` are always included as dimensions in all forwarded metrics.
Dimensions to forward to signalfx when they are present in the named tags of any log message.
dimensions: [Array]

Obtain the Signalfx token via the Signalfx Web UI under `Organization` -> `Access Tokens`.
Access Token to use for sending metrics.
token: [String]
Parameters:

Create SignalFx metrics appender.
def initialize(token:,
               dimensions: nil,
               url: "https://ingest.signalfx.com",
               formatter: nil,
               **args,
               &block)
  formatter ||= SemanticLogger::Formatters::Signalfx.new(token: token, dimensions: dimensions)
  super(url: url, formatter: formatter, **args, &block)
  @header["X-SF-TOKEN"] = token
  @full_url             = "#{url}/#{END_POINT}"
end

def log(log)

def log(log)
  message = formatter.call(log, self)
  logger.trace(message)
  post(message, full_url)
end

def should_log?(log)

Only forward log entries that contain metrics.
def should_log?(log)
  log.metric && meets_log_level?(log) && !filtered?(log)
end