xerions / metricman

9 stars 4 forks source link

Variable name clashing in subscription DSL #23

Open surik opened 8 years ago

surik commented 8 years ago

For example this module:

defmodule Mapping do
  use Metricman.Subscription

  @reporter expose: [:exometer_report_influxdb]

  scope [:sessions], @reporter do
    map [:total],       [:sessions, :total]
    map [:access_class, '$access_class'], [:sessions, :access_class '$access_class']
  end
end

Will generate get/2 function which works like:

> Mapping.get [:sessions, :access_class, :online], :counter
{:ok, {[:sessions, :online, :access_class], [:value], [expose: [:exometer_report_influxdb]]}}

but it is not was expected. The correct result should looks like:

{:ok, {[:sessions, :access_class, :online], [:value], [expose: [:exometer_report_influxdb]]}}

It happens because we have names clashing: :access_class and '$access_class'. If we rename '$access_class' to '$class' all works correct.