<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Pyroscope language SDKs on Grafana Labs</title><link>https://grafana.com/docs/pyroscope/v1.18.x/configure-client/language-sdks/</link><description>Recent content in Pyroscope language SDKs on Grafana Labs</description><generator>Hugo -- gohugo.io</generator><language>en</language><atom:link href="/docs/pyroscope/v1.18.x/configure-client/language-sdks/index.xml" rel="self" type="application/rss+xml"/><item><title>Go (push mode)</title><link>https://grafana.com/docs/pyroscope/v1.18.x/configure-client/language-sdks/go_push/</link><pubDate>Wed, 08 Apr 2026 14:38:28 +0000</pubDate><guid>https://grafana.com/docs/pyroscope/v1.18.x/configure-client/language-sdks/go_push/</guid><content><![CDATA[&lt;h1 id=&#34;go-push-mode&#34;&gt;Go (push mode)&lt;/h1&gt;
&lt;p&gt;Our Go Profiler is a cutting-edge tool designed to optimize Golang applications.
By integrating with Pyroscope, the profiler offers developers an in-depth view of their Go codebase, enabling real-time performance analysis.
This powerful tool is crucial for pinpointing inefficiencies, streamlining code execution, and ensuring peak performance in Go applications.&lt;/p&gt;
&lt;p&gt;Pyroscope uses the standard &lt;code&gt;runtime/pprof&lt;/code&gt; package to collect profiling data.
Refer to &lt;a href=&#34;https://golang.org/doc/diagnostics#profiling&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;the official documentation&lt;/a&gt; for details.&lt;/p&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;Refer to &lt;a href=&#34;/docs/pyroscope/latest/configure-client/profile-types/&#34;&gt;Available profiling types&lt;/a&gt; for a list of profile types supported by Go.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;h2 id=&#34;before-you-begin&#34;&gt;Before you begin&lt;/h2&gt;
&lt;p&gt;To capture and analyze profiling data, you need either a hosted Pyroscope OSS server or a hosted &lt;a href=&#34;/products/cloud/profiles-for-continuous-profiling/&#34;&gt;Pyroscope instance with Grafana Cloud Profiles&lt;/a&gt; (requires a free Grafana Cloud account).&lt;/p&gt;
&lt;p&gt;The Pyroscope server can be a local server for development or a remote server for production use.&lt;/p&gt;
&lt;h2 id=&#34;configure-the-go-client&#34;&gt;Configure the Go client&lt;/h2&gt;
&lt;p&gt;To start profiling a Go application, you need to include the Go module in your app:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Go&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-go&#34;&gt;go get github.com/grafana/pyroscope-go&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;If you&amp;rsquo;d prefer to use Pull mode you can do so using 
    &lt;a href=&#34;/docs/pyroscope/v1.18.x/configure-client/grafana-alloy/&#34;&gt;Grafana Alloy&lt;/a&gt;.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;p&gt;Add the following code to your application:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Go&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-go&#34;&gt;package main

import &amp;#34;github.com/grafana/pyroscope-go&amp;#34;

func main() {
  // These 2 lines are only required if you&amp;#39;re using mutex or block profiling
  // Read the explanation below for how to set these rates:
  runtime.SetMutexProfileFraction(5)
  runtime.SetBlockProfileRate(5)

  pyroscope.Start(pyroscope.Config{
    ApplicationName: &amp;#34;simple.golang.app&amp;#34;,

    // replace this with the address of pyroscope server
    ServerAddress:   &amp;#34;http://pyroscope-server:4040&amp;#34;,

    // you can disable logging by setting this to nil
    Logger:          pyroscope.StandardLogger,

    // you can provide static tags via a map:
    Tags:            map[string]string{&amp;#34;hostname&amp;#34;: os.Getenv(&amp;#34;HOSTNAME&amp;#34;)},

    ProfileTypes: []pyroscope.ProfileType{
      // these profile types are enabled by default:
      pyroscope.ProfileCPU,
      pyroscope.ProfileAllocObjects,
      pyroscope.ProfileAllocSpace,
      pyroscope.ProfileInuseObjects,
      pyroscope.ProfileInuseSpace,

      // these profile types are optional:
      pyroscope.ProfileGoroutines,
      pyroscope.ProfileMutexCount,
      pyroscope.ProfileMutexDuration,
      pyroscope.ProfileBlockCount,
      pyroscope.ProfileBlockDuration,
    },
  })

  // your code goes here
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Alternatively, if you want more control over the profiling process, you can manually handle the profiler initialization and termination:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Go&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-go&#34;&gt;  profiler, err := pyroscope.Start(pyroscope.Config{
    // omitted for brevity
  })
  if err != nil {
    // the only reason this would fail is if the configuration is not valid
    log.Fatalf(&amp;#34;failed to start Pyroscope: %v&amp;#34;, err)
  }
  defer profiler.Stop()

  // your code goes here
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;This approach may be necessary if you need to ensure that the last profile is sent before the application exits.&lt;/p&gt;
&lt;h3 id=&#34;add-profiling-labels-to-your-application&#34;&gt;Add profiling labels to your application&lt;/h3&gt;
&lt;p&gt;You can add tags (labels) to the profiling data. These tags can be used to filter the data in the UI. There is a custom API that&amp;rsquo;s in line with the go-native pprof API:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Go&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-go&#34;&gt;// these two ways of adding tags are equivalent:
pyroscope.TagWrapper(context.Background(), pyroscope.Labels(&amp;#34;controller&amp;#34;, &amp;#34;slow_controller&amp;#34;), func(c context.Context) {
  slowCode()
})

pprof.Do(context.Background(), pprof.Labels(&amp;#34;controller&amp;#34;, &amp;#34;slow_controller&amp;#34;), func(c context.Context) {
  slowCode()
})&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;mutex-profiling&#34;&gt;Mutex profiling&lt;/h3&gt;
&lt;p&gt;Mutex profiling is useful for finding sources of contention within your application. It helps you find out which mutexes are being held by which goroutines.&lt;/p&gt;
&lt;p&gt;To enable mutex profiling, you need to add the following code to your application:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Go&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-go&#34;&gt;runtime.SetMutexProfileFraction(rate)&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;The &lt;code&gt;rate&lt;/code&gt; parameter controls the fraction of mutex contention events that are reported in the mutex profile. On average, 1/rate events are reported.&lt;/p&gt;
&lt;h3 id=&#34;block-profiling&#34;&gt;Block profiling&lt;/h3&gt;
&lt;p&gt;Block profiling lets you analyze how much time your program spends waiting on the blocking operations such as:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;select&lt;/li&gt;
&lt;li&gt;channel send/receive&lt;/li&gt;
&lt;li&gt;semacquire&lt;/li&gt;
&lt;li&gt;notifyListWait&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;To enable block profiling, you need to add the following code to your application:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Go&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-go&#34;&gt;runtime.SetBlockProfileRate(rate)&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;The &lt;code&gt;rate&lt;/code&gt; parameter controls the fraction of goroutine blocking events that are reported in the blocking profile.
The profiler aims to sample an average of one blocking event per rate nanoseconds spent blocked.&lt;/p&gt;
&lt;h2 id=&#34;send-data-to-pyroscope-oss-or-grafana-cloud-profiles&#34;&gt;Send data to Pyroscope OSS or Grafana Cloud Profiles&lt;/h2&gt;
&lt;p&gt;To configure the Golang SDK to send data to Pyroscope, replace the &lt;code&gt;&amp;lt;URL&amp;gt;&lt;/code&gt; placeholder with the appropriate server URL.
This could be the Grafana Cloud URL or your own custom Pyroscope server URL.&lt;/p&gt;
&lt;p&gt;If you need to send data to Grafana Cloud, you&amp;rsquo;ll have to configure HTTP Basic authentication.
Replace &lt;code&gt;&amp;lt;User&amp;gt;&lt;/code&gt; with your Grafana Cloud stack user and &lt;code&gt;&amp;lt;Password&amp;gt;&lt;/code&gt; with your Grafana Cloud API key.&lt;/p&gt;
&lt;p&gt;If your Pyroscope server has multi-tenancy enabled, you&amp;rsquo;ll need to configure a tenant ID.
Replace &lt;code&gt;&amp;lt;TenantID&amp;gt;&lt;/code&gt; with your Pyroscope tenant ID.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Go&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-go&#34;&gt;pyroscope.Start(pyroscope.Config{
  ApplicationName:   &amp;#34;example.golang.app&amp;#34;,
  ServerAddress:     &amp;#34;&amp;lt;URL&amp;gt;&amp;#34;,
  // Optional HTTP Basic authentication
  BasicAuthUser:     &amp;#34;&amp;lt;User&amp;gt;&amp;#34;,
  BasicAuthPassword: &amp;#34;&amp;lt;Password&amp;gt;&amp;#34;,
  // Optional Pyroscope tenant ID (only needed if using multi-tenancy). Not needed for Grafana Cloud.
  // TenantID:          &amp;#34;&amp;lt;TenantID&amp;gt;&amp;#34;,
  ProfileTypes: []pyroscope.ProfileType{
    pyroscope.ProfileCPU,
    pyroscope.ProfileInuseObjects,
    pyroscope.ProfileAllocObjects,
    pyroscope.ProfileInuseSpace,
    pyroscope.ProfileAllocSpace,
  },
})&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;locate-the-url-user-and-password-in-grafana-cloud-profiles&#34;&gt;Locate the URL, user, and password in Grafana Cloud Profiles&lt;/h3&gt;


&lt;div data-shared=&#34;locate-url-pw-user-cloud-profiles.md&#34;&gt;
            &lt;!-- Locate your stack&#39;s URL, user, and password --&gt;
&lt;p&gt;When you configure Alloy or your SDK, you need to provide the URL, user, and password for your Grafana Cloud stack.
This information is located in the &lt;strong&gt;Pyroscope&lt;/strong&gt; section of your Grafana Cloud stack.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Navigate to your Grafana Cloud stack.&lt;/li&gt;
&lt;li&gt;Select &lt;strong&gt;Details&lt;/strong&gt; next to your stack.&lt;/li&gt;
&lt;li&gt;Locate the &lt;strong&gt;Pyroscope&lt;/strong&gt; section and select &lt;strong&gt;Details&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Copy the &lt;strong&gt;URL&lt;/strong&gt;, &lt;strong&gt;User&lt;/strong&gt;, and &lt;strong&gt;Password&lt;/strong&gt; values in the &lt;strong&gt;Configure the client and data source using Grafana credentials&lt;/strong&gt; section.
&lt;img
  class=&#34;lazyload d-inline-block&#34;
  data-src=&#34;/media/docs/pyroscope/cloud-profiles-url-user-password.png&#34;
  alt=&#34;Locate the SDK or Grafana Alloy configuration values&#34; width=&#34;1029&#34;
     height=&#34;725&#34;/&gt;&lt;/li&gt;
&lt;li&gt;Use these values to complete the configuration.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;As an alternative, you can also create a Cloud Access Policy and generate a token to use instead of the user and password.
For more information, refer to &lt;a href=&#34;/docs/grafana-cloud/security-and-account-management/authentication-and-permissions/access-policies/create-access-policies/&#34;&gt;Create a Cloud Access Policy&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;

        
&lt;h3 id=&#34;option-use-disablegcruns-for-handling-increased-memory-usage&#34;&gt;Option: Use &lt;code&gt;DisableGCRuns&lt;/code&gt; for handling increased memory usage&lt;/h3&gt;
&lt;p&gt;Pyroscope may require additional resources when tracking a lot of objects. For example, a Go service that indexes large amounts of data requires more memory.
This tracking can lead to higher CPU usage and potential CPU throttling.&lt;/p&gt;
&lt;p&gt;You can use &lt;code&gt;DisableGCRuns&lt;/code&gt; in your Go configuration to disable automatic runtimes.
If this flag is activated, there is less GC running and therefore less CPU resources spent.
However, the heap profile may be less precise.&lt;/p&gt;
&lt;h4 id=&#34;background&#34;&gt;Background&lt;/h4&gt;
&lt;p&gt;In Go&amp;rsquo;s pprof heap profiling, forcing garbage collection (GC) ensures accurate memory usage snapshots by removing uncollected objects.
Without this step, the heap profile may include memory that has been allocated but is no longer in use&amp;ndash;objects that stay in memory simply because they haven&amp;rsquo;t been collected yet.
This can mask or mimic memory leaks and introduce bias into the profiles, complicating their analysis.
Therefore, Pyroscope defaults to forcing GC every time a heap profile is collected.&lt;/p&gt;
&lt;p&gt;However, in some cases, forcing GC can increase CPU usage, especially if there are many live objects in the heap.
This issue is reflected by the appearance of the &lt;code&gt;runtime.GC&lt;/code&gt; function in the CPU profile.
If the problem has manifested, and some inaccuracy in the heap profile is acceptable, then it is advisable to disable this option to avoid performance degradation.&lt;/p&gt;
&lt;h4 id=&#34;activate-disablegcruns&#34;&gt;Activate &lt;code&gt;DisableGCRuns&lt;/code&gt;&lt;/h4&gt;
&lt;p&gt;Add &lt;code&gt;DisableGCRuns: true&lt;/code&gt; to the &lt;code&gt;pyroscope.Start(pyroscope.Config)&lt;/code&gt; block.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Go&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-go&#34;&gt;pyroscope.Start(pyroscope.Config{
  ApplicationName:   &amp;#34;example.golang.app&amp;#34;,
  ServerAddress:     &amp;#34;&amp;lt;URL&amp;gt;&amp;#34;,
  // Disable automatic runtime.GC runs between getting the heap profiles.
		DisableGCRuns:   true,&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;golang-profiling-examples&#34;&gt;Golang profiling examples&lt;/h2&gt;
&lt;p&gt;Check out the following resources to learn more about Golang profiling:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://github.com/grafana/pyroscope/tree/main/examples/language-sdk-instrumentation/golang-push&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Golang examples&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://play.grafana.org/a/grafana-pyroscope-app/single?query=process_cpu%3Acpu%3Ananoseconds%3Acpu%3Ananoseconds%7Bservice_name%3D%22pyroscope-rideshare-go%22%7D&amp;amp;from=now-1h&amp;amp;until=now&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Golang Demo&lt;/a&gt; showing golang example with tags&lt;/li&gt;
&lt;/ul&gt;
]]></content><description>&lt;h1 id="go-push-mode">Go (push mode)&lt;/h1>
&lt;p>Our Go Profiler is a cutting-edge tool designed to optimize Golang applications.
By integrating with Pyroscope, the profiler offers developers an in-depth view of their Go codebase, enabling real-time performance analysis.
This powerful tool is crucial for pinpointing inefficiencies, streamlining code execution, and ensuring peak performance in Go applications.&lt;/p></description></item><item><title>Java</title><link>https://grafana.com/docs/pyroscope/v1.18.x/configure-client/language-sdks/java/</link><pubDate>Wed, 08 Apr 2026 14:38:28 +0000</pubDate><guid>https://grafana.com/docs/pyroscope/v1.18.x/configure-client/language-sdks/java/</guid><content><![CDATA[&lt;h1 id=&#34;java&#34;&gt;Java&lt;/h1&gt;
&lt;p&gt;The Java Profiler, integrated with Pyroscope, offers a comprehensive solution for performance analysis in Java applications.
It provides real-time insights, enabling developers to understand and optimize their Java codebase effectively.
This tool is crucial for improving application responsiveness, reducing resource consumption, and ensuring top-notch performance in Java environments.&lt;/p&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;Refer to 
    &lt;a href=&#34;/docs/pyroscope/v1.18.x/configure-client/profile-types/&#34;&gt;Available profiling types&lt;/a&gt; for a list of profile types supported by each language.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;h2 id=&#34;before-you-begin&#34;&gt;Before you begin&lt;/h2&gt;
&lt;p&gt;To capture and analyze profiling data, you need either a hosted Pyroscope OSS server or a hosted &lt;a href=&#34;/products/cloud/profiles-for-continuous-profiling/&#34;&gt;Pyroscope instance with Grafana Cloud Profiles&lt;/a&gt; (requires a free Grafana Cloud account).&lt;/p&gt;
&lt;p&gt;The Pyroscope server can be a local server for development or a remote server for production use.&lt;/p&gt;
&lt;h2 id=&#34;add-java-profiling-to-your-application&#34;&gt;Add Java profiling to your application&lt;/h2&gt;
&lt;p&gt;Java integration is distributed as a single jar file (&lt;code&gt;pyroscope.jar&lt;/code&gt;) or a Maven package.
Supported platforms include:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Linux on x64&lt;/li&gt;
&lt;li&gt;Linux on ARM64&lt;/li&gt;
&lt;li&gt;MacOS on x64&lt;/li&gt;
&lt;li&gt;MacOS on ARM64&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Visit the GitHub &lt;a href=&#34;https://github.com/pyroscope-io/pyroscope-java/releases&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;releases&lt;/a&gt; page to download the latest version of &lt;code&gt;pyroscope.jar&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;The latest release is also available on &lt;a href=&#34;https://search.maven.org/artifact/io.pyroscope/agent&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Maven Central&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;configure-the-java-client&#34;&gt;Configure the Java client&lt;/h2&gt;
&lt;p&gt;You can start Pyroscope either from your application&amp;rsquo;s code or attach it as javaagent.&lt;/p&gt;
&lt;h3 id=&#34;start-pyroscope-from-apps-java-code&#34;&gt;Start Pyroscope from app&amp;rsquo;s Java code&lt;/h3&gt;
&lt;p&gt;First, add the Pyroscope dependency:&lt;/p&gt;



  

  


&lt;div data-element=&#34;tabs&#34;&gt;
  &lt;div data-element=&#34;tabs-bar&#34;&gt;
    
      &lt;div data-element=&#34;tab&#34; data-key=&#34;0&#34; data-label=&#34;maven&#34;&gt;maven&lt;/div&gt;
    
      &lt;div data-element=&#34;tab&#34; data-key=&#34;1&#34; data-label=&#34;gradle&#34;&gt;gradle&lt;/div&gt;
    
  &lt;/div&gt;
  &lt;div data-element=&#34;tab-content&#34;&gt;
    
&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;maven&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-maven&#34;&gt;&amp;lt;dependency&amp;gt;
  &amp;lt;groupId&amp;gt;io.pyroscope&amp;lt;/groupId&amp;gt;
  &amp;lt;artifactId&amp;gt;agent&amp;lt;/artifactId&amp;gt;
  &amp;lt;version&amp;gt;2.1.2&amp;lt;/version&amp;gt;
&amp;lt;/dependency&amp;gt;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;gradle&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-gradle&#34;&gt;implementation(&amp;#34;io.pyroscope:agent:2.1.2&amp;#34;)&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Add the following code to your application:&lt;/p&gt;



  

  


&lt;div data-element=&#34;tabs&#34;&gt;
  &lt;div data-element=&#34;tabs-bar&#34;&gt;
    
      &lt;div data-element=&#34;tab&#34; data-key=&#34;0&#34; data-label=&#34;java&#34;&gt;java&lt;/div&gt;
    
      &lt;div data-element=&#34;tab&#34; data-key=&#34;1&#34; data-label=&#34;spring&#34;&gt;spring&lt;/div&gt;
    
  &lt;/div&gt;
  &lt;div data-element=&#34;tab-content&#34;&gt;
    
&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;java&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-java&#34;&gt;PyroscopeAgent.start(
  new Config.Builder()
    .setApplicationName(&amp;#34;ride-sharing-app-java&amp;#34;)
    .setProfilingEvent(EventType.ITIMER)
    .setFormat(Format.JFR)
    .setServerAddress(&amp;#34;http://pyroscope-server:4040&amp;#34;)
    .build()
);&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;spring&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-spring&#34;&gt;import io.pyroscope.javaagent.PyroscopeAgent;
import io.pyroscope.javaagent.config.Config;
import io.pyroscope.javaagent.EventType;
import io.pyroscope.http.Format;

@PostConstruct
public void init() {

    PyroscopeAgent.start(
    new Config.Builder()
        .setApplicationName(&amp;#34;ride-sharing-app-java&amp;#34;)
        .setProfilingEvent(EventType.ITIMER)
        .setFormat(Format.JFR)
        .setServerAddress(&amp;#34;http://pyroscope-server:4040&amp;#34;)
        // Optionally, if authentication is enabled, specify the API key.
        // .setBasicAuthUser(&amp;#34;&amp;lt;User&amp;gt;&amp;#34;)
        // .setBasicAuthPassword(&amp;#34;&amp;lt;Password&amp;gt;&amp;#34;)
        // Optionally, if you&amp;#39;d like to set allocation threshold to register events, in bytes. &amp;#39;0&amp;#39; registers all events
        // .setProfilingAlloc(&amp;#34;0&amp;#34;)
        .build()
    );
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;You can also optionally replace some Pyroscope components:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;java&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-java&#34;&gt;PyroscopeAgent.start(
  new PyroscopeAgent.Options.Builder(config)
    .setExporter(snapshot -&amp;gt; {
      // Your custom export/upload logic may go here
      // It is invoked every 10 seconds by default with snapshot of
      // profiling data
    })
    .setLogger((l, msg, args) -&amp;gt; {
      // Your custom logging may go here
      // Pyroscope does not depend on any logging library
      System.out.printf((msg) &amp;#43; &amp;#34;%n&amp;#34;, args);
    })
    .setScheduler(profiler -&amp;gt; {
      // Your custom profiling schedule logic may go here
    })
    .build()
);&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;start-pyroscope-as-javaagent&#34;&gt;Start Pyroscope as &lt;code&gt;javaagent&lt;/code&gt;&lt;/h3&gt;
&lt;p&gt;To start profiling a Java application, run your application with &lt;code&gt;pyroscope.jar&lt;/code&gt; &lt;code&gt;javaagent&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;shell&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-shell&#34;&gt;export PYROSCOPE_APPLICATION_NAME=my.java.app
export PYROSCOPE_SERVER_ADDRESS=http://pyroscope-server:4040

java -javaagent:pyroscope.jar -jar app.jar&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;add-profiling-labels-to-java-applications&#34;&gt;Add profiling labels to Java applications&lt;/h3&gt;
&lt;p&gt;You can add dynamic tags (labels) to the profiling data. These tags can filter the data in the UI.&lt;/p&gt;
&lt;p&gt;Add labels dynamically:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;java&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-java&#34;&gt;Pyroscope.LabelsWrapper.run(new LabelsSet(&amp;#34;controller&amp;#34;, &amp;#34;slow_controller&amp;#34;), () -&amp;gt; {
  slowCode();
});&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;You can also add static tags (labels) to the profiling data:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;java&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-java&#34;&gt;Pyroscope.setStaticLabels(Map.of(&amp;#34;region&amp;#34;, System.getenv(&amp;#34;REGION&amp;#34;)));
// or with Config.Builder if you start pyroscope with PyroscopeAgent.start
PyroscopeAgent.start(new Config.Builder()
    .setLabels(mapOf(&amp;#34;region&amp;#34;, System.getenv(&amp;#34;REGION&amp;#34;)))
    // ...
    .build()
);&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;configuration-options&#34;&gt;Configuration options&lt;/h3&gt;
&lt;p&gt;When you start Pyroscope as &lt;code&gt;javaagent&lt;/code&gt; or obtain configuration by &lt;code&gt;Config.build()&lt;/code&gt;, Pyroscope searches
for configuration in multiple sources: system properties, environment variables, and &lt;code&gt;pyroscope.properties&lt;/code&gt;.
Property keys have the same names as environment variables, but are in lowercase and underscores (&lt;code&gt;_&lt;/code&gt;) are replaced with periods (&lt;code&gt;.&lt;/code&gt;). For example, &lt;code&gt;PYROSCOPE_FORMAT&lt;/code&gt; becomes &lt;code&gt;pyroscope.format&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;The Java integration supports JFR format to be able to support multiple events (JFR is the only output format that supports &lt;a href=&#34;https://github.com/jvm-profiling-tools/async-profiler#multiple-events&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;multiple events in &lt;code&gt;async-profiler&lt;/code&gt;&lt;/a&gt;). There are several environment variables that define how multiple event configuration works:&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Flag&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;PYROSCOPE_AGENT_ENABLED&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Enables the agent. The default is &lt;code&gt;true&lt;/code&gt;.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;PYROSCOPE_APPLICATION_NAME&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Sets the application name. If not provided, a generated name will be used.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;PYROSCOPE_PROFILING_INTERVAL&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Sets the profiling sampling interval for CPU profiling. The default is &lt;code&gt;10ms&lt;/code&gt;.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;PYROSCOPE_FORMAT&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Sets the profiler output format. The default is &lt;code&gt;collapsed&lt;/code&gt;, but in order to support multiple formats it must be set to &lt;code&gt;jfr&lt;/code&gt;.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;PYROSCOPE_PROFILER_EVENT&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Sets the profiler event. With JFR format enabled, this event refers to one of the possible CPU profiling events: &lt;code&gt;itimer&lt;/code&gt;, &lt;code&gt;cpu&lt;/code&gt;, &lt;code&gt;wall&lt;/code&gt;. The default is &lt;code&gt;itimer&lt;/code&gt;.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;PYROSCOPE_PROFILER_ALLOC&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Sets the threshold to register allocation events, in bytes (equivalent to &lt;code&gt;--alloc=&lt;/code&gt; in &lt;code&gt;async-profiler&lt;/code&gt;). The default value is &lt;code&gt;&amp;quot;&amp;quot;&lt;/code&gt; - empty string, which means that allocation profiling is disabled. Setting it to &lt;code&gt;0&lt;/code&gt; will register every event, causing significant CPU and network overhead, making it not suitable for production environments. We recommend setting a starting value of 512k and adjusting it as needed.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;PYROSCOPE_PROFILER_LOCK&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Sets the threshold to register lock events, in nanoseconds (equivalent to &lt;code&gt;--lock=&lt;/code&gt; in &lt;code&gt;async-profiler&lt;/code&gt;). The default value is &lt;code&gt;&amp;quot;&amp;quot;&lt;/code&gt; - empty string, which means that lock profiling is disabled. Setting it to &lt;code&gt;0&lt;/code&gt; will register every event, causing significant CPU and network overhead, making it not suitable for production environments. We recommend setting a starting value of 10ms and adjusting it as needed.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;PYROSCOPE_UPLOAD_INTERVAL&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Sets the interval for uploading profiling data. The default is &lt;code&gt;10s&lt;/code&gt;.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;PYROSCOPE_JAVA_STACK_DEPTH_MAX&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Sets the maximum stack depth. The default is &lt;code&gt;2048&lt;/code&gt;.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;PYROSCOPE_SERVER_ADDRESS&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Address of the Pyroscope server. The default is &lt;code&gt;http://localhost:4040&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;PYROSCOPE_CONFIGURATION_FILE&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Sets an additional properties configuration file. The default value is &lt;code&gt;pyroscope.properties&lt;/code&gt;.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;PYROSCOPE_BASIC_AUTH_USER&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;HTTP Basic authentication username. The default value is &lt;code&gt;&amp;quot;&amp;quot;&lt;/code&gt; - empty string, no authentication.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;PYROSCOPE_BASIC_AUTH_PASSWORD&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;HTTP Basic authentication password. The default value is &lt;code&gt;&amp;quot;&amp;quot;&lt;/code&gt; - empty string, no authentication.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;PYROSCOPE_TENANT_ID&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;pyroscope tenant ID, passed as X-Scope-OrgID http header. The default value is &lt;code&gt;&amp;quot;&amp;quot;&lt;/code&gt; - empty string, no tenant ID.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;PYROSCOPE_HTTP_HEADERS&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Extra HTTP headers in JSON format, for example: &lt;code&gt;{&amp;quot;X-Header&amp;quot;: &amp;quot;Value&amp;quot;}&lt;/code&gt;. The default value is &lt;code&gt;{}&lt;/code&gt; - no extra headers.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;PYROSCOPE_LABELS&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Sets static labels in the form of comma separated &lt;code&gt;key=value&lt;/code&gt; pairs. The default value is &lt;code&gt;&amp;quot;&amp;quot;&lt;/code&gt; - empty string, no labels.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;PYROSCOPE_LOG_LEVEL&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Determines the level of verbosity for Pyroscope&amp;rsquo;s logger. Available options include &lt;code&gt;debug&lt;/code&gt;, &lt;code&gt;info&lt;/code&gt;, &lt;code&gt;warn&lt;/code&gt;, and &lt;code&gt;error&lt;/code&gt;. The default value is set to &lt;code&gt;info&lt;/code&gt;.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;PYROSCOPE_PUSH_QUEUE_CAPACITY&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Specifies the size of the ingestion queue that temporarily stores profiling data in memory during network outages. The default value is set to 8.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;PYROSCOPE_INGEST_MAX_TRIES&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Sets the maximum number of times to retry an ingestion API call in the event of failure. A value of &lt;code&gt;-1&lt;/code&gt; indicates that the retries will continue indefinitely. The default value is set to &lt;code&gt;8&lt;/code&gt;.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;PYROSCOPE_EXPORT_COMPRESSION_LEVEL_JFR&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Sets the level of GZIP compression applied to uploaded JFR files. This option accepts values of &lt;code&gt;NO_COMPRESSION&lt;/code&gt;, &lt;code&gt;BEST_SPEED&lt;/code&gt;, &lt;code&gt;BEST_COMPRESSION&lt;/code&gt;, and &lt;code&gt;DEFAULT_COMPRESSION&lt;/code&gt;.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;PYROSCOPE_EXPORT_COMPRESSION_LEVEL_LABELS&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Operates similarly to &lt;code&gt;PYROSCOPE_EXPORT_COMPRESSION_LEVEL_JFR&lt;/code&gt;, but applies to the dynamic labels part. The default value is set to &lt;code&gt;BEST_SPEED&lt;/code&gt;.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;PYROSCOPE_ALLOC_LIVE&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Retain allocation samples with live objects only (objects that have not been collected by the end of profiling session). Useful for finding Java heap memory leaks. The default value is &lt;code&gt;false&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;PYROSCOPE_GC_BEFORE_DUMP&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;A boolean value that executes a &lt;code&gt;System.gc()&lt;/code&gt; command before dumping the profile when set to &lt;code&gt;true&lt;/code&gt;. This option may be useful for live profiling, but is disabled by default.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h2 id=&#34;send-data-to-pyroscope-oss-or-grafana-cloud-profiles&#34;&gt;Send data to Pyroscope OSS or Grafana Cloud Profiles&lt;/h2&gt;
&lt;p&gt;Add the following code to your application:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;java&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-java&#34;&gt;PyroscopeAgent.start(
    new Config.Builder()
        .setApplicationName(&amp;#34;test-java-app&amp;#34;)
        .setProfilingEvent(EventType.ITIMER)
        .setFormat(Format.JFR)
        .setServerAddress(&amp;#34;&amp;lt;URL&amp;gt;&amp;#34;)
        // Set these if using Grafana Cloud:
        .setBasicAuthUser(&amp;#34;&amp;lt;User&amp;gt;&amp;#34;)
        .setBasicAuthPassword(&amp;#34;&amp;lt;Password&amp;gt;&amp;#34;)
        // Optional Pyroscope tenant ID (only needed if using multi-tenancy). Not needed for Grafana cloud.
        // .setTenantID(&amp;#34;&amp;lt;TenantID&amp;gt;&amp;#34;)
        .build()
);&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;To configure the Java SDK to send data to Pyroscope, replace the &lt;code&gt;&amp;lt;URL&amp;gt;&lt;/code&gt; placeholder with the appropriate server URL. This could be the Grafana Cloud URL or your own custom Pyroscope server URL.&lt;/p&gt;
&lt;p&gt;If you need to send data to Grafana Cloud, you&amp;rsquo;ll have to configure HTTP Basic authentication. Replace &lt;code&gt;&amp;lt;User&amp;gt;&lt;/code&gt; with your Grafana Cloud stack user and &lt;code&gt;&amp;lt;Password&amp;gt;&lt;/code&gt; with your Grafana Cloud API key.&lt;/p&gt;
&lt;p&gt;If your Pyroscope server has multi-tenancy enabled, you&amp;rsquo;ll need to configure a tenant ID. Replace &lt;code&gt;&amp;lt;TenantID&amp;gt;&lt;/code&gt; with your Pyroscope tenant ID.&lt;/p&gt;
&lt;h3 id=&#34;locate-the-url-user-and-password-in-grafana-cloud-profiles&#34;&gt;Locate the URL, user, and password in Grafana Cloud Profiles&lt;/h3&gt;


&lt;div data-shared=&#34;locate-url-pw-user-cloud-profiles.md&#34;&gt;
            &lt;!-- Locate your stack&#39;s URL, user, and password --&gt;
&lt;p&gt;When you configure Alloy or your SDK, you need to provide the URL, user, and password for your Grafana Cloud stack.
This information is located in the &lt;strong&gt;Pyroscope&lt;/strong&gt; section of your Grafana Cloud stack.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Navigate to your Grafana Cloud stack.&lt;/li&gt;
&lt;li&gt;Select &lt;strong&gt;Details&lt;/strong&gt; next to your stack.&lt;/li&gt;
&lt;li&gt;Locate the &lt;strong&gt;Pyroscope&lt;/strong&gt; section and select &lt;strong&gt;Details&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Copy the &lt;strong&gt;URL&lt;/strong&gt;, &lt;strong&gt;User&lt;/strong&gt;, and &lt;strong&gt;Password&lt;/strong&gt; values in the &lt;strong&gt;Configure the client and data source using Grafana credentials&lt;/strong&gt; section.
&lt;img
  class=&#34;lazyload d-inline-block&#34;
  data-src=&#34;/media/docs/pyroscope/cloud-profiles-url-user-password.png&#34;
  alt=&#34;Locate the SDK or Grafana Alloy configuration values&#34; width=&#34;1029&#34;
     height=&#34;725&#34;/&gt;&lt;/li&gt;
&lt;li&gt;Use these values to complete the configuration.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;As an alternative, you can also create a Cloud Access Policy and generate a token to use instead of the user and password.
For more information, refer to &lt;a href=&#34;/docs/grafana-cloud/security-and-account-management/authentication-and-permissions/access-policies/create-access-policies/&#34;&gt;Create a Cloud Access Policy&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;

        
&lt;h3 id=&#34;example-configurations&#34;&gt;Example configurations&lt;/h3&gt;
&lt;p&gt;The following configuration sets application name, Pyroscope format, profiling interval, event, and lock.
This example is an excerpt from the &lt;a href=&#34;https://github.com/grafana/pyroscope/blob/main/examples/language-sdk-instrumentation/java/rideshare/Dockerfile#L24-L34&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;&lt;code&gt;rideshare&lt;/code&gt; Dockerfile&lt;/a&gt; available in the Pyroscope repository.&lt;/p&gt;

&lt;div class=&#34;code-snippet code-snippet__mini&#34;&gt;&lt;div class=&#34;lang-toolbar__mini&#34;&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet code-snippet__border&#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-none&#34;&gt;ENV PYROSCOPE_APPLICATION_NAME=rideshare.java.push.app
ENV PYROSCOPE_FORMAT=jfr
ENV PYROSCOPE_PROFILING_INTERVAL=10ms
ENV PYROSCOPE_PROFILER_EVENT=itimer
ENV PYROSCOPE_PROFILER_LOCK=10ms&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;This configuration excerpt enables allocation and lock profiling:&lt;/p&gt;

&lt;div class=&#34;code-snippet code-snippet__mini&#34;&gt;&lt;div class=&#34;lang-toolbar__mini&#34;&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet code-snippet__border&#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-none&#34;&gt;PYROSCOPE_PROFILER_ALLOC=512k
PYROSCOPE_PROFILER_LOCK=10ms&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;java-profiling-examples&#34;&gt;Java profiling examples&lt;/h2&gt;
&lt;p&gt;Check out the following resources to learn more about Java profiling:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://github.com/grafana/pyroscope/tree/main/examples/language-sdk-instrumentation/java/rideshare&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Java examples&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://play.grafana.org/a/grafana-pyroscope-app/single?query=process_cpu%3Acpu%3Ananoseconds%3Acpu%3Ananoseconds%7Bservice_name%3D%22pyroscope-rideshare-java%22%7D&amp;amp;from=now-1h&amp;amp;until=now&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Java Demo&lt;/a&gt; showing Java example with tags&lt;/li&gt;
&lt;/ul&gt;
]]></content><description>&lt;h1 id="java">Java&lt;/h1>
&lt;p>The Java Profiler, integrated with Pyroscope, offers a comprehensive solution for performance analysis in Java applications.
It provides real-time insights, enabling developers to understand and optimize their Java codebase effectively.
This tool is crucial for improving application responsiveness, reducing resource consumption, and ensuring top-notch performance in Java environments.&lt;/p></description></item><item><title>.NET</title><link>https://grafana.com/docs/pyroscope/v1.18.x/configure-client/language-sdks/dotnet/</link><pubDate>Wed, 08 Apr 2026 14:38:28 +0000</pubDate><guid>https://grafana.com/docs/pyroscope/v1.18.x/configure-client/language-sdks/dotnet/</guid><content><![CDATA[&lt;h1 id=&#34;net&#34;&gt;.NET&lt;/h1&gt;
&lt;p&gt;Our .NET Profiler is a powerful tool designed to enhance the performance analysis and optimization of .NET applications. It seamlessly integrates with Pyroscope, offering real-time insights into the resource usage and bottlenecks within your .NET codebase. This integration empowers developers to pinpoint inefficiencies, improve application speed, and ensure resource-efficient operation.&lt;/p&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;Refer to 
    &lt;a href=&#34;/docs/pyroscope/v1.18.x/configure-client/profile-types/&#34;&gt;Available profiling types&lt;/a&gt; for a list of profile types supported by each language.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;h2 id=&#34;supported-profiling-types&#34;&gt;Supported profiling types&lt;/h2&gt;
&lt;p&gt;The .NET Profiler supports the following profiling types:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;CPU&lt;/li&gt;
&lt;li&gt;Wall time&lt;/li&gt;
&lt;li&gt;Allocations&lt;/li&gt;
&lt;li&gt;Lock contention&lt;/li&gt;
&lt;li&gt;Exceptions&lt;/li&gt;
&lt;li&gt;Live heap (requires .NET 7&#43;)&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;compatibility&#34;&gt;Compatibility&lt;/h3&gt;
&lt;p&gt;The only compatible operating system and architecture combination is Linux running on amd64 architecture.&lt;/p&gt;
&lt;p&gt;Our .NET profiler works with the following .NET versions:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;.NET 6&lt;/li&gt;
&lt;li&gt;.NET 7&lt;/li&gt;
&lt;li&gt;.NET 8&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;before-you-begin&#34;&gt;Before you begin&lt;/h2&gt;
&lt;p&gt;To capture and analyze profiling data, you need either a hosted Pyroscope OSS server or a hosted &lt;a href=&#34;/products/cloud/profiles-for-continuous-profiling/&#34;&gt;Pyroscope instance with Grafana Cloud Profiles&lt;/a&gt; (requires a free Grafana Cloud account).&lt;/p&gt;
&lt;p&gt;The Pyroscope server can be a local server for development or a remote server for production use.&lt;/p&gt;
&lt;h2 id=&#34;configure-the-net-client&#34;&gt;Configure the .NET client&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;Obtain &lt;code&gt;Pyroscope.Profiler.Native.so&lt;/code&gt; and &lt;code&gt;Pyroscope.Linux.ApiWrapper.x64.so&lt;/code&gt; from the &lt;a href=&#34;https://github.com/pyroscope-io/pyroscope-dotnet/releases/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;latest tarball&lt;/a&gt;:&lt;/li&gt;
&lt;/ol&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;curl -s -L https://github.com/grafana/pyroscope-dotnet/releases/download/v0.13.0-pyroscope/pyroscope.0.13.0-glibc-x86_64.tar.gz  | tar xvz -C .&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Or copy them from the &lt;a href=&#34;https://hub.docker.com/r/pyroscope/pyroscope-dotnet/tags&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;latest docker image&lt;/a&gt;. We have &lt;code&gt;glibc&lt;/code&gt; and &lt;code&gt;musl&lt;/code&gt; versions:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;dockerfile&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-dockerfile&#34;&gt;COPY --from=pyroscope/pyroscope-dotnet:0.13.0-glibc /Pyroscope.Profiler.Native.so /dotnet/Pyroscope.Profiler.Native.so
COPY --from=pyroscope/pyroscope-dotnet:0.13.0-glibc /Pyroscope.Linux.ApiWrapper.x64.so /dotnet/Pyroscope.Linux.ApiWrapper.x64.so&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;ol start=&#34;2&#34;&gt;
&lt;li&gt;Set the following required environment variables to enable profiler&lt;/li&gt;
&lt;/ol&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;shell&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-shell&#34;&gt;PYROSCOPE_APPLICATION_NAME=rideshare.dotnet.app
PYROSCOPE_SERVER_ADDRESS=http://localhost:4040
PYROSCOPE_PROFILING_ENABLED=1
CORECLR_ENABLE_PROFILING=1
CORECLR_PROFILER={BD1A650D-AC5D-4896-B64F-D6FA25D6B26A}
CORECLR_PROFILER_PATH=/dotnet/Pyroscope.Profiler.Native.so
LD_PRELOAD=/dotnet/Pyroscope.Linux.ApiWrapper.x64.so
LD_LIBRARY_PATH=/dotnet&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;The &lt;code&gt;LD_LIBRARY_PATH&lt;/code&gt; environment variable should point to the directory containing the &lt;code&gt;Pyroscope.Profiler.Native.so&lt;/code&gt; file. This ensures that the dynamic linker can locate the profiler&amp;rsquo;s shared libraries at runtime.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;



&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;Since .NET version 8 the environment variable &lt;code&gt;DOTNET_EnableDiagnostics=0&lt;/code&gt; (or its legacy equivalent &lt;code&gt;COMPlus_EnableDiagnostics=0&lt;/code&gt;) will also disable the profiler. In order to get the previous behaviour (allowing profiling, but switch off IPC and Debugging) the following environment variables should be set instead:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;shell&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-shell&#34;&gt;DOTNET_EnableDiagnostics=1
DOTNET_EnableDiagnostics_IPC=0
DOTNET_EnableDiagnostics_Debugger=0
DOTNET_EnableDiagnostics_Profiler=1&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;h3 id=&#34;net-profiler-api&#34;&gt;.NET Profiler API&lt;/h3&gt;
&lt;p&gt;With a managed helper you can interact with the Pyroscope profiler from .NET runtime. You can add labels, turn on/off profiling types, and more.&lt;/p&gt;
&lt;p&gt;To use it, first, add the Pyroscope dependency:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;shell&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-shell&#34;&gt;dotnet add package Pyroscope&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt; &lt;/p&gt;
&lt;h3 id=&#34;add-profiling-labels-to-your-application&#34;&gt;Add profiling labels to your application&lt;/h3&gt;
&lt;p&gt;You can add labels to the profiling data to filter the data in the UI. Common labels include:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;hostname&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;region&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;team&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;api_endpoint&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Create a &lt;code&gt;LabelSet&lt;/code&gt; and wrap a piece of code with &lt;code&gt;Pyroscope.LabelsWrapper&lt;/code&gt;.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;cs&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-cs&#34;&gt;var labels = Pyroscope.LabelSet.Empty.BuildUpon()
    .Add(&amp;#34;key1&amp;#34;, &amp;#34;value1&amp;#34;)
    .Build();
Pyroscope.LabelsWrapper.Do(labels, () =&amp;gt;
{
  SlowCode();
});&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Labels can be nested. For nesting LabelSets use &lt;code&gt;LabelSet.BuildUpon&lt;/code&gt; on non-empty set.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;cs&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-cs&#34;&gt;var labels = Pyroscope.LabelSet.Empty.BuildUpon()
    .Add(&amp;#34;key1&amp;#34;, &amp;#34;value1&amp;#34;)
    .Build();
Pyroscope.LabelsWrapper.Do(labels, () =&amp;gt;
{
  var labels2 = labels.BuildUpon()
    .Add(&amp;#34;key2&amp;#34;, &amp;#34;value2&amp;#34;)
    .Build();
  Pyroscope.LabelsWrapper.Do(labels2, () =&amp;gt;
  {
    SlowCode();
  });
  FastCode();
});&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;dynamic-control&#34;&gt;Dynamic control&lt;/h3&gt;
&lt;p&gt;It is possible to dynamically enable/disable specific profiling types. Profiling types have to be configured prior.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;cs&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-cs&#34;&gt;// Enables or disables CPU/wall profiling dynamically.
// This function works in conjunction with the PYROSCOPE_PROFILING_CPU_ENABLED and
// PYROSCOPE_PROFILING_WALLTIME_ENABLED environment variables. If CPU/wall profiling is not
// configured, this function will have no effect.
Pyroscope.Profiler.Instance.SetCPUTrackingEnabled(enabled);
// Enables or disables allocation profiling dynamically.
// This function works in conjunction with the PYROSCOPE_PROFILING_ALLOCATION_ENABLED environment variable.
// If allocation profiling is not configured, this function will have no effect.
Pyroscope.Profiler.Instance.SetAllocationTrackingEnabled(enabled);
// Enables or disables contention profiling dynamically.
// This function works in conjunction with the PYROSCOPE_PROFILING_LOCK_ENABLED environment variable.
// If contention profiling is not configured, this function will have no effect.
Pyroscope.Profiler.Instance.SetContentionTrackingEnabled(enabled);
// Enables or disables exception profiling dynamically.
// This function works in conjunction with the PYROSCOPE_PROFILING_EXCEPTION_ENABLED environment variable.
// If exception profiling is not configured, this function will have no effect.
Pyroscope.Profiler.Instance.SetExceptionTrackingEnabled(enabled);&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;It is possible to dynamically change authorization credentials:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;cs&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-cs&#34;&gt;// Set Basic authorization username and password. Clears any previous authorization credentials.
Pyroscope.Profiler.Instance.SetBasicAuth(basicAuthUser, BasicAuthPassword);&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Here is a simple &lt;a href=&#34;https://github.com/grafana/pyroscope/blob/main/examples/language-sdk-instrumentation/dotnet/rideshare/example/Program.cs&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;example&lt;/a&gt; exposing these APIs as HTTP endpoints.&lt;/p&gt;
&lt;h3 id=&#34;configuration-options&#34;&gt;Configuration options&lt;/h3&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;ENVIRONMENT VARIABLE&lt;/th&gt;
              &lt;th&gt;Type&lt;/th&gt;
              &lt;th&gt;DESCRIPTION&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;PYROSCOPE_PROFILING_LOG_DIR&lt;/td&gt;
              &lt;td&gt;String&lt;/td&gt;
              &lt;td&gt;Sets the directory for .NET Profiler logs. Defaults to /var/log/pyroscope/.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;PYROSCOPE_LABELS&lt;/td&gt;
              &lt;td&gt;String&lt;/td&gt;
              &lt;td&gt;Static labels to apply to an uploaded profile. Must be a list of key:value separated by commas such as: layer:api or team:intake.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;PYROSCOPE_SERVER_ADDRESS&lt;/td&gt;
              &lt;td&gt;String&lt;/td&gt;
              &lt;td&gt;Address of the Pyroscope Server&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;PYROSCOPE_PROFILING_ENABLED&lt;/td&gt;
              &lt;td&gt;Boolean&lt;/td&gt;
              &lt;td&gt;If set to true, enables the .NET Profiler. Defaults to false.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;PYROSCOPE_PROFILING_WALLTIME_ENABLED&lt;/td&gt;
              &lt;td&gt;Boolean&lt;/td&gt;
              &lt;td&gt;If set to false, disables the Wall time profiling. Defaults to false.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;PYROSCOPE_PROFILING_CPU_ENABLED&lt;/td&gt;
              &lt;td&gt;Boolean&lt;/td&gt;
              &lt;td&gt;If set to false, disables the CPU profiling. Defaults to true.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;PYROSCOPE_PROFILING_EXCEPTION_ENABLED&lt;/td&gt;
              &lt;td&gt;Boolean&lt;/td&gt;
              &lt;td&gt;If set to true, enables the Exceptions profiling. Defaults to false.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;PYROSCOPE_PROFILING_ALLOCATION_ENABLED&lt;/td&gt;
              &lt;td&gt;Boolean&lt;/td&gt;
              &lt;td&gt;If set to true, enables the Allocations profiling. Defaults to false.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;PYROSCOPE_PROFILING_LOCK_ENABLED&lt;/td&gt;
              &lt;td&gt;Boolean&lt;/td&gt;
              &lt;td&gt;If set to true, enables the Lock Contention profiling. Defaults to false.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;PYROSCOPE_PROFILING_HEAP_ENABLED&lt;/td&gt;
              &lt;td&gt;Boolean&lt;/td&gt;
              &lt;td&gt;If set to true, enables the Live heap profiling. Requires .NET 7&#43;. Defaults to false.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;PYROSCOPE_BASIC_AUTH_USER&lt;/td&gt;
              &lt;td&gt;String&lt;/td&gt;
              &lt;td&gt;For HTTP Basic Authentication, use this to send profiles to authenticated server, for example Grafana Cloud&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;PYROSCOPE_BASIC_AUTH_PASSWORD&lt;/td&gt;
              &lt;td&gt;String&lt;/td&gt;
              &lt;td&gt;For HTTP Basic Authentication, use this to send profiles to authenticated server, for example Grafana Cloud&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;PYROSCOPE_TENANT_ID&lt;/td&gt;
              &lt;td&gt;String&lt;/td&gt;
              &lt;td&gt;Only needed if using multi-tenancy in Pyroscope.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h2 id=&#34;send-data-to-pyroscope-oss-or-grafana-cloud-profiles&#34;&gt;Send data to Pyroscope OSS or Grafana Cloud Profiles&lt;/h2&gt;
&lt;p&gt;To send profiling data from your .NET application, configure your environment for either Pyroscope OSS or Grafana Cloud Profiles using the following steps:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;export CORECLR_ENABLE_PROFILING=1
export CORECLR_PROFILER={BD1A650D-AC5D-4896-B64F-D6FA25D6B26A}
export CORECLR_PROFILER_PATH=/dotnet/Pyroscope.Profiler.Native.so
export LD_PRELOAD=/dotnet/Pyroscope.Linux.ApiWrapper.x64.so
export LD_LIBRARY_PATH=/dotnet
export PYROSCOPE_PROFILING_ENABLED=1
export PYROSCOPE_APPLICATION_NAME=example.dotnet.app
export PYROSCOPE_SERVER_ADDRESS=&amp;lt;URL&amp;gt;
# Use these environment variables to send data to Grafana Cloud Profiles
export PYROSCOPE_BASIC_AUTH_USER=&amp;lt;User&amp;gt;
export PYROSCOPE_BASIC_AUTH_PASSWORD=&amp;lt;Password&amp;gt;
# Optional Pyroscope tenant ID (only needed if using multi-tenancy). Not needed for Grafana Cloud.
# export PYROSCOPE_TENANT_ID=&amp;lt;TenantID&amp;gt;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;To configure the .NET SDK to send data to Grafana Cloud Profiles or Pyroscope, replace the &lt;code&gt;&amp;lt;URL&amp;gt;&lt;/code&gt; placeholder with the appropriate server URL. This could be the Grafana Cloud URL or your own custom Pyroscope server URL.&lt;/p&gt;
&lt;p&gt;If you need to send data to Grafana Cloud, you&amp;rsquo;ll have to configure HTTP Basic authentication. Replace &lt;code&gt;&amp;lt;User&amp;gt;&lt;/code&gt; with your Grafana Cloud stack user and &lt;code&gt;&amp;lt;Password&amp;gt;&lt;/code&gt; with your Grafana Cloud API key.&lt;/p&gt;
&lt;p&gt;If your open source Pyroscope server has multi-tenancy enabled, you&amp;rsquo;ll need to specify a tenant ID. Replace &lt;code&gt;&amp;lt;TenantID&amp;gt;&lt;/code&gt; with your Pyroscope tenant ID.&lt;/p&gt;
&lt;h3 id=&#34;locate-the-url-user-and-password-in-grafana-cloud-profiles&#34;&gt;Locate the URL, user, and password in Grafana Cloud Profiles&lt;/h3&gt;


&lt;div data-shared=&#34;locate-url-pw-user-cloud-profiles.md&#34;&gt;
            &lt;!-- Locate your stack&#39;s URL, user, and password --&gt;
&lt;p&gt;When you configure Alloy or your SDK, you need to provide the URL, user, and password for your Grafana Cloud stack.
This information is located in the &lt;strong&gt;Pyroscope&lt;/strong&gt; section of your Grafana Cloud stack.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Navigate to your Grafana Cloud stack.&lt;/li&gt;
&lt;li&gt;Select &lt;strong&gt;Details&lt;/strong&gt; next to your stack.&lt;/li&gt;
&lt;li&gt;Locate the &lt;strong&gt;Pyroscope&lt;/strong&gt; section and select &lt;strong&gt;Details&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Copy the &lt;strong&gt;URL&lt;/strong&gt;, &lt;strong&gt;User&lt;/strong&gt;, and &lt;strong&gt;Password&lt;/strong&gt; values in the &lt;strong&gt;Configure the client and data source using Grafana credentials&lt;/strong&gt; section.
&lt;img
  class=&#34;lazyload d-inline-block&#34;
  data-src=&#34;/media/docs/pyroscope/cloud-profiles-url-user-password.png&#34;
  alt=&#34;Locate the SDK or Grafana Alloy configuration values&#34; width=&#34;1029&#34;
     height=&#34;725&#34;/&gt;&lt;/li&gt;
&lt;li&gt;Use these values to complete the configuration.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;As an alternative, you can also create a Cloud Access Policy and generate a token to use instead of the user and password.
For more information, refer to &lt;a href=&#34;/docs/grafana-cloud/security-and-account-management/authentication-and-permissions/access-policies/create-access-policies/&#34;&gt;Create a Cloud Access Policy&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;

        
]]></content><description>&lt;h1 id="net">.NET&lt;/h1>
&lt;p>Our .NET Profiler is a powerful tool designed to enhance the performance analysis and optimization of .NET applications. It seamlessly integrates with Pyroscope, offering real-time insights into the resource usage and bottlenecks within your .NET codebase. This integration empowers developers to pinpoint inefficiencies, improve application speed, and ensure resource-efficient operation.&lt;/p></description></item><item><title>Python</title><link>https://grafana.com/docs/pyroscope/v1.18.x/configure-client/language-sdks/python/</link><pubDate>Wed, 08 Apr 2026 14:38:28 +0000</pubDate><guid>https://grafana.com/docs/pyroscope/v1.18.x/configure-client/language-sdks/python/</guid><content><![CDATA[&lt;h1 id=&#34;python&#34;&gt;Python&lt;/h1&gt;
&lt;p&gt;The Python profiler, when integrated with Pyroscope, transforms the way you analyze and optimize Python applications.
This combination provides unparalleled real-time insights into your Python codebase, allowing for precise identification of performance issues
It&amp;rsquo;s an essential tool for Python developers focused on enhancing code efficiency and application speed.&lt;/p&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;Refer to 
    &lt;a href=&#34;/docs/pyroscope/v1.18.x/configure-client/profile-types/&#34;&gt;Available profiling types&lt;/a&gt; for a list of profile types supported by each language.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;h2 id=&#34;before-you-begin&#34;&gt;Before you begin&lt;/h2&gt;
&lt;p&gt;To capture and analyze profiling data, you need either a hosted Pyroscope OSS server or a hosted &lt;a href=&#34;/products/cloud/profiles-for-continuous-profiling/&#34;&gt;Pyroscope instance with Grafana Cloud Profiles&lt;/a&gt; (requires a free Grafana Cloud account).&lt;/p&gt;
&lt;p&gt;The Pyroscope server can be a local server for development or a remote server for production use.&lt;/p&gt;
&lt;h3 id=&#34;profiling-on-macos&#34;&gt;Profiling on macOS&lt;/h3&gt;
&lt;p&gt;macOS has a feature called System Integrity Protection (SIP) that prevents even the root user from reading memory from any binary located in system folders.&lt;/p&gt;
&lt;p&gt;The easiest way to avoid interference from SIP, is by installing a Python distribution into your home folder. This can be achieved for example by using &lt;code&gt;pyenv&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;# Setup pyenv
brew update
brew install pyenv
echo &amp;#39;export PYENV_ROOT=&amp;#34;$HOME/.pyenv&amp;#34;&amp;#39; &amp;gt;&amp;gt; ~/.zshrc
echo &amp;#39;[[ -d $PYENV_ROOT/bin ]] &amp;amp;&amp;amp; export PATH=&amp;#34;$PYENV_ROOT/bin:$PATH&amp;#34;&amp;#39; &amp;gt;&amp;gt; ~/.zshrc
echo &amp;#39;eval &amp;#34;$(pyenv init - zsh)&amp;#34;&amp;#39; &amp;gt;&amp;gt; ~/.zshrc
#  Restart your shell
exec &amp;#34;$SHELL&amp;#34;
# Install Python 3.12
pyenv install 3.12&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;add-python-profiling-to-your-application&#34;&gt;Add Python profiling to your application&lt;/h2&gt;
&lt;p&gt;Install the &lt;code&gt;pyroscope-io&lt;/code&gt; pip package:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;pip install pyroscope-io&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;configure-the-python-client&#34;&gt;Configure the Python client&lt;/h2&gt;
&lt;p&gt;Add the following code to your application. This code will initialize the Pyroscope profiler and start profiling:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Python&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-python&#34;&gt;import pyroscope

pyroscope.configure(
  application_name = &amp;#34;my.python.app&amp;#34;, # replace this with some name for your application
  server_address   = &amp;#34;http://my-pyroscope-server:4040&amp;#34;, # replace this with the address of your Pyroscope server
)&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Optionally, you can configure several additional parameters:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Python&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-python&#34;&gt;import os
import pyroscope

pyroscope.configure(
    application_name    = &amp;#34;my.python.app&amp;#34;, # replace this with some name for your application
    server_address      = &amp;#34;http://my-pyroscope-server:4040&amp;#34;, # replace this with the address of your Pyroscope server
    sample_rate         = 100, # default is 100
    detect_subprocesses = False, # detect subprocesses started by the main process; default is False
    oncpu               = True, # report cpu time only; default is True
    gil_only            = True, # only include traces for threads that are holding on to the Global Interpreter Lock; default is True
    enable_logging      = True, # does enable logging facility; default is False
    tags                = {
        &amp;#34;region&amp;#34;: f&amp;#39;{os.getenv(&amp;#34;REGION&amp;#34;)}&amp;#39;,
    }
)&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;add-profiling-labels-to-python-applications&#34;&gt;Add profiling labels to Python applications&lt;/h2&gt;
&lt;p&gt;You can add tags to certain parts of your code:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Python&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-python&#34;&gt;# You can use a wrapper:
with pyroscope.tag_wrapper({ &amp;#34;controller&amp;#34;: &amp;#34;slow_controller_i_want_to_profile&amp;#34; }):
    slow_code()&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;sending-data-to-pyroscope-oss-or-grafana-cloud-profiles-with-python-sdk&#34;&gt;Sending data to Pyroscope OSS or Grafana Cloud Profiles with Python SDK&lt;/h2&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Python&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-python&#34;&gt;import pyroscope

pyroscope.configure(
    application_name = &amp;#34;example.python.app&amp;#34;,
    server_address = &amp;#34;&amp;lt;URL&amp;gt;&amp;#34;,
    basic_auth_username = &amp;#39;&amp;lt;User&amp;gt;&amp;#39;,
    basic_auth_password = &amp;#39;&amp;lt;Password&amp;gt;&amp;#39;,
    # Optional Pyroscope tenant ID (only needed if using multi-tenancy). Not needed for Grafana Cloud.
    # tenant_id = &amp;#34;&amp;lt;TenantID&amp;gt;&amp;#34;,
)&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;To configure the Python SDK to send data to Pyroscope, replace the &lt;code&gt;&amp;lt;URL&amp;gt;&lt;/code&gt; placeholder with the appropriate server URL. This could be the Grafana Cloud URL or your own custom Pyroscope server URL.&lt;/p&gt;
&lt;p&gt;If you need to send data to Grafana Cloud, you&amp;rsquo;ll have to configure HTTP Basic authentication. Replace &lt;code&gt;&amp;lt;User&amp;gt;&lt;/code&gt; with your Grafana Cloud stack user and &lt;code&gt;&amp;lt;Password&amp;gt;&lt;/code&gt; with your Grafana Cloud API key.&lt;/p&gt;
&lt;p&gt;If your Pyroscope server has multi-tenancy enabled, you&amp;rsquo;ll need to configure a tenant ID. Replace &lt;code&gt;&amp;lt;TenantID&amp;gt;&lt;/code&gt; with your Pyroscope tenant ID.&lt;/p&gt;
&lt;h3 id=&#34;locate-the-url-user-and-password-in-grafana-cloud-profiles&#34;&gt;Locate the URL, user, and password in Grafana Cloud Profiles&lt;/h3&gt;


&lt;div data-shared=&#34;locate-url-pw-user-cloud-profiles.md&#34;&gt;
            &lt;!-- Locate your stack&#39;s URL, user, and password --&gt;
&lt;p&gt;When you configure Alloy or your SDK, you need to provide the URL, user, and password for your Grafana Cloud stack.
This information is located in the &lt;strong&gt;Pyroscope&lt;/strong&gt; section of your Grafana Cloud stack.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Navigate to your Grafana Cloud stack.&lt;/li&gt;
&lt;li&gt;Select &lt;strong&gt;Details&lt;/strong&gt; next to your stack.&lt;/li&gt;
&lt;li&gt;Locate the &lt;strong&gt;Pyroscope&lt;/strong&gt; section and select &lt;strong&gt;Details&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Copy the &lt;strong&gt;URL&lt;/strong&gt;, &lt;strong&gt;User&lt;/strong&gt;, and &lt;strong&gt;Password&lt;/strong&gt; values in the &lt;strong&gt;Configure the client and data source using Grafana credentials&lt;/strong&gt; section.
&lt;img
  class=&#34;lazyload d-inline-block&#34;
  data-src=&#34;/media/docs/pyroscope/cloud-profiles-url-user-password.png&#34;
  alt=&#34;Locate the SDK or Grafana Alloy configuration values&#34; width=&#34;1029&#34;
     height=&#34;725&#34;/&gt;&lt;/li&gt;
&lt;li&gt;Use these values to complete the configuration.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;As an alternative, you can also create a Cloud Access Policy and generate a token to use instead of the user and password.
For more information, refer to &lt;a href=&#34;/docs/grafana-cloud/security-and-account-management/authentication-and-permissions/access-policies/create-access-policies/&#34;&gt;Create a Cloud Access Policy&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;

        
&lt;h2 id=&#34;python-profiling-examples&#34;&gt;Python profiling examples&lt;/h2&gt;
&lt;p&gt;Check out the following resources to learn more about Python profiling:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://github.com/pyroscope-io/pyroscope/tree/main/examples/language-sdk-instrumentation/python&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Python examples&lt;/a&gt; demonstrating how Django, Flask, and FastAPI apps can be profiled with Pyroscope.&lt;/li&gt;
&lt;li&gt;A &lt;a href=&#34;https://play.grafana.org/a/grafana-pyroscope-app/profiles-explorer?searchText=&amp;amp;panelType=time-series&amp;amp;layout=grid&amp;amp;hideNoData=off&amp;amp;explorationType=flame-graph&amp;amp;var-serviceName=pyroscope-rideshare-python&amp;amp;var-profileMetricId=process_cpu:cpu:nanoseconds:cpu:nanoseconds&amp;amp;var-dataSource=grafanacloud-profiles&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Python demo&lt;/a&gt; on play.grafana.org.&lt;/li&gt;
&lt;/ul&gt;
]]></content><description>&lt;h1 id="python">Python&lt;/h1>
&lt;p>The Python profiler, when integrated with Pyroscope, transforms the way you analyze and optimize Python applications.
This combination provides unparalleled real-time insights into your Python codebase, allowing for precise identification of performance issues
It&amp;rsquo;s an essential tool for Python developers focused on enhancing code efficiency and application speed.&lt;/p></description></item><item><title>Ruby</title><link>https://grafana.com/docs/pyroscope/v1.18.x/configure-client/language-sdks/ruby/</link><pubDate>Wed, 08 Apr 2026 14:38:28 +0000</pubDate><guid>https://grafana.com/docs/pyroscope/v1.18.x/configure-client/language-sdks/ruby/</guid><content><![CDATA[&lt;h1 id=&#34;ruby&#34;&gt;Ruby&lt;/h1&gt;
&lt;p&gt;The Ruby Profiler revolutionizes performance tuning in Ruby applications.
Integrated with Pyroscope, it offers real-time performance data, allowing developers to delve deep into their Ruby codebase.
This tool is essential for identifying performance issues, optimizing code efficiency, and enhancing the overall speed and reliability of Ruby applications.&lt;/p&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;Refer to 
    &lt;a href=&#34;/docs/pyroscope/v1.18.x/configure-client/profile-types/&#34;&gt;Available profiling types&lt;/a&gt; for a list of profile types supported by Ruby.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;h2 id=&#34;before-you-begin&#34;&gt;Before you begin&lt;/h2&gt;
&lt;p&gt;To capture and analyze profiling data, you need either a hosted Pyroscope OSS server or a hosted &lt;a href=&#34;/products/cloud/profiles-for-continuous-profiling/&#34;&gt;Pyroscope instance with Grafana Cloud Profiles&lt;/a&gt; (requires a free Grafana Cloud account).&lt;/p&gt;
&lt;p&gt;The Pyroscope server can be a local server for development or a remote server for production use.&lt;/p&gt;
&lt;h2 id=&#34;add-ruby-profiling-to-your-application&#34;&gt;Add Ruby profiling to your application&lt;/h2&gt;
&lt;p&gt;Add the &lt;code&gt;pyroscope&lt;/code&gt; gem to your Gemfile:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;bundle add pyroscope&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;configure-the-ruby-client&#34;&gt;Configure the Ruby client&lt;/h2&gt;
&lt;p&gt;Add the following code to your application. If you&amp;rsquo;re using Rails, put this into &lt;code&gt;config/initializers&lt;/code&gt; directory. This code will initialize the Pyroscope profiler and start profiling:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;ruby&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-ruby&#34;&gt;require &amp;#39;pyroscope&amp;#39;

Pyroscope.configure do |config|
  config.application_name = &amp;#34;my.ruby.app&amp;#34; # replace this with some name for your application
  config.server_address   = &amp;#34;http://my-pyroscope-server:4040&amp;#34; # replace this with the address of your Pyroscope server
end&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;how-to-add-profiling-labels-to-ruby-applications&#34;&gt;How to add profiling labels to Ruby applications&lt;/h2&gt;
&lt;p&gt;The Pyroscope Ruby integration provides a number of ways to tag profiling data. For example, you can provide tags when you&amp;rsquo;re initializing the profiler:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;ruby&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-ruby&#34;&gt;require &amp;#39;pyroscope&amp;#39;

Pyroscope.configure do |config|
  config.application_name = &amp;#34;my.ruby.app&amp;#34;
  config.server_address   = &amp;#34;http://my-pyroscope-server:4040&amp;#34;

  config.tags = {
    &amp;#34;hostname&amp;#34; =&amp;gt; ENV[&amp;#34;HOSTNAME&amp;#34;],
  }
end&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Or you can dynamically tag certain parts of your code:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;ruby&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-ruby&#34;&gt;Pyroscope.tag_wrapper({ &amp;#34;controller&amp;#34;: &amp;#34;slow_controller_i_want_to_profile&amp;#34; }) do
  slow_code
end&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;rails-profiling-auto-instrumentation&#34;&gt;Rails profiling auto-instrumentation&lt;/h2&gt;
&lt;p&gt;By default, if you add Pyroscope to a Rails application it will automatically tag your actions with a &lt;code&gt;action=&amp;quot;&amp;lt;controller_name&amp;gt;/&amp;lt;action_name&amp;gt;&amp;quot;&lt;/code&gt; tag.&lt;/p&gt;
&lt;p&gt;To disable Rails auto-instrumentation, set &lt;code&gt;autoinstrument_rails&lt;/code&gt; to &lt;code&gt;false&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;ruby&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-ruby&#34;&gt;Pyroscope.configure do |config|
  config.autoinstrument_rails = false
  # more configuration
end&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;sending-data-to-pyroscope-oss-or-grafana-cloud-profiles-with-ruby-sdk&#34;&gt;Sending data to Pyroscope OSS or Grafana Cloud Profiles with Ruby SDK&lt;/h2&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;ruby&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-ruby&#34;&gt;require &amp;#34;pyroscope&amp;#34;

Pyroscope.configure do |config|
  config.application_name = &amp;#34;example.ruby.app&amp;#34;
  config.server_address = &amp;#34;&amp;lt;URL&amp;gt;&amp;#34;
  config.basic_auth_username=&amp;#39;&amp;lt;User&amp;gt;&amp;#39;
  config.basic_auth_password=&amp;#39;&amp;lt;Password&amp;gt;&amp;#39;
  # Optional Pyroscope tenant ID (only needed if using multi-tenancy). Not needed for Grafana Cloud.
  # config.tenant_id=&amp;#39;&amp;lt;TenantID&amp;gt;&amp;#39;
end&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;To configure the Ruby SDK to send data to Pyroscope, replace the &lt;code&gt;&amp;lt;URL&amp;gt;&lt;/code&gt; placeholder with the appropriate server URL. This could be the Grafana Cloud URL or your own custom Pyroscope server URL.&lt;/p&gt;
&lt;p&gt;If you need to send data to Grafana Cloud, you&amp;rsquo;ll have to configure HTTP Basic authentication. Replace &lt;code&gt;&amp;lt;User&amp;gt;&lt;/code&gt; with your Grafana Cloud stack user and &lt;code&gt;&amp;lt;Password&amp;gt;&lt;/code&gt; with your Grafana Cloud API key.&lt;/p&gt;
&lt;p&gt;If your Pyroscope server has multi-tenancy enabled, you&amp;rsquo;ll need to configure a tenant ID. Replace &lt;code&gt;&amp;lt;TenantID&amp;gt;&lt;/code&gt; with your Pyroscope tenant ID.&lt;/p&gt;
&lt;h3 id=&#34;locate-the-url-user-and-password-in-grafana-cloud-profiles&#34;&gt;Locate the URL, user, and password in Grafana Cloud Profiles&lt;/h3&gt;


&lt;div data-shared=&#34;locate-url-pw-user-cloud-profiles.md&#34;&gt;
            &lt;!-- Locate your stack&#39;s URL, user, and password --&gt;
&lt;p&gt;When you configure Alloy or your SDK, you need to provide the URL, user, and password for your Grafana Cloud stack.
This information is located in the &lt;strong&gt;Pyroscope&lt;/strong&gt; section of your Grafana Cloud stack.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Navigate to your Grafana Cloud stack.&lt;/li&gt;
&lt;li&gt;Select &lt;strong&gt;Details&lt;/strong&gt; next to your stack.&lt;/li&gt;
&lt;li&gt;Locate the &lt;strong&gt;Pyroscope&lt;/strong&gt; section and select &lt;strong&gt;Details&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Copy the &lt;strong&gt;URL&lt;/strong&gt;, &lt;strong&gt;User&lt;/strong&gt;, and &lt;strong&gt;Password&lt;/strong&gt; values in the &lt;strong&gt;Configure the client and data source using Grafana credentials&lt;/strong&gt; section.
&lt;img
  class=&#34;lazyload d-inline-block&#34;
  data-src=&#34;/media/docs/pyroscope/cloud-profiles-url-user-password.png&#34;
  alt=&#34;Locate the SDK or Grafana Alloy configuration values&#34; width=&#34;1029&#34;
     height=&#34;725&#34;/&gt;&lt;/li&gt;
&lt;li&gt;Use these values to complete the configuration.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;As an alternative, you can also create a Cloud Access Policy and generate a token to use instead of the user and password.
For more information, refer to &lt;a href=&#34;/docs/grafana-cloud/security-and-account-management/authentication-and-permissions/access-policies/create-access-policies/&#34;&gt;Create a Cloud Access Policy&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;

        
&lt;h2 id=&#34;ruby-profiling-examples&#34;&gt;Ruby profiling examples&lt;/h2&gt;
&lt;p&gt;Check out the following resources to learn more about Ruby profiling:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://github.com/pyroscope-io/pyroscope/tree/main/examples/language-sdk-instrumentation/ruby&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Ruby examples&lt;/a&gt; demonstrating how Ruby applications, including Rails, can be profiled with Pyroscope.&lt;/li&gt;
&lt;li&gt;A &lt;a href=&#34;https://play.grafana.org/a/grafana-pyroscope-app/profiles-explorer?searchText=&amp;amp;panelType=time-series&amp;amp;layout=grid&amp;amp;hideNoData=off&amp;amp;explorationType=flame-graph&amp;amp;var-serviceName=pyroscope-rideshare-ruby&amp;amp;var-profileMetricId=process_cpu:cpu:nanoseconds:cpu:nanoseconds&amp;amp;var-dataSource=grafanacloud-profiles&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Ruby demo&lt;/a&gt; on play.grafana.org.&lt;/li&gt;
&lt;/ul&gt;
]]></content><description>&lt;h1 id="ruby">Ruby&lt;/h1>
&lt;p>The Ruby Profiler revolutionizes performance tuning in Ruby applications.
Integrated with Pyroscope, it offers real-time performance data, allowing developers to delve deep into their Ruby codebase.
This tool is essential for identifying performance issues, optimizing code efficiency, and enhancing the overall speed and reliability of Ruby applications.&lt;/p></description></item><item><title>Rust</title><link>https://grafana.com/docs/pyroscope/v1.18.x/configure-client/language-sdks/rust/</link><pubDate>Wed, 08 Apr 2026 14:38:28 +0000</pubDate><guid>https://grafana.com/docs/pyroscope/v1.18.x/configure-client/language-sdks/rust/</guid><content><![CDATA[&lt;h1 id=&#34;rust&#34;&gt;Rust&lt;/h1&gt;
&lt;p&gt;Optimize your Rust applications with our advanced Rust Profiler.
In collaboration with Pyroscope, it offers real-time profiling capabilities, shedding light on the intricacies of your Rust codebase.
This integration is invaluable for developers seeking to enhance performance, reduce resource usage, and achieve efficient code execution in Rust applications.&lt;/p&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;Refer to 
    &lt;a href=&#34;/docs/pyroscope/v1.18.x/configure-client/profile-types/&#34;&gt;Available profiling types&lt;/a&gt; for a list of profile types supported by Rust.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;h2 id=&#34;before-you-begin&#34;&gt;Before you begin&lt;/h2&gt;
&lt;p&gt;To capture and analyze profiling data, you need either a hosted Pyroscope OSS server or a hosted &lt;a href=&#34;/products/cloud/profiles-for-continuous-profiling/&#34;&gt;Pyroscope instance with Grafana Cloud Profiles&lt;/a&gt; (requires a free Grafana Cloud account).&lt;/p&gt;
&lt;p&gt;The Pyroscope server can be a local server for development or a remote server for production use.&lt;/p&gt;
&lt;h2 id=&#34;add-rust-profiling-to-your-application&#34;&gt;Add Rust profiling to your application&lt;/h2&gt;
&lt;p&gt;Add the &lt;code&gt;pyroscope&lt;/code&gt; and &lt;code&gt;pyroscope_pprofrs&lt;/code&gt; crates to your Cargo.toml:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;cargo add pyroscope
cargo add pyroscope_pprofrs&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;configure-the-rust-client&#34;&gt;Configure the Rust client&lt;/h2&gt;
&lt;p&gt;At a minimum, you need to provide the URL of the Pyroscope server and the name
of your application. You also need to configure a profiling backend. For Rust,
you can use &lt;a href=&#34;https://github.com/pyroscope-io/pyroscope-rs/tree/main/pyroscope_backends/pyroscope_pprofrs&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;pprof-rs&lt;/a&gt;.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;rust&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-rust&#34;&gt;// Configure profiling backend
let pprof_config = PprofConfig::new().sample_rate(100);
let backend_impl = pprof_backend(pprof_config);

// Configure Pyroscope Agent
let agent = PyroscopeAgent::builder(&amp;#34;http://localhost:4040&amp;#34;, &amp;#34;myapp&amp;#34;)
    .backend(backend_impl)
    .build()?;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Users of a secured backend will need to provide authentication details. &lt;strong&gt;Grafana Cloud&lt;/strong&gt; uses Basic authentication. Your username is a numeric value which you can get from the &amp;ldquo;Details Page&amp;rdquo; for Pyroscope from your stack on grafana.com. On this same page, create a token and use it as the Basic authentication password. The configuration then would look similar to:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;rust&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-rust&#34;&gt;fn  main() -&amp;gt;  Result&amp;lt;()&amp;gt; {
std::env::set_var(&amp;#34;RUST_LOG&amp;#34;, &amp;#34;debug&amp;#34;);
pretty_env_logger::init_timed();
let user = std::env::var(&amp;#34;USER&amp;#34;).unwrap();
let password = std::env::var(&amp;#34;PASSWORD&amp;#34;).unwrap();
let url = std::env::var(&amp;#34;PYROSCOPE_URL&amp;#34;).unwrap();
let samplerate = std::env::var(&amp;#34;SAMPLE_RATE&amp;#34;).unwrap().to_string().parse().unwrap();
let application_name = &amp;#34;example.basic&amp;#34;;

let agent = PyroscopeAgent::builder(url, application_name.to_string())
    .basic_auth(user, password).backend(pprof_backend(PprofConfig::new().sample_rate(samplerate)))
    .tags([(&amp;#34;app&amp;#34;, &amp;#34;Rust&amp;#34;), (&amp;#34;TagB&amp;#34;, &amp;#34;ValueB&amp;#34;)].to_vec())
    .build()?;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;You can start profiling by invoking the following code:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;rust&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-rust&#34;&gt;let agent_running = agent.start().unwrap();&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;The agent can be stopped at any point, and it&amp;rsquo;ll send a last report to the server. The agent can be restarted at a later point.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;rust&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-rust&#34;&gt;let agent_ready = agent.stop().unwrap();&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;It&amp;rsquo;s recommended to shut down the agent before exiting the application. A last
request to the server might be missed if the agent is not shutdown properly.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;rust&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-rust&#34;&gt;agent_ready.shutdown();&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;locate-the-url-user-and-password-in-grafana-cloud-profiles&#34;&gt;Locate the URL, user, and password in Grafana Cloud Profiles&lt;/h3&gt;


&lt;div data-shared=&#34;locate-url-pw-user-cloud-profiles.md&#34;&gt;
            &lt;!-- Locate your stack&#39;s URL, user, and password --&gt;
&lt;p&gt;When you configure Alloy or your SDK, you need to provide the URL, user, and password for your Grafana Cloud stack.
This information is located in the &lt;strong&gt;Pyroscope&lt;/strong&gt; section of your Grafana Cloud stack.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Navigate to your Grafana Cloud stack.&lt;/li&gt;
&lt;li&gt;Select &lt;strong&gt;Details&lt;/strong&gt; next to your stack.&lt;/li&gt;
&lt;li&gt;Locate the &lt;strong&gt;Pyroscope&lt;/strong&gt; section and select &lt;strong&gt;Details&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Copy the &lt;strong&gt;URL&lt;/strong&gt;, &lt;strong&gt;User&lt;/strong&gt;, and &lt;strong&gt;Password&lt;/strong&gt; values in the &lt;strong&gt;Configure the client and data source using Grafana credentials&lt;/strong&gt; section.
&lt;img
  class=&#34;lazyload d-inline-block&#34;
  data-src=&#34;/media/docs/pyroscope/cloud-profiles-url-user-password.png&#34;
  alt=&#34;Locate the SDK or Grafana Alloy configuration values&#34; width=&#34;1029&#34;
     height=&#34;725&#34;/&gt;&lt;/li&gt;
&lt;li&gt;Use these values to complete the configuration.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;As an alternative, you can also create a Cloud Access Policy and generate a token to use instead of the user and password.
For more information, refer to &lt;a href=&#34;/docs/grafana-cloud/security-and-account-management/authentication-and-permissions/access-policies/create-access-policies/&#34;&gt;Create a Cloud Access Policy&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;

        
&lt;h2 id=&#34;add-profiling-labels-to-rust-applications&#34;&gt;Add profiling labels to Rust applications&lt;/h2&gt;
&lt;p&gt;Tags can be added or removed after the agent is started. As of 0.5.0, the
Pyroscope Agent supports tagging within threads. Check the &lt;a href=&#34;https://github.com/pyroscope-io/pyroscope-rs/blob/main/examples/tags.rs&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;tags&lt;/a&gt; and &lt;a href=&#34;https://github.com/pyroscope-io/pyroscope-rs/blob/main/examples/multi-thread.rs&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;multi-thread&lt;/a&gt; examples for detailed usage.&lt;/p&gt;
&lt;p&gt;After the agent is started, the &lt;code&gt;tag_wrapper&lt;/code&gt; function becomes available.
&lt;code&gt;tag_wrapper&lt;/code&gt; returns a tuple of functions to add and remove tags to the agent
across thread boundaries. This function is available as long as the agent is
running and can be called multiple times.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;rust&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-rust&#34;&gt;// Start Profiling
let agent_running = agent.start().unwrap();

// Generate Tag Wrapper functions
let (add_tag, remove_tag) = agent_running.tag_wrapper();

// Profiled code (with no tags)

// Add tags to the agent
add_tag(&amp;#34;key&amp;#34;.to_string(), &amp;#34;value&amp;#34;.to_string());

// This portion will be profiled with the specified tag.

// Remove tags from the agent
remove_tag(&amp;#34;key&amp;#34;.to_string(), &amp;#34;value&amp;#34;.to_string());

// Stop the agent
let agent_ready = running_agent.stop();&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;rust-client-configuration-options&#34;&gt;Rust client configuration options&lt;/h2&gt;
&lt;p&gt;The agent accepts additional initial parameters:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Backend&lt;/strong&gt;: Profiling backend. For Rust, it&amp;rsquo;s &lt;a href=&#34;https://github.com/pyroscope-io/pyroscope-rs/tree/main/pyroscope_backends/pyroscope_pprofrs&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;pprof-rs&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Sample Rate&lt;/strong&gt;: Sampling Frequency in Hertz. Default is 100.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Tags&lt;/strong&gt;: Initial tags.&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;rust&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-rust&#34;&gt;// Configure Profiling backend
let pprof_config = PprofConfig::new().sample_rate(100);
let pprof_backend = Pprof::new(pprof_config);

// Configure Pyroscope Agent
let agent =
PyroscopeAgent::builder(&amp;#34;http://localhost:4040&amp;#34;, &amp;#34;myapp&amp;#34;)
// Profiling backend
.backend(pprof_backend)
// Sample rate
.sample_rate(100)
// Tags
.tags(vec![(&amp;#34;env&amp;#34;, &amp;#34;dev&amp;#34;)])
// Create the agent
.build()?;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;technical-details&#34;&gt;Technical details&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Backend&lt;/strong&gt;: The Pyroscope Agent uses &lt;a href=&#34;https://github.com/tikv/pprof-rs&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;pprof-rs&lt;/a&gt; as a backend. As a result, the &lt;a href=&#34;https://github.com/tikv/pprof-rs#why-not-&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;limitations&lt;/a&gt; for pprof-rs also applies.
As of 0.5.0, the Pyroscope Agent supports tagging within threads. Check the &lt;a href=&#34;https://github.com/pyroscope-io/pyroscope-rs/blob/main/examples/tags.rs&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;tags&lt;/a&gt; and &lt;a href=&#34;https://github.com/pyroscope-io/pyroscope-rs/blob/main/examples/multi-thread.rs&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;multi-thread&lt;/a&gt; examples for usage.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Timer&lt;/strong&gt;: epoll (for Linux) and kqueue (for macOS) are required for a more precise timer.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Shutdown&lt;/strong&gt;: The Pyroscope Agent might take some time (usually less than 10 seconds) to shut down properly and drop its threads. For a proper shutdown, it&amp;rsquo;s recommended that you run the &lt;code&gt;shutdown&lt;/code&gt; function before dropping the agent.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Relevant Links&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://github.com/pyroscope-io/pyroscope-rs&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;GitHub Repository&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://crates.io/crates/pyroscope&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Cargo crate&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://docs.rs/pyroscope/latest/pyroscope/index.html&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Crate documentation&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;examples&#34;&gt;Examples&lt;/h2&gt;
&lt;h3 id=&#34;usage-examples&#34;&gt;Usage examples&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://github.com/pyroscope-io/pyroscope-rs/blob/main/examples/basic.rs&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;&lt;strong&gt;basic&lt;/strong&gt;&lt;/a&gt;: Minimal configuration example.&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://github.com/pyroscope-io/pyroscope-rs/blob/main/examples/tags.rs&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;&lt;strong&gt;tags&lt;/strong&gt;&lt;/a&gt;: Example using Tags.&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://github.com/pyroscope-io/pyroscope-rs/blob/main/examples/async.rs&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;&lt;strong&gt;async&lt;/strong&gt;&lt;/a&gt;: Example using Async code with Tokio.&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://github.com/pyroscope-io/pyroscope-rs/blob/main/examples/multi-thread.rs&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;&lt;strong&gt;multi-thread&lt;/strong&gt;&lt;/a&gt;: Example using multiple threads.&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://github.com/pyroscope-io/pyroscope-rs/blob/main/examples/with-logger.rs&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;&lt;strong&gt;with-logger&lt;/strong&gt;&lt;/a&gt;: Example with logging to stdout.&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://github.com/pyroscope-io/pyroscope-rs/blob/main/examples/error.rs&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;&lt;strong&gt;error&lt;/strong&gt;&lt;/a&gt;: Example with an invalid server address.&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&#34;stand-alone-examples&#34;&gt;Stand-alone examples&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://github.com/grafana/pyroscope/tree/main/examples/language-sdk-instrumentation/rust/basic&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;&lt;strong&gt;basic&lt;/strong&gt;&lt;/a&gt;: Simple Rust application that uses the Pyroscope Library.&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://github.com/grafana/pyroscope/tree/main/examples/language-sdk-instrumentation/rust/rideshare&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;&lt;strong&gt;rideshare&lt;/strong&gt;&lt;/a&gt;: A multi-instances web service running on Docker.&lt;/li&gt;
&lt;/ul&gt;
]]></content><description>&lt;h1 id="rust">Rust&lt;/h1>
&lt;p>Optimize your Rust applications with our advanced Rust Profiler.
In collaboration with Pyroscope, it offers real-time profiling capabilities, shedding light on the intricacies of your Rust codebase.
This integration is invaluable for developers seeking to enhance performance, reduce resource usage, and achieve efficient code execution in Rust applications.&lt;/p></description></item><item><title>Node.js</title><link>https://grafana.com/docs/pyroscope/v1.18.x/configure-client/language-sdks/nodejs/</link><pubDate>Wed, 08 Apr 2026 14:38:28 +0000</pubDate><guid>https://grafana.com/docs/pyroscope/v1.18.x/configure-client/language-sdks/nodejs/</guid><content><![CDATA[&lt;h1 id=&#34;nodejs&#34;&gt;Node.js&lt;/h1&gt;
&lt;p&gt;Enhance your Node.js application&amp;rsquo;s performance with our Node.js Profiler. Seamlessly integrated with Pyroscope, it provides real-time insights into your application’s operation, helping you identify and resolve performance bottlenecks. This integration is key for Node.js developers aiming to boost efficiency, reduce latency, and maintain optimal application performance.&lt;/p&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;Refer to 
    &lt;a href=&#34;/docs/pyroscope/v1.18.x/configure-client/profile-types/&#34;&gt;Available profiling types&lt;/a&gt; for a list of profile types supported by each language.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;h2 id=&#34;before-you-begin&#34;&gt;Before you begin&lt;/h2&gt;
&lt;p&gt;To capture and analyze profiling data, you need either a hosted Pyroscope OSS server or a hosted &lt;a href=&#34;/products/cloud/profiles-for-continuous-profiling/&#34;&gt;Pyroscope instance with Grafana Cloud Profiles&lt;/a&gt; (requires a free Grafana Cloud account).&lt;/p&gt;
&lt;p&gt;The Pyroscope server can be a local server for development or a remote server for production use.&lt;/p&gt;
&lt;h2 id=&#34;add-nodejs-profiling-to-your-application&#34;&gt;Add Node.js profiling to your application&lt;/h2&gt;
&lt;p&gt;To start profiling a Node.js application, you need to include the npm module in your app:&lt;/p&gt;

&lt;div class=&#34;code-snippet code-snippet__mini&#34;&gt;&lt;div class=&#34;lang-toolbar__mini&#34;&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet code-snippet__border&#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-none&#34;&gt;npm install @pyroscope/nodejs

# or
yarn add @pyroscope/nodejs&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;configure-the-nodejs-client&#34;&gt;Configure the Node.js client&lt;/h2&gt;
&lt;p&gt;Add the following code to your application:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;JavaScript&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-javascript&#34;&gt;const Pyroscope = require(&amp;#39;@pyroscope/nodejs&amp;#39;);

Pyroscope.init({
    serverAddress: &amp;#39;http://pyroscope:4040&amp;#39;,
    appName: &amp;#39;myNodeService&amp;#39;,
    // Enable CPU time collection for wall profiles
    // This is required for CPU profiling functionality
    // wall: {
    //   collectCpuTime: true
    // }
});

Pyroscope.start()&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;If you&amp;rsquo;d prefer, you can use Pull mode using 
    &lt;a href=&#34;/docs/pyroscope/v1.18.x/configure-client/grafana-alloy/go_pull/&#34;&gt;Grafana Alloy&lt;/a&gt;.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;h3 id=&#34;configuration-options&#34;&gt;Configuration options&lt;/h3&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Init parameter&lt;/th&gt;
              &lt;th&gt;ENVIRONMENT VARIABLE&lt;/th&gt;
              &lt;th&gt;Type&lt;/th&gt;
              &lt;th&gt;DESCRIPTION&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;appName:&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;PYROSCOPE_APPLICATION_NAME&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;String&lt;/td&gt;
              &lt;td&gt;Sets the &lt;code&gt;service_name&lt;/code&gt; label&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;serverAddress:&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;PYROSCOPE_SERVER_ADDRESS&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;String&lt;/td&gt;
              &lt;td&gt;URL of the Pyroscope Server&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;basicAuthUser:&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;n/a&lt;/td&gt;
              &lt;td&gt;String&lt;/td&gt;
              &lt;td&gt;Username for basic auth / Grafana Cloud stack user ID (Default &lt;code&gt;&amp;quot;&amp;quot;&lt;/code&gt;)&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;basicAuthPassword:&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;n/a&lt;/td&gt;
              &lt;td&gt;String&lt;/td&gt;
              &lt;td&gt;Password for basic auth / Grafana Cloud API key (Default &lt;code&gt;&amp;quot;&amp;quot;&lt;/code&gt;)&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;flushIntervalMs:&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;PYROSCOPE_FLUSH_INTERVAL_MS&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Number&lt;/td&gt;
              &lt;td&gt;Interval when profiles are sent to the server (Default &lt;code&gt;60000&lt;/code&gt;)&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;heapSamplingIntervalBytes&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;PYROSCOPE_HEAP_SAMPLING_INTERVAL_BYTES&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Number&lt;/td&gt;
              &lt;td&gt;Average number of bytes between samples. (Default &lt;code&gt;524288&lt;/code&gt;)&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;heapStackDepth:&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;PYROSCOPE_HEAP_STACK_DEPTH&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Number&lt;/td&gt;
              &lt;td&gt;Maximum stack depth for heap samples (Default &lt;code&gt;64&lt;/code&gt;)&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;wall.SamplingDurationMs:&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;PYROSCOPE_WALL_SAMPLING_DURATION_MS&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Number&lt;/td&gt;
              &lt;td&gt;Duration of a single wall profile (Default &lt;code&gt;60000&lt;/code&gt;)&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;wall.SamplingIntervalMicros:&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;PYROSCOPE_WALL_SAMPLING_INTERVAL_MICROS&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Number&lt;/td&gt;
              &lt;td&gt;Interval of how often wall samples are collected (Default &lt;code&gt;10000&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;wall.CollectCpuTime:&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;PYROSCOPE_WALL_COLLECT_CPU_TIME&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Boolean&lt;/td&gt;
              &lt;td&gt;Required for CPU profiling. Enable CPU time collection as part of the wall profiler (Default &lt;code&gt;false&lt;/code&gt;)&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;tags:&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;n/a&lt;/td&gt;
              &lt;td&gt;&lt;a href=&#34;https://github.com/DataDog/pprof-nodejs/blob/v5.3.0/ts/src/v8-types.ts#L59-L61&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;LabelSet&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;Static labels applying to all profiles collected (Default &lt;code&gt;{}&lt;/code&gt;)&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;sourceMapper:&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;n/a&lt;/td&gt;
              &lt;td&gt;&lt;a href=&#34;https://github.com/DataDog/pprof-nodejs/blob/v5.3.0/ts/src/sourcemapper/sourcemapper.ts#L152&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;SourceMapper&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;Provide source file mapping information (Default &lt;code&gt;undefined&lt;/code&gt;)&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;add-profiling-labels-to-nodejs-applications&#34;&gt;Add profiling labels to Node.js applications&lt;/h3&gt;
&lt;h4 id=&#34;static-labels&#34;&gt;Static labels&lt;/h4&gt;
&lt;p&gt;You can add static labels to the profiling data.
These labels can be used to filter the data in the UI and apply for all profiles collected.
Common static labels include:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;hostname&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;region&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;team&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;JavaScript&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-javascript&#34;&gt;Pyroscope.init({
  serverAddress: &amp;#39;http://pyroscope:4040&amp;#39;,
  appName: &amp;#39;myNodeService&amp;#39;,
  tags: {
    region: ENV[&amp;#39;region&amp;#39;]
  },
});

Pyroscope.start()&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h4 id=&#34;dynamic-labels-for-wallcpu-profiles&#34;&gt;Dynamic labels for Wall/CPU profiles&lt;/h4&gt;
&lt;p&gt;In Wall and CPU profiles, labels can also be attached dynamically and help to separate different code paths:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;JavaScript&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-javascript&#34;&gt;Pyroscope.wrapWithLabels({ vehicle: &amp;#39;bike&amp;#39; }, () =&amp;gt;
  slowCode()
);&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;send-data-to-pyroscope-oss-or-grafana-cloud&#34;&gt;Send data to Pyroscope OSS or Grafana Cloud&lt;/h2&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;JavaScript&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-javascript&#34;&gt;Pyroscope.init({
  serverAddress: &amp;#39;http://pyroscope:4040&amp;#39;,
  appName: &amp;#39;myNodeService&amp;#39;,
  tags: {
    region: ENV[&amp;#39;region&amp;#39;]
  },
  basicAuthUser: ENV[&amp;#39;PYROSCOPE_BASIC_AUTH_USER&amp;#39;],
  basicAuthPassword: ENV[&amp;#39;PYROSCOPE_BASIC_AUTH_PASSWORD&amp;#39;],
  // Optional Pyroscope tenant ID (only needed if using multi-tenancy). Not needed for Grafana Cloud.
  // tenantID: ENV[&amp;#39;PYROSCOPE_TENANT_ID&amp;#39;],
});

Pyroscope.start()&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;To configure the Node.js SDK to send data to Pyroscope, replace the &lt;code&gt;serverAddress&lt;/code&gt; placeholder with the appropriate server URL. This could be the Grafana Cloud Pyroscope URL or your own custom Pyroscope server URL.&lt;/p&gt;
&lt;p&gt;If you need to send data to Grafana Cloud, you’ll have to configure HTTP Basic authentication. Replace &lt;code&gt;basicAuthUser&lt;/code&gt; with your Grafana Cloud stack user ID and &lt;code&gt;basicAuthPassword&lt;/code&gt; with your Grafana Cloud API key.&lt;/p&gt;
&lt;p&gt;If your Pyroscope server has multi-tenancy enabled, you’ll need to configure a tenant ID. Replace &lt;code&gt;tenantID&lt;/code&gt; with your Pyroscope tenant ID.&lt;/p&gt;
&lt;h3 id=&#34;locate-the-url-user-and-password-in-grafana-cloud-profiles&#34;&gt;Locate the URL, user, and password in Grafana Cloud Profiles&lt;/h3&gt;


&lt;div data-shared=&#34;locate-url-pw-user-cloud-profiles.md&#34;&gt;
            &lt;!-- Locate your stack&#39;s URL, user, and password --&gt;
&lt;p&gt;When you configure Alloy or your SDK, you need to provide the URL, user, and password for your Grafana Cloud stack.
This information is located in the &lt;strong&gt;Pyroscope&lt;/strong&gt; section of your Grafana Cloud stack.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Navigate to your Grafana Cloud stack.&lt;/li&gt;
&lt;li&gt;Select &lt;strong&gt;Details&lt;/strong&gt; next to your stack.&lt;/li&gt;
&lt;li&gt;Locate the &lt;strong&gt;Pyroscope&lt;/strong&gt; section and select &lt;strong&gt;Details&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Copy the &lt;strong&gt;URL&lt;/strong&gt;, &lt;strong&gt;User&lt;/strong&gt;, and &lt;strong&gt;Password&lt;/strong&gt; values in the &lt;strong&gt;Configure the client and data source using Grafana credentials&lt;/strong&gt; section.
&lt;img
  class=&#34;lazyload d-inline-block&#34;
  data-src=&#34;/media/docs/pyroscope/cloud-profiles-url-user-password.png&#34;
  alt=&#34;Locate the SDK or Grafana Alloy configuration values&#34; width=&#34;1029&#34;
     height=&#34;725&#34;/&gt;&lt;/li&gt;
&lt;li&gt;Use these values to complete the configuration.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;As an alternative, you can also create a Cloud Access Policy and generate a token to use instead of the user and password.
For more information, refer to &lt;a href=&#34;/docs/grafana-cloud/security-and-account-management/authentication-and-permissions/access-policies/create-access-policies/&#34;&gt;Create a Cloud Access Policy&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;

        
&lt;h2 id=&#34;troubleshoot&#34;&gt;Troubleshoot&lt;/h2&gt;
&lt;p&gt;Setting &lt;code&gt;DEBUG&lt;/code&gt; env to &lt;code&gt;pyroscope&lt;/code&gt; provides additional debugging information.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;DEBUG=pyroscope node index.js&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
]]></content><description>&lt;h1 id="nodejs">Node.js&lt;/h1>
&lt;p>Enhance your Node.js application&amp;rsquo;s performance with our Node.js Profiler. Seamlessly integrated with Pyroscope, it provides real-time insights into your application’s operation, helping you identify and resolve performance bottlenecks. This integration is key for Node.js developers aiming to boost efficiency, reduce latency, and maintain optimal application performance.&lt;/p></description></item></channel></rss>