joola / joola.sdk

Joola's Software Development Kit (SDK)
https://joo.la
Other
3 stars 3 forks source link

Conflicting metric keys #146

Open orweinberger opened 9 years ago

orweinberger commented 9 years ago

I have two collections with a metric called count. When I attempt and calculate a division of the two I always get 1 back. This happens becuase Joola gets the same metric value even if two different collections are defined if the metric key is identical.

For example, running this will return 1:

query: {
          timeframe: 'last_day',
          interval: 'hour',
          dimensions: ['timestamp'],
          metrics: [
            {
              key:'avgTxBlock',
              formula: {
                dependsOn: [
                  {
                    key: 'count',
                    collection: 'tx'
                  },
                  {
                    key: 'count',
                    collection: 'block'
                  }
                ],
                run: 'function(tx,block) { return tx/block }'
              }
            }
          ],
          realtime: true
      }

However, running this returns the correct value:

query: {
          timeframe: 'last_day',
          interval: 'hour',
          dimensions: ['timestamp'],
          metrics: [
            {
              key:'avgTxBlock',
              formula: {
                dependsOn: [
                  {
                    key: 'count',
                    collection: 'tx'
                  },
                  {
                    key: '_count',
                    dependsOn: ['count'],
                    collection: 'block'
                  }
                ],
                run: 'function(tx,block) { return tx/block }'
              }
            }
          ],
          realtime: true
      }