To collect trace data from your applications and send it to Cloud Trace, you
can instrument your code with [OpenTelemetry](https://opentelemetry.io) or
language-specific Cloud Client Libraries. You can use the setup guides and library
resources in this document to instrument C++, Go, Java, Node.js, Python, Ruby,
Rust, and .NET applications.

## When to instrument your application

> [!NOTE]
> **Note:** Trace data is automatically captured for some configurations and for some Google Cloud services, so you might not need to instrument your application. For more information, see [Configurations with automatic tracing](https://docs.cloud.google.com/trace/docs/overview.md.txt#configurations_with_automatic_tracing).


Instrument your application to collect specific information that helps you understand its
performance and troubleshoot failures.
Several open-source instrumentation frameworks collect log, metric, and trace
data, and can send that data to any vendor, including Google Cloud. For your
agentic applications, some frameworks can collect your prompts and responses or
pass context that allows tracing of some remote
[Google Cloud MCP servers](https://docs.cloud.google.com/mcp/overview.md.txt) calls.

To instrument your application, we recommend that you use an
open-source, vendor-neutral instrumentation framework, such as
[OpenTelemetry](https://opentelemetry.io/), instead of
vendor- and product-specific APIs or client libraries.
For information about these frameworks, see
[Observability for application developers](https://docs.cloud.google.com/stackdriver/docs/opentelemetry/application-developers.md.txt) and
[Choose an instrumentation approach](https://docs.cloud.google.com/stackdriver/docs/instrumentation/choose-approach.md.txt).

## OpenTelemetry setup

For information about setting up OpenTelemetry, see the following guides:

- [C++](https://docs.cloud.google.com/trace/docs/setup/cpp-ot.md.txt)
- [Go](https://docs.cloud.google.com/trace/docs/setup/go-ot.md.txt)
- [Java](https://docs.cloud.google.com/trace/docs/setup/java-ot.md.txt)
- [Node.js](https://docs.cloud.google.com/trace/docs/setup/nodejs-ot.md.txt)
- [Python](https://docs.cloud.google.com/trace/docs/setup/python-ot.md.txt)
- [Rust](https://docs.cloud.google.com/rust/docs/observability.md.txt)

## Cloud Client Libraries

For information about the Cloud Client Libraries, see the following resources:

- Ruby:

  > [!NOTE]
  > **Note:** We recommend that you use OpenTelemetry for Ruby. For more information, see the [Ruby SDK](https://opentelemetry.io/docs/instrumentation/ruby/).

  GitHub: [`googleapis/google-cloud-trace`](https://github.com/googleapis/google-cloud-ruby/tree/master/google-cloud-trace)
- ASP.NET:

  > [!NOTE]
  > **Note:** We recommend that you use OpenTelemetry for .NET. For more information, see the [.NET SDK](https://opentelemetry.io/docs/languages/dotnet/).

  - Library: [`Google.Cloud.Diagnostics.AspNet`](https://googleapis.dev/dotnet/Google.Cloud.Diagnostics.AspNet/latest/index.html)
  - NuGet package: [`Google.Cloud.Diagnostics.AspNet`](https://www.nuget.org/packages/Google.Cloud.Diagnostics.AspNet/)
  - GitHub: [`Google.Cloud.Diagnostics.AspNet version 4.0.0`](https://github.com/googleapis/google-cloud-dotnet/releases/tag/Google.Cloud.Diagnostics.AspNet-4.0.0)
- ASP.NET Core:

  > [!NOTE]
  > **Note:** We recommend that you use OpenTelemetry for .NET. For more information, see the [.NET SDK](https://opentelemetry.io/docs/languages/dotnet/).

  - Libraries: [`Google.Cloud.Diagnostics.AspNetCore3`](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.AspNetCore3/latest.md.txt) and [`Google.Cloud.Diagnostics.AspNetCore`](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.AspNetCore/latest.md.txt)
  - NuGet packages: [`Google.Cloud.Diagnostics.AspNetCore3`](https://www.nuget.org/packages/Google.Cloud.Diagnostics.AspNetCore3/) and [`Google.Cloud.Diagnostics.AspNetCore`](https://www.nuget.org/packages/Google.Cloud.Diagnostics.AspNetCore/)
  - GitHub: [`googleapis/google-cloud-dotnet`](https://github.com/googleapis/google-cloud-dotnet)