---
title: Code Snippets and Context Links
description: >-
  View inline code snippets and links to your source code from stack traces,
  profiles, test runs, and code findings across Datadog products.
breadcrumbs: Docs > Source Code Integration > Code Snippets and Context Links
---

> For the complete documentation index, see [llms.txt](https://docs.datadoghq.com/llms.txt).

# 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](https://docs.datadoghq.com/error_tracking.md), 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](https://docs.datadoghq.com/source_code/source-code-management.md). Most products also need Git information attached to their data. For example, APM-based products use [service mapping](https://docs.datadoghq.com/source_code/service-mapping.md), and RUM uses source maps uploaded with Git metadata.

## View code snippets and context links by product{% #view-code-snippets-and-context-links-by-product %}

Select a product to see how to view code snippets and context links:

{% tab title="App and API Protection Monitoring" %}
You can see links from errors in your security signals' associated stack traces to their source repository in [App and API Protection Monitoring](https://docs.datadoghq.com/security/application_security.md).

1. Navigate to [Security > App and API Protection](https://app.datadoghq.com/security/appsec) and select a security signal.
1. Scroll down to the Traces section on the Related Signals tab and click an associated stack trace.
1. 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.

{% image
   source="https://docs.dd-static.net/images/source_code_integration/asm-signal-trace-blur.494869c8efe583544f6444d10afd8f2f.png?auto=format&fit=max&w=850 1x, https://docs.dd-static.net/images/source_code_integration/asm-signal-trace-blur.494869c8efe583544f6444d10afd8f2f.png?auto=format&fit=max&w=850&dpr=2 2x"
   alt="Link to GitHub from App and API Protection Monitoring" /%}

{% /tab %}

{% tab title="Code Security" %}
You can see links from failed Static Analysis and Software Composition Analysis scans to their source repository in [Code Security](https://docs.datadoghq.com/security/code_security.md).

1. Navigate to [Software Delivery > Code Security](https://app.datadoghq.com/ci/code-analysis) and select a repository.
1. 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.

{% image
   source="https://docs.dd-static.net/images/source_code_integration/code-analysis-scan.17c308ad97f4cc3066032d86da508718.png?auto=format&fit=max&w=850 1x, https://docs.dd-static.net/images/source_code_integration/code-analysis-scan.17c308ad97f4cc3066032d86da508718.png?auto=format&fit=max&w=850&dpr=2 2x"
   alt="Link to GitHub from the Code Security Code Vulnerabilities view" /%}

For more information, see the [Code Security documentation](https://docs.datadoghq.com/security/code_security.md).
{% /tab %}

{% tab title="Continuous Profiler" %}
You can see source code previews directly in [Continuous Profiler](https://docs.datadoghq.com/profiler.md) flame graphs.

1. Navigate to [APM > Profiles > Explorer](https://app.datadoghq.com/profiling/explorer).
1. Select the service you want to investigate.
1. Hover your cursor over a method in the flame graph.
1. Press `Opt` (on macOS) or `Ctrl` (on other operating systems) to lock the tooltip so you can interact with its contents.
1. 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.
1. After authorizing, the source code preview appears in the tooltip.
1. Click the file link in the tooltip to open the full source code file in your repository.

{% image
   source="https://docs.dd-static.net/images/source_code_integration/profiler-source-code-preview-2.8b4b78067f60b13c21c9ac1930393e1d.png?auto=format&fit=max&w=850 1x, https://docs.dd-static.net/images/source_code_integration/profiler-source-code-preview-2.8b4b78067f60b13c21c9ac1930393e1d.png?auto=format&fit=max&w=850&dpr=2 2x"
   alt="Source code preview in the Continuous Profiler" /%}

{% /tab %}

{% tab title="Dynamic Instrumentation" %}
You can see full source code files in [Dynamic Instrumentation](https://docs.datadoghq.com/dynamic_instrumentation.md) when creating or editing an instrumentation (dynamic log, metric, span, or span tags).

### Create new instrumentation{% #create-new-instrumentation %}

1. Navigate to [APM > Dynamic Instrumentation](https://app.datadoghq.com/dynamic-instrumentation/events).
1. Select Create New Instrumentation and choose a service to instrument.
1. Search for and select a source code filename or method.

### View or edit instrumentation{% #view-or-edit-instrumentation %}

1. Navigate to [APM > Dynamic Instrumentation](https://app.datadoghq.com/dynamic-instrumentation/events).
1. Select an existing instrumentation from the list, then click View Events.
1. Select the instrumentation card to view its location in the source code.

{% image
   source="https://docs.dd-static.net/images/source_code_integration/dynamic-instrumentation-create-new.dcebe1a40c8bd08d0f7ffa02ead649c8.png?auto=format&fit=max&w=850 1x, https://docs.dd-static.net/images/source_code_integration/dynamic-instrumentation-create-new.dcebe1a40c8bd08d0f7ffa02ead649c8.png?auto=format&fit=max&w=850&dpr=2 2x"
   alt="A source code file displayed in Dynamic Instrumentation while creating a new instrumentation" /%}

For more information, see the [Dynamic Instrumentation documentation](https://docs.datadoghq.com/dynamic_instrumentation.md).
{% /tab %}

{% tab title="Error Tracking" %}
You can see links from stack frames to their source repository in [Error Tracking](https://docs.datadoghq.com/tracing/error_tracking.md).

1. Navigate to [APM > Error Tracking](https://app.datadoghq.com/apm/error-tracking).
1. Click an issue. The Issue Details panel appears on the right.
1. 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.

{% image
   source="https://docs.dd-static.net/images/source_code_integration/error-tracking-panel-full.292df325ea0fea24f20042b6f776e604.png?auto=format&fit=max&w=850 1x, https://docs.dd-static.net/images/source_code_integration/error-tracking-panel-full.292df325ea0fea24f20042b6f776e604.png?auto=format&fit=max&w=850&dpr=2 2x"
   alt="A view repository button with three options (view file, view blame, and view commit) available on the right side of an error stack trace in Error Tracking, along with inline code snippets in the stack trace" /%}

{% /tab %}

{% tab title="RUM" %}
You can see links from stack frames to their source repository in [Error Tracking for RUM](https://docs.datadoghq.com/real_user_monitoring/error_tracking.md).

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](https://docs.datadoghq.com/real_user_monitoring/guide/upload-javascript-source-maps.md) to be uploaded with Git information using the [`datadog-ci sourcemaps upload`](https://github.com/DataDog/datadog-ci/tree/master/packages/datadog-ci/src/commands/sourcemaps#link-errors-with-your-source-code) command
- **React Native**: Requires [source maps and debug symbols](https://docs.datadoghq.com/real_user_monitoring/application_monitoring/react_native/error_tracking.md#get-deobfuscated-stack-traces) to be uploaded with Git information
- **Android**: Requires [Proguard mapping files](https://docs.datadoghq.com/real_user_monitoring/application_monitoring/android/error_tracking.md) to be uploaded with Git information
- **Electron**: Requires [source maps](https://docs.datadoghq.com/real_user_monitoring/application_monitoring/electron/error_tracking.md#upload-source-maps) to be uploaded with Git information

**Note**: Source code integration is not supported for iOS RUM errors.

1. Navigate to [Digital Experience > Error Tracking](https://app.datadoghq.com/rum/error-tracking).
1. Click an issue. The Issue Details panel appears on the right.
1. 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.

{% image
   source="https://docs.dd-static.net/images/source_code_integration/error-tracking-panel-full.292df325ea0fea24f20042b6f776e604.png?auto=format&fit=max&w=850 1x, https://docs.dd-static.net/images/source_code_integration/error-tracking-panel-full.292df325ea0fea24f20042b6f776e604.png?auto=format&fit=max&w=850&dpr=2 2x"
   alt="A view repository button with options to view the file, blame, and commit available on the right side of a RUM error stack trace in Error Tracking, along with inline code snippets" /%}

{% /tab %}

{% tab title="Serverless Monitoring" %}
You can see links from errors in your Lambda functions' associated stack traces to their source repository in [Serverless Monitoring](https://docs.datadoghq.com/serverless.md).

1. Navigate to [Infrastructure > Serverless](https://app.datadoghq.com/functions?cloud=aws&entity_view=lambda_functions) and click the AWS tab.
1. Click a Lambda function and click the Open Trace button for an invocation with an associated stack trace.
1. 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.

{% video
   url="https://docs.dd-static.net/images/source_code_integration/serverless-aws-function-errors.mp4" /%}

{% /tab %}

{% tab title="Test Optimization" %}
You can see links from failed test runs to their source repository in [Test Optimization](https://docs.datadoghq.com/tests.md).

1. Navigate to [Software Delivery > Test Optimization > Test Runs](https://app.datadoghq.com/ci/test-runs) and select a failed test run.
1. 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.

{% image
   source="https://docs.dd-static.net/images/source_code_integration/test_run_blurred.2c4aefe2ce327300b7dcd3ba921474cf.png?auto=format&fit=max&w=850 1x, https://docs.dd-static.net/images/source_code_integration/test_run_blurred.2c4aefe2ce327300b7dcd3ba921474cf.png?auto=format&fit=max&w=850&dpr=2 2x"
   alt="Link to GitHub from the CI Visibility Explorer" /%}

For more information, see [Enhancing Developer Workflows with Datadog](https://docs.datadoghq.com/tests/developer_workflows.md#open-tests-in-github-and-your-ide).
{% /tab %}

## Further reading{% #further-reading %}

Additional helpful documentation, links, and articles:

- [Learn about Error Tracking for Backend Services](https://docs.datadoghq.com/tracing/error_tracking.md)
- [Learn about Error Tracking for Logs](https://docs.datadoghq.com/logs/error_tracking.md)
- [Learn about Error Tracking for RUM](https://docs.datadoghq.com/real_user_monitoring/error_tracking.md)
- [Learn about the Continuous Profiler](https://docs.datadoghq.com/profiler.md)
- [Learn about Serverless Monitoring](https://docs.datadoghq.com/serverless/aws_lambda/configuration.md?tab=datadogcli#link-errors-to-your-source-code)
- [Learn about Test Optimization](https://docs.datadoghq.com/tests/developer_workflows.md)
- [Learn about Code Security](https://docs.datadoghq.com/security/code_security.md)
- [Learn about Application Security Monitoring](https://docs.datadoghq.com/security/application_security.md)
- [Learn about Dynamic Instrumentation](https://docs.datadoghq.com/dynamic_instrumentation.md)
- [Fix production bugs efficiently with Datadog Live Debugging](https://www.datadoghq.com/blog/live-debugging/)
