andrewgross / pyrelic

New Relic Python API
MIT License
21 stars 11 forks source link

Is Client.get_metric_list() deprecated in 0.7.2? #20

Closed ykyuen closed 9 years ago

ykyuen commented 10 years ago

i want to query the apdex score but the following program throws an error.

from django.core.management.base import BaseCommand
from pyrelic import Client

class Command(BaseCommand):
  args = 'Arguments is not needed'
  help = 'Generate a random number and push to StatsD server.'

  def handle(self, *args, **options):
    c = Client(account_id='xxx', api_key='xxx')

    # List some metrics
    metrics = c.get_metric_list('<app_id>', re='Apdex')

    for k,v in metrics.iteritems():
      print "Metric Name: %s" % k
      print "Available Fields: %s " % v

but it throws

AttributeError: 'Client' object has no attribute 'get_metric_list'
andrewgross commented 9 years ago

Sorry for the delayed response. It looks like the name is now get_metric_names. Unsure when or why I changed this, sorry for breaking backwards compat.

def get_metric_names(self, agent_id, re=None, limit=5000):
        """
        Requires: application ID
        Optional: Regex to filter metric names, limit of results
        Returns: A dictionary,
                    key => metric name,
                    value => list of fields available for a given metric
        Method: Get
        Restrictions: Rate limit to 1x per minute
        Errors: 403 Invalid API Key, 422 Invalid Parameters
        Endpoint: api.newrelic.com
        """
ykyuen commented 9 years ago

got it. thx for your reply. =D