DTrace
Dynamic tracing framework for kernel and applications
title: "DTrace" type: doc version: 1 created: 2026-02-28 author: "Wikipedia contributors" status: active scope: public tags: ["command-line-software", "sun-microsystems-software", "free-system-software", "debuggers", "aspect-oriented-programming", "software-using-the-common-development-and-distribution-license", "linux-kernel-features"] description: "Dynamic tracing framework for kernel and applications" topic_path: "technology/operating-systems" source: "https://en.wikipedia.org/wiki/DTrace" license: "CC BY-SA 4.0" wikipedia_page_id: 0 wikipedia_revision_id: 0
::summary Dynamic tracing framework for kernel and applications ::
::data[format=table title="Infobox software"]
| Field | Value |
|---|---|
| name | DTrace |
| screenshot | DTrace on Windows v10.0.19041.1 1115x966.png |
| caption | The DTrace command |
| author | Bryan Cantrill, Adam Leventhal, Mike Shapiro (Sun Microsystems) |
| developer | Sun Microsystems, Oracle, Microsoft |
| released | |
| repo | |
| programming language | C |
| operating system | Solaris, illumos, macOS, FreeBSD, NetBSD, Linux,{{cite web |
| url | http://blogs.oracle.com/wim/entry/trying_out_dtrace |
| author | Wim Coekaerts |
| title | Trying out dtrace |
| date | 2011-10-09 |
| access-date | 2018-02-15 |
| website | blogs.oracle.com}} Windows |
| genre | Tracing |
| license | CDDL, GPLv2, UPL |
| website | |
| :: |
| name = DTrace
| screenshot = DTrace on Windows v10.0.19041.1 1115x966.png
| screenshot size =
| caption = The DTrace command
| author = Bryan Cantrill, Adam Leventhal, Mike Shapiro (Sun Microsystems)
| developer = Sun Microsystems, Oracle, Microsoft
| released =
| repo =
| programming language = C
| operating system = Solaris, illumos, macOS, FreeBSD, NetBSD, Linux,{{cite web
|url=http://blogs.oracle.com/wim/entry/trying_out_dtrace
|author = Wim Coekaerts
|title = Trying out dtrace
|date = 2011-10-09
|access-date = 2018-02-15
|website = blogs.oracle.com}} Windows
| genre = Tracing
| license = CDDL, GPLv2, UPL
| website =
DTrace is a comprehensive dynamic tracing framework originally created by Sun Microsystems for troubleshooting kernel and application problems on production systems in real time.
Originally developed for Solaris, it has since been released under the free Common Development and Distribution License (CDDL) in OpenSolaris and its descendant illumos, and has been ported to several other Unix-like systems. Windows Server systems from Windows Server 2025 will have DTrace as part of the system.
DTrace can be used to get a global overview of a running system, such as the amount of memory, CPU time, filesystem and network resources used by the active processes. It can also provide much more fine-grained information, such as a log of the arguments with which a specific function is being called, or a list of the processes accessing a specific file.
In 2010, Oracle Corporation acquired Sun Microsystems and announced the discontinuation of OpenSolaris. As a community effort of some core Solaris engineers to create a truly open source Solaris, illumos operating system was announced via webinar on Thursday, 3 August 2010, as a fork on OpenSolaris OS/Net consolidation, including DTrace technology.
In October 2011, Oracle announced the porting of DTrace to Linux, and in 2019 official DTrace for Fedora is available on GitHub. For several years an unofficial DTrace port to Linux was available, with no changes in licensing terms.
In August 2017, Oracle released DTrace kernel code under the GPLv2+ license, and user space code under GPLv2 and UPL licensing.{{cite web |url = https://gnu.wildebeest.org/blog/mjw/2018/02/14/dtrace-for-linux-oracle-does-the-right-thing/ |title = dtrace for linux; Oracle does the right thing |access-date = 2018-02-14 |first = Mark J. |last = Wielaard |date = 2018-02-14 |work = Mark J. Wielaard blog
In September 2016 the OpenDTrace effort began on GitHub with both code and comprehensive documentation of the system's internals. The OpenDTrace effort maintains the original CDDL licensing for the code from OpenSolaris with additional code contributions coming under a BSD 2 Clause license. The goal of OpenDTrace is to provide an OS agnostic, portable implementation of DTrace that is acceptable to all consumers, including macOS, FreeBSD, OpenBSD, NetBSD, and Linux as well as embedded systems.
Description
Sun Microsystems designed DTrace to give operational insights that allow users to tune and troubleshoot applications and the OS itself.
Testers write tracing programs (also referred to as scripts) using the D programming language (not to be confused with other programming languages named "D"). The language, inspired by C, includes added functions and variables specific to tracing. D programs resemble AWK programs in structure; they consist of a list of one or more probes (instrumentation points), and each probe is associated with an action. These probes are comparable to a pointcut in aspect-oriented programming. Whenever the condition for the probe is met, the associated action is executed (the probe "fires"). A typical probe might fire when a certain file is opened, or a process is started, or a certain line of code is executed. A probe that fires may analyze the run-time situation by accessing the call stack and context variables and evaluating expressions; it can then print out or log some information, record it in a database, or modify context variables. The reading and writing of context variables allows probes to pass information to each other, allowing them to cooperatively analyze the correlation of different events.
Special consideration has been taken to make DTrace safe to use in a production environment. For example, there is minimal probe effect when tracing is underway, and no performance impact associated with any disabled probe; this is important since there are tens of thousands of DTrace probes that can be enabled. New probes can also be created dynamically.
Command line examples
DTrace scripts can be invoked directly from the command line, providing one or more probes and actions as arguments. Some examples:
::code[lang=bash]
New processes with arguments
dtrace -n 'proc:::exec-success { trace(curpsinfo->pr_psargs); }'
Files opened by process
dtrace -n 'syscall::open*:entry { printf("%s %s",execname,copyinstr(arg0)); }'
Syscall count by program
dtrace -n 'syscall:::entry { @num[execname] = count(); }'
Syscall count by syscall
dtrace -n 'syscall:::entry { @num[probefunc] = count(); }'
Syscall count by process
dtrace -n 'syscall:::entry { @num[pid,execname] = count(); }'
Disk size by process
dtrace -n 'io:::start { printf("%d %s %d",pid,execname,args[0]->b_bcount); }'
Pages paged in by process
dtrace -n 'vminfo:::pgpgin { @pg[execname] = sum(arg0); }' ::
Scripts can also be written which can reach hundreds of lines in length, although typically only tens of lines are needed for advanced troubleshooting and analysis. Over 200 examples of open source DTrace scripts can be found in the DTraceToolkit,{{cite web | url = http://www.brendangregg.com/dtracetoolkit.html | title = DTraceToolkit | publisher = Brendan Gregg | access-date=2014-06-08 | url = http://my.safaribooksonline.com/book/operating-systems-and-server-administration/solaris/9780137061839 | title = DTrace: Dynamic Tracing in Oracle Solaris, Mac OS X and FreeBSD | publisher = Safari Books | isbn = 978-0132091510 | date = 2011 | access-date = 2011-01-03 | archive-date = 2011-04-06 | archive-url = https://web.archive.org/web/20110406173133/http://my.safaribooksonline.com/book/operating-systems-and-server-administration/solaris/9780137061839 | url-status = dead
Supported platforms
DTrace first became available for use in November 2003, and was formally released as part of Sun's Solaris 10 in January 2005. DTrace was the first component of the OpenSolaris project to have its source code released under the Common Development and Distribution License (CDDL).
DTrace is an integral part of illumos and related distributions.
DTrace is a standard part of FreeBSD and NetBSD.
Apple added DTrace support in Mac OS X 10.5 "Leopard", including a GUI called Instruments.{{cite web |url=https://www.apple.com/macosx/developertools/instruments.html |title=Mac OS X Leopard - Developer Tools - Instruments |publisher=Apple Inc. |access-date=2007-10-19 |archive-url=https://web.archive.org/web/20071024144916/http://www.apple.com/macosx/developertools/instruments.html |archive-date=2007-10-24 |url-status=dead | url = https://opensource.apple.com/source/dtrace/ | title = Mac OS X DTrace | publisher = Apple Inc. | access-date = 2010-05-31 | archive-date = 2022-06-05 | archive-url = https://web.archive.org/web/20220605233550/https://opensource.apple.com/source/dtrace/ | url-status = dead | url = http://dtrace.org/blogs/ahl/2008/01/18/mac-os-x-and-the-missing-probes/ | title = Mac OS X and the missing probes | publisher = Leventhal, Adam H. | date = January 18, 2008 | access-date = 2008-01-20 | url = http://dtrace.org/blogs/ahl/2008/06/07/apple-updates-dtrace/ | title = Apple Updates DTrace | publisher = Leventhal, Adam H. | date = June 7, 2008 | access-date = 2008-06-16
The Linux port of DTrace has been available since 2008;{{cite web | url = http://www.crisp.demon.co.uk/tools.html | title = CRiSP tools download page. | access-date = 2011-03-02 | archive-date = 2020-11-16 | archive-url = https://web.archive.org/web/20201116162408/http://www.crisp.demon.co.uk/tools.html | url-status = dead
In 2007, a developer at QNX Software Systems announced on his blog that he and a colleague were working on incorporating DTrace into the QNX operating system.
Oracle Corporation added beta DTrace support for Oracle Linux in 2011, General availability was announced in December 2012.
On March 11, 2019, Microsoft released a version of DTrace for Windows 10 insider builds. Microsoft included DTrace as a built-in tool in Windows Server 2025.
Language and application providers
With a supported language provider, DTrace can retrieve context of the code, including function, source file, and line number location. Further, dynamic memory allocation and garbage collection can be made available if supported by the language. Supported language providers include assembly language, C, C++, Java, Erlang, JavaScript, Perl, PHP, Python, Ruby, shell script, and Tcl.
Application providers allow DTrace to follow the operation of applications through system calls and into the kernel. Applications that offer DTrace application providers include MySQL, PostgreSQL, Oracle Database, Oracle Grid Engine, and Firefox.
Authors and awards
DTrace was designed and implemented by Bryan Cantrill, Mike Shapiro, and Adam Leventhal.
The authors received recognition in 2005 for the innovations in DTrace from InfoWorld and Technology Review.{{cite web | url = http://www.technologyreview.com/tr35/Profile.aspx?Cand=T&TRID=91 | title = Tracing software in real time | access-date = 2007-03-31 | year = 2005 | work = Technology Review | publisher = MIT |url = http://www.infoworld.com/reports/31SRinnovators2005.html |title = Innovation is alive and well in 2005 |access-date = 2007-03-31 |last = McAllister |first = Neil |date = August 2005 |work = InfoWorld |publisher = IDG |url-status = dead |archive-url = https://web.archive.org/web/20051123190528/http://www.infoworld.com/reports/31SRinnovators2005.html |archive-date = 2005-11-23 | url = https://www.wsj.com/public/article/SB115755300770755096-R2Ct41cQ4ZIPMwk4_xh0xU_HnQI_20061011.html?mod=tff_main_tff_top | title = The Winners Are... | access-date = 2007-03-31 | last = Totty | first = Michael |date=September 2006 | work = The Wall Street Journal | publisher = Dow Jones & Company, Inc. | url = http://www.usenix.org/events/usenix08/index.html | title = 2008 USENIX Annual Technical Conference (USENIX '08) | access-date = 2008-11-26 | year = 2008
References
- {{cite journal | first = Bryan | last = Cantrill |date=February 2006 | title = Hidden in Plain Sight | journal = ACM Queue | volume = 4 | issue = 1 | pages = 26–36 | doi = 10.1145/1117389.1117401 | url = http://queue.acm.org/detail.cfm?id=1117401 | access-date = 2017-12-19 |doi-access = free
- {{cite conference | author = Bryan M. Cantrill, Michael W. Shapiro and Adam H. Leventhal |date=June 2004 | title = Dynamic Instrumentation of Production Systems | conference = Proceedings of the 2004 USENIX Annual Technical Conference | url = http://www.usenix.org/event/usenix04/tech/general/full_papers/cantrill/cantrill_html/ | access-date = 2006-09-08
Notes
References
- (2018-10-08). "OS internals: Technical deep-dive into operating system innovations - BRK3365". Microsoft Ignite Channel.
- D'Amore, Garrett. (3 August 2010). "Illumos - Hope and Light Springs Anew - Presented by Garrett D'Amore". illumos.org.
- (2011-10-04). "Oracle To Bring Dtrace To Linux".
- [https://github.com/dtrace4linux/linux] "The original DTrace is licensed under Sun's (now Oracle) CDDL license. Original copyrights are left intact. No GPL code is incorporated into the release, to avoid legal conflicts."
- (2009-01-06). "FreeBSD 7.1-RELEASE Announcement".
- "NetBSD source changes, 21 February 2010".
- (November 8, 2007). "DTrace on QNX!".
- (2012). "DTrace on Linux".
- Koch, Zeynep. (December 12, 2012). "Announcement: DTrace for Oracle Linux General Availability".
- [https://web.archive.org/web/20190913144624/https://oss.oracle.com/git/?p=dtrace-modules.git DTrace module source code for Linux]
- Pulapaka, Hari. (March 11, 2019). "DTrace on Windows".
- (2024-04-19). "DTrace".
- Gatlan, Sergiu. (2024-11-04). "Windows Server 2025 released—here are the new features".
- (2011). "DTrace: Dynamic Tracing in Oracle Solaris, Mac OS X and FreeBSD". [[Prentice Hall]].
- "Open Grid Scheduler / Grid Engine Documentation". Open Grid Scheduler.
- "DTrace – MDN". Mozilla.
::callout[type=info title="Wikipedia Source"] This article was imported from Wikipedia and is available under the Creative Commons Attribution-ShareAlike 4.0 License. Content has been adapted to SurfDoc format. Original contributors can be found on the article history page. ::