惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

量子位
WordPress大学
WordPress大学
小众软件
小众软件
云风的 BLOG
云风的 BLOG
IT之家
IT之家
人人都是产品经理
人人都是产品经理
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Last Week in AI
Last Week in AI
博客园 - 【当耐特】
T
Tailwind CSS Blog
阮一峰的网络日志
阮一峰的网络日志
V
V2EX
宝玉的分享
宝玉的分享
博客园 - Franky
F
Fortinet All Blogs
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
GbyAI
GbyAI
Hugging Face - Blog
Hugging Face - Blog
Jina AI
Jina AI
D
Docker
博客园 - 聂微东
C
Check Point Blog
H
Help Net Security

Datadog | The Monitor blog

Introducing our open source AI-native SAST Instrument and monitor Boomi integration flows with OpenTelemetry and Datadog Not all index scans are equal: How we cut query latency by over 99% Platform engineering metrics: What to measure and what to ignore Integrate Recorded Future threat intelligence with Datadog Cloud SIEM CI/CD security: threat modeling using a MITRE-style threat matrix CI/CD security: How to secure your GitHub ecosystem Ingress NGINX is EOL: A practical guide for migrating to Kubernetes Gateway API Operating agentic AI with Amazon Bedrock AgentCore and Datadog LLM Observability: Lessons from NTT DATA Introducing the Datadog Code Security MCP Capture and analyze custom heatmaps in Session Replay Understand session replays faster with AI summaries and smart chapters Monitor ClickHouse query performance with Datadog Database Monitoring How we designed empathetic alert sounds for on-call engineers Search and act across Datadog to resolve issues faster with Bits Assistant Measure the business impact of every product change with Datadog Experiments Analyzing round trip query latency Configuring JavaScript caches for better performance Introducing Bits AI Dev Agent for Code Security Datadog achieves ISO 42001 certification for responsible AI Monitor Nutanix clusters, hosts, and VMs with Datadog Monitor Juniper Mist in Datadog A new Host Map for modern infrastructure Annotate traces to improve LLM quality with Datadog LLM Observability What’s new in Cloud SIEM: AI-powered investigations, enhanced threat intelligence, and scalable security operations Explore Kubernetes with native OpenTelemetry data Monitor Oracle Fusion Cloud Applications with Datadog Announcing the Datadog Terraform provider v4.0.0 Scaling Kubernetes workloads on custom metrics How to design cloud environments for AI-powered threat analysis
Introducing developer mode for the Agent
2015-07-15 · via Datadog | The Monitor blog

The Datadog Agent is deployed on a lot of machines, so its performance is very important. As you would imagine, we carefully profile the Agent’s code for efficiency and speed before each release.

Because the Agent is open source, it benefits from contributions made by developers all over the world, which is great. What’s not as great is that until now there was no easy and consistent way for the community to profile their Agent code before submitting a pull request. This led to unnecessarily long GitHub conversations with contributors while we pinned down and resolved inefficiencies. That’s why, as of the most recent release (version 5.4), the Agent ships with profiling tools baked in. We call the new functionality “developer mode.”

Who is this for?

Anyone actively working on or contributing to the Datadog Agent code will find the new developer mode to be an essential tool. Whether modifying the core Agent or creating a custom Agent Check, you will be able to see the impact your code changes have on performance.

Which metrics are supported?

A wide variety of metrics are available, but here are a few of the most important ones:

  • CPU usage
  • Memory consumption
  • Threads in use
  • Network connections open
  • Total time to run configured checks

Profile individual Agent Checks

Let’s say you just wrote your own Check. Before submitting the pull request, you can (and should) run:

python agent.py check <check_name> --profile

This command will run the specified Agent Check just one time, and then print collected metrics and profiling information (run time, memory use, etc.) to stdout. Once your Check looks good, you may then want to turn on full developer mode and profile everything.

Profile everything with developer mode

To enable developer mode for the Agent itself as well as all Agent Checks, open your datadog.conf and add the following line:

developer_mode: yes

After saving the changes to datadog.conf, be sure to restart the Agent.

Once enabled, developer mode will begin collecting all Agent statistics.

You can also enable developer mode with the addition of the --profile command line flag:

python agent.py start --profile

Without any additional configuration, the profiling metrics collected in developer mode are available in Datadog under the datadog.agent.* namespace.

Datadog dashboard showing metrics from developer mode

Locally, the additional information can be found in the collector.log file located at /var/log/datadog/collector.log on Linux or C:\ProgramData\Datadog\logs\collector.log on Windows. Output can also be piped to stdout or another process.

Contribute!

After your new Agent code or Check is profiled and ready for contribution, please send us a pull request; instructions here.

Getting the most out of developer mode

By default, developer mode will report memory usage before and after running the Agent (to help spot leaks), various statistics including total run time, memory use, disk I/O if available, and the top 20 calls returned by pstats.

Additionally, since developer mode is built on top of the popular Python profiling library psutil (version 2.1.1), any psutil method supported by your environment is available. You can also report these additional metrics by editing the agen_etrics.yaml file, located in the conf.d directory. Please refer to the documentation on the Datadog Agent Project Wiki for more information on configuring agen_etrics.

Digging into collector.log

Because data collected while developer mode is enabled is sent directly to Datadog, you may never need to open the collector.log. Nonetheless, some example excerpts from collector.log are included below.

Memory leak checks

This block shows memory usage before and after a disk check.

2015-06-22 16:25:05 Eastern Daylight Time | INFO | checks(__init__.pyc:692) | disk

Memory Before (RSS): 18685952

Memory After (RSS): 18722816

Difference (RSS): 36864

Memory Before (VMS): 2533859328

Memory After (VMS): 2534907904

Difference (VMS): 1048576

Collected stats

Agent stats include memory use, I/O, and so on.

2015-06-22 16:25:05 Eastern Daylight Time | INFO | checks.collector( collector.pyc:507) |

AGENT STATS:

[ ( 'datadog.agent.collector.memory_info.rss',

1435004705,

28442624,

{ 'hostname': 'vagelitab', 'type': 'gauge'}),

( 'datadog.agent.collector.io_counters.write_bytes',

1435004705,

608.1111111111111,

{ 'hostname': 'vagelitab', 'type': 'gauge'})

]

Top function calls

The log captures the top 20 function calls, as ranked by cumulative time.

2015-06-22 16:25:05 Eastern Daylight Time | DEBUG | collector(profile.pyc:37) | 2236475 function calls (2220860 primitive calls) in 383.244 seconds

Ordered by: cumulative time

List reduced from 930 to 20 due to restriction <20>

Ncalls tottime percall cumtime percall filename:lineno(function)

20 299.986 14.999 299.986 14.999 {time.sleep}

21 0.051 0.002 83.260 3.965 checks\collector.pyc:249(run)

147 0.004 0.000 68.352 0.465 wmi.pyc:801(query)

147 0.154 0.001 68.348 0.465 wmi.pyc:1005(query) …

Where can I learn more?

Documentation on using developer mode is available at the Datadog Agent Project Wiki. A full list of process-level methods supported by psutil can be found at pypi.org.