当前位置: 首页>>代码示例>>Python>>正文


Python datadog.initialize方法代码示例

本文整理汇总了Python中datadog.initialize方法的典型用法代码示例。如果您正苦于以下问题:Python datadog.initialize方法的具体用法?Python datadog.initialize怎么用?Python datadog.initialize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在datadog的用法示例。


在下文中一共展示了datadog.initialize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

# 需要导入模块: import datadog [as 别名]
# 或者: from datadog import initialize [as 别名]
def main():
    global DD_API_KEY, REPO, TRELLO_KEY, TRELLO_TOKEN

    if len(sys.argv) > 1:
        REPO = sys.argv[1]

    try:
        DD_API_KEY = os.environ['DD_API_KEY']
        TRELLO_KEY = os.environ['TRELLO_KEY']
        TRELLO_TOKEN = os.environ['TRELLO_TOKEN']
    except KeyError as e:
        env_var = str(e).replace('KeyError:', '', 1).strip(' "\'')
        raise EnvironmentError(f'Missing required environment variable `{env_var}`')

    dd.initialize(api_key=DD_API_KEY)

    pull_request = get_latest_pr()

    if should_create_card(pull_request):
        create_trello_card(pull_request)
    else:
        pr_url = pull_request.get('html_url')
        print(f'Not creating a card for Pull Request {pr_url}') 
开发者ID:DataDog,项目名称:integrations-core,代码行数:25,代码来源:remind.py

示例2: __init__

# 需要导入模块: import datadog [as 别名]
# 或者: from datadog import initialize [as 别名]
def __init__(self):
        datadog.initialize()
        self.set_ndays(90) # default is 90 days
        self.print_configured = True
        self.map_aws_dd = None 
开发者ID:autofitcloud,项目名称:isitfit,代码行数:7,代码来源:metrics_datadog.py

示例3: datadog_api

# 需要导入模块: import datadog [as 别名]
# 或者: from datadog import initialize [as 别名]
def datadog_api():
    import datadog
    datadog.initialize()
    return datadog.api 
开发者ID:autofitcloud,项目名称:isitfit,代码行数:6,代码来源:test_metricsDatadog_datadogApiWrap_functional.py

示例4: __init__

# 需要导入模块: import datadog [as 别名]
# 或者: from datadog import initialize [as 别名]
def __init__(self, bot):
        self.bot = bot
        self.tags = []
        self.task = bot.loop.create_task(self.loop_task())
        self.settings = dataIO.load_json(JSON)

        try:
            self.analytics = CogAnalytics(self)
        except Exception as error:
            self.bot.logger.exception(error)
            self.analytics = None

        datadog.initialize(statsd_host=self.settings['HOST']) 
开发者ID:calebj,项目名称:calebj-cogs,代码行数:15,代码来源:datadog.py

示例5: initialize_datadog

# 需要导入模块: import datadog [as 别名]
# 或者: from datadog import initialize [as 别名]
def initialize_datadog(environment):
    datadog_enabled = environment.public_vars.get('DATADOG_ENABLED', False)
    if datadog_enabled:
        datadog.initialize(
            environment.get_vault_var('secrets.DATADOG_API_KEY'),
            environment.get_vault_var('secrets.DATADOG_APP_KEY')
        )
        return True 
开发者ID:dimagi,项目名称:commcare-cloud,代码行数:10,代码来源:downtime.py

示例6: send

# 需要导入模块: import datadog [as 别名]
# 或者: from datadog import initialize [as 别名]
def send(env, bucket, key, status):
    if "DATADOG_API_KEY" in os.environ:
        datadog.initialize()  # by default uses DATADOG_API_KEY

        result_metric_name = "unknown"

        metric_tags = ["env:%s" % env, "bucket:%s" % bucket, "object:%s" % key]

        if status == AV_STATUS_CLEAN:
            result_metric_name = "clean"
        elif status == AV_STATUS_INFECTED:
            result_metric_name = "infected"
            datadog.api.Event.create(
                title="Infected S3 Object Found",
                text="Virus found in s3://%s/%s." % (bucket, key),
                tags=metric_tags,
            )

        scanned_metric = {
            "metric": "s3_antivirus.scanned",
            "type": "counter",
            "points": 1,
            "tags": metric_tags,
        }
        result_metric = {
            "metric": "s3_antivirus.%s" % result_metric_name,
            "type": "counter",
            "points": 1,
            "tags": metric_tags,
        }
        print("Sending metrics to Datadog.")
        datadog.api.Metric.send([scanned_metric, result_metric]) 
开发者ID:upsidetravel,项目名称:bucket-antivirus-function,代码行数:34,代码来源:metrics.py

示例7: main

# 需要导入模块: import datadog [as 别名]
# 或者: from datadog import initialize [as 别名]
def main():
    datadog.initialize(**CONFIG['datadog'])
    args.command(args) 
开发者ID:trueaccord,项目名称:DogPush,代码行数:5,代码来源:dogpush.py

示例8: __init__

# 需要导入模块: import datadog [as 别名]
# 或者: from datadog import initialize [as 别名]
def __init__(self, bot):
        self.bot = bot
        self.tags = []
        self.task = bot.loop.create_task(self.loop_task())
        self.settings = dataIO.load_json(JSON)
        datadog.initialize(statsd_host=self.settings['HOST']) 
开发者ID:smlbiobot,项目名称:SML-Cogs,代码行数:8,代码来源:ddlogmsg.py

示例9: initialize

# 需要导入模块: import datadog [as 别名]
# 或者: from datadog import initialize [as 别名]
def initialize(cls):
		# Init method for keys

		options = {
			'api_key': '****',
			'app_key': '****'
		}
		initialize(**options) 
开发者ID:DataDog,项目名称:Miscellany,代码行数:10,代码来源:merge_screenboards.py

示例10: create

# 需要导入模块: import datadog [as 别名]
# 或者: from datadog import initialize [as 别名]
def create(cls, dash_list, config):
		# Main method to init, build and perform the API call

		cls.initialize()
		cls.builder(dash_list, config)
		output = api.Screenboard.create(board_title=cls.title,
			     widgets=cls.dash['widgets'], template_variables=cls.dict_tem_var, width=cls.dash['width'])
		print "http://app.datadoghq.com/screen/" + str(output['id']) 
开发者ID:DataDog,项目名称:Miscellany,代码行数:10,代码来源:merge_screenboards.py

示例11: __init__

# 需要导入模块: import datadog [as 别名]
# 或者: from datadog import initialize [as 别名]
def __init__(self, api_key, app_key):
        #To strongly suggest that outside objects don't access a property or method
        #prefix it with a double underscore, this will perform name mangling on the
        #attribute in question. 
        self.__api_key = api_key
        self.__app_key = app_key

        myKeys = {
            'api_key':self.__api_key,
            'app_key':self.__app_key
            }

        initialize(**myKeys) #call the API's initialize function that unpacks the myKeys dict, and uses those key-value pairs as parameters

    #function that takes a JSON object and converts it to a python dictionary 
开发者ID:DataDog,项目名称:Miscellany,代码行数:17,代码来源:csvmod.py

示例12: api

# 需要导入模块: import datadog [as 别名]
# 或者: from datadog import initialize [as 别名]
def api(self):
    """The Datadog API stub for interacting with Datadog."""
    if self.__api is None:
      datadog.initialize(api_key=self.__arguments['api_key'],
                         app_key=self.__arguments['app_key'],
                         host_name=self.__arguments['host'])
      self.__api = datadog.api
    return self.__api 
开发者ID:spinnaker,项目名称:spinnaker-monitoring,代码行数:10,代码来源:datadog_service.py

示例13: get_stats

# 需要导入模块: import datadog [as 别名]
# 或者: from datadog import initialize [as 别名]
def get_stats():
    """
    Configure a shared ThreadStats instance for datadog
    """
    global __stats

    if __stats is not None:
        return __stats

    app_channel = taskcluster.secrets["APP_CHANNEL"]

    if taskcluster.secrets.get("DATADOG_API_KEY"):
        datadog.initialize(
            api_key=taskcluster.secrets["DATADOG_API_KEY"],
            host_name=f"coverage.{app_channel}.moz.tools",
        )
    else:
        logger.info("No datadog credentials")

    # Must be instantiated after initialize
    # https://datadogpy.readthedocs.io/en/latest/#datadog-threadstats-module
    __stats = datadog.ThreadStats(
        constant_tags=[config.PROJECT_NAME, f"channel:{app_channel}"]
    )
    __stats.start(flush_in_thread=True)
    return __stats 
开发者ID:mozilla,项目名称:code-coverage,代码行数:28,代码来源:datadog.py

示例14: __init__

# 需要导入模块: import datadog [as 别名]
# 或者: from datadog import initialize [as 别名]
def __init__(self):
        datadog.initialize(api_key=settings["datadog_key"])

        self.after_upgrade_success = partial(self.create_event, "success")
        self.after_upgrade_failure = partial(self.create_event, "error") 
开发者ID:kiwicom,项目名称:crane,代码行数:7,代码来源:datadog.py

示例15: v2_playbook_on_play_start

# 需要导入模块: import datadog [as 别名]
# 或者: from datadog import initialize [as 别名]
def v2_playbook_on_play_start(self, play):
        # On Ansible v2, Ansible doesn't set `self.play` automatically
        self.play = play
        if self.disabled:
            return

        # Read config and hostvars
        config_path = os.environ.get('ANSIBLE_DATADOG_CALLBACK_CONF_FILE', os.path.join(os.path.dirname(__file__), "datadog_callback.yml"))
        api_key, dd_url, dd_site = self._load_conf(config_path)

        # If there is no api key defined in config file, try to get it from hostvars
        if api_key == '':
            hostvars = self.play.get_variable_manager()._hostvars

            if not hostvars:
                print("No api_key found in the config file ({0}) and hostvars aren't set: disabling Datadog callback plugin".format(config_path))
                self.disabled = True
            else:
                try:
                    api_key = hostvars['localhost']['datadog_api_key']
                    if not dd_url:
                        dd_url = hostvars['localhost'].get('datadog_url')
                    if not dd_site:
                        dd_site = hostvars['localhost'].get('datadog_site')
                except Exception as e:
                    print('No "api_key" found in the config file ({0}) and "datadog_api_key" is not set in the hostvars: disabling Datadog callback plugin'.format(config_path))
                    self.disabled = True

        if not dd_url:
            if dd_site:
                dd_url = "https://api."+ dd_site
            else:
                dd_url = DEFAULT_DD_URL # default to Datadog US

        # Set up API client and send a start event
        if not self.disabled:
            datadog.initialize(api_key=api_key, api_host=dd_url)

            self.send_playbook_event(
                'Ansible play "{0}" started in playbook "{1}" by "{2}" against "{3}"'.format(
                    self.play.name,
                    self._playbook_name,
                    getpass.getuser(),
                    self._inventory_name),
                event_type='start',
            ) 
开发者ID:DataDog,项目名称:ansible-datadog-callback,代码行数:48,代码来源:datadog_callback.py


注:本文中的datadog.initialize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。