Code Snippets and Context Links
Code Snippets and Context Links Code snippets and context links connect what you see in Datadog to the source code behind it: Code snippets display the relevant lines of code inline in Datadog, so you can read the code without leaving the page. Context links take you from a stack frame, flame graph, test run, or code finding in Datadog to the file, Git blame, or commit in your repository. For example, in Error Tracking , you can preview code snippets in a stack trace or click View on a frame to open the file in your repository.
To use code snippets and context links, connect your Git repositories with a source code management provider integration . Most products also need Git information attached to their data. For example, APM-based products use service mapping , and RUM uses source maps uploaded with Git metadata. View code snippets and context links by product Select a product to see how to view code snippets and context links: You can see links from errors in your security signals’ associated stack traces to their source repository in App and API Protection Monitoring .
Navigate to Security > App and API Protection and select a security signal. Scroll down to the Traces section on the Related Signals tab and click an associated stack trace. If you’re using a source code management integration, click Connect to preview on stack frames. You can see inline code snippets directly in the stack trace. Otherwise, you can click the View button on the right of a frame or select View file , View Git blame , or View commit to be redirected to your source code management tool.
You can see links from failed Static Analysis and Software Composition Analysis scans to their source repository in Code Security . Navigate to Software Delivery > Code Security and select a repository. In the Code Vulnerabilities or Code Quality view, click a code vulnerability or violation. In the Details section, if you’re using a source code management integration, click Connect to preview . You can see inline code snippets highlighting the exact lines of code that triggered the vulnerability or violation.
Otherwise, you can click the View button on the right of a frame or select View file , View Git blame , or View commit to be redirected to your source code management tool. For more information, see the Code Security documentation . You can see source code previews directly in Continuous Profiler flame graphs. Navigate to APM > Profiles > Explorer . Select the service you want to investigate. Hover your cursor over a method in the flame graph.
Press Opt (on macOS) or Ctrl (on other operating systems) to lock the tooltip so you can interact with its contents. If prompted, click Connect to preview . The first time you do this for a repository, you may be redirected to your source code management provider to Authorize the Datadog application. After authorizing, the source code preview appears in the tooltip. Click the file link in the tooltip to open the full source code file in your repository.
You can see full source code files in Dynamic Instrumentation when creating or editing an instrumentation (dynamic log, metric, span, or span tags). Create new instrumentation Navigate to APM > Dynamic Instrumentation . Select Create New Instrumentation and choose a service to instrument. Search for and select a source code filename or method. View or edit instrumentation Navigate to APM > Dynamic Instrumentation . Select an existing instrumentation from the list, then click View Events .
Select the instrumentation card to view its location in the source code. For more information, see the Dynamic Instrumentation documentation . You can see links from stack frames to their source repository in Error Tracking . Navigate to APM > Error Tracking . Click an issue. The Issue Details panel appears on the right. Under Latest Event , if you’re using a source code management integration, click Connect to preview on stack frames.
You can see inline code snippets directly in the stack trace. Otherwise, you can click the View button on the right of a frame or select View file , View Git blame , or View commit to be redirected to your source code management tool. You can see links from stack frames to their source repository in Error Tracking for RUM . Source code integration is supported for the following RUM platforms when source maps or debug symbols are uploaded with Git metadata: Browser : Requires JavaScript source maps to be uploaded with Git information using the datadog-ci sourcemaps upload command React Native : Requires source maps and debug symbols to be uploaded with Git information Android : Requires Proguard mapping files to be uploaded with Git information Electron : Requires source maps to be uploaded with Git information Note : Source code integration is not supported for iOS RUM errors.
Navigate to Digital Experience > Error Tracking . Click an issue. The Issue Details panel appears on the right. Under Latest Available Errors or error samples, if you’re using a source code management integration, click Connect to preview on stack frames. You can see inline code snippets directly in the stack trace. Otherwise, you can click the View button on the right of a frame or select View file , View Git blame , or View commit to be redirected to your source code management tool.
You can see links from errors in your Lambda functions’ associated stack traces to their source repository in Serverless Monitoring . Navigate to Infrastructure > Serverless and click the AWS tab. Click a Lambda function and click the Open Trace button for an invocation with an associated stack trace. If you’re using a source code management integration, click Connect to preview on stack frames. You can see inline code snippets directly in the stack trace.
Otherwise, you can click the View button on the right of a frame or select View file , View Git blame , or View commit to be redirected to your source code management tool. You can see links from failed test runs to their source repository in Test Optimization . Navigate to Software Delivery > Test Optimization > Test Runs and select a failed test run. If you’re using a source code management integration, click Connect to preview on stack frames.
You can see inline code snippets directly in the stack trace. Otherwise, you can click the View button on the right of a frame or select View file , View Git blame , or View commit to be redirected to your source code management tool. For more information, see Enhancing Developer Workflows with Datadog . Further reading Additional helpful documentation, links, and articles: Learn about Error Tracking for Backend Services DOCUMENTATION Learn about Error Tracking for Logs DOCUMENTATION Learn about Error Tracking for RUM DOCUMENTATION Learn about the Continuous Profiler DOCUMENTATION Learn about Serverless Monitoring DOCUMENTATION Learn about Test Optimization DOCUMENTATION Learn about Code Security DOCUMENTATION Learn about Application Security Monitoring DOCUMENTATION Learn about Dynamic Instrumentation DOCUMENTATION Fix production bugs efficiently with Datadog Live Debugging BLOG 1 2 rulesets : - %!s(<nil>) # Rules to enforce .
Request a personalized demo Get Started with Datadog