From 6cce0d7fde548b9657f6ec28ad56e334b3e58694 Mon Sep 17 00:00:00 2001 From: Attila Szegedi Date: Tue, 14 Apr 2026 13:22:07 +0200 Subject: [PATCH 1/4] Document custom labels for Node.js --- ...isolate-outliers-in-monolithic-services.md | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/content/en/profiler/guide/isolate-outliers-in-monolithic-services.md b/content/en/profiler/guide/isolate-outliers-in-monolithic-services.md index 260ebee2a92..c3c161ba68c 100644 --- a/content/en/profiler/guide/isolate-outliers-in-monolithic-services.md +++ b/content/en/profiler/guide/isolate-outliers-in-monolithic-services.md @@ -78,7 +78,7 @@ In the previous image, notice that the `ModelTraining` operation is taking more Endpoint and operation isolation is available in your profiles by default, but you may want to isolate a different piece of logic. For example, if the monolith is sensitive to specific customers, you can add a custom filter to the profiles: -{{< programming-lang-wrapper langs="java,go" >}} +{{< programming-lang-wrapper langs="java,go,nodejs" >}} {{< programming-lang lang="java">}} @@ -124,6 +124,31 @@ Then, open CPU or goroutine profiles for your service and select the `customer_n [1]: https://pkg.go.dev/runtime/pprof#Do [2]: https://pkg.go.dev/gopkg.in/DataDog/dd-trace-go.v1/profiler#WithCustomProfilerLabelKeys [3]: https://pkg.go.dev/github.com/DataDog/dd-trace-go/v2/profiler#WithCustomProfilerLabelKeys +{{< /programming-lang >}} +{{< programming-lang lang="nodejs">}} + +The Node.js profiler supports custom labels for your business logic as of `dd-trace` version 5.97.0 on Node.js 24 or later. + +To add labels, use `tracer.profiling.runWithLabels()`: + +```javascript +const tracer = require('dd-trace').init() + +tracer.profiling.runWithLabels({ customer_name: }, () => { + /* customer-specific logic here */ +}) +``` + +All wall time and CPU time samples taken during the function's execution, including across async continuations, carry the custom labels. Nested `runWithLabels` calls merge labels, with inner values taking precedence for duplicate keys. + +To specify which label keys you want to use for filtering, call `setCustomLabelKeys()` as a one-time setup before calling `runWithLabels()`: + +```javascript +tracer.profiling.setCustomLabelKeys(['customer_name']) +``` + +Then, open wall time profiles for your service and select the `customer_name` value you're interested in under the `CPU time by` dropdown. + {{< /programming-lang >}} {{< /programming-lang-wrapper >}} From 8e64476e77c91bcb584431c479088f7c55ee4318 Mon Sep 17 00:00:00 2001 From: Attila Szegedi Date: Thu, 16 Apr 2026 14:24:23 +0200 Subject: [PATCH 2/4] Apply suggestions from code review Co-authored-by: domalessi <111786334+domalessi@users.noreply.github.com> --- .../guide/isolate-outliers-in-monolithic-services.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/content/en/profiler/guide/isolate-outliers-in-monolithic-services.md b/content/en/profiler/guide/isolate-outliers-in-monolithic-services.md index c3c161ba68c..6818756284e 100644 --- a/content/en/profiler/guide/isolate-outliers-in-monolithic-services.md +++ b/content/en/profiler/guide/isolate-outliers-in-monolithic-services.md @@ -139,15 +139,15 @@ tracer.profiling.runWithLabels({ customer_name: }, () => { }) ``` -All wall time and CPU time samples taken during the function's execution, including across async continuations, carry the custom labels. Nested `runWithLabels` calls merge labels, with inner values taking precedence for duplicate keys. +All wall time and CPU time samples taken during the function's execution, including across async continuations, carry the custom labels. Nested `runWithLabels` calls merge labels. Inner values taking precedence for duplicate keys. -To specify which label keys you want to use for filtering, call `setCustomLabelKeys()` as a one-time setup before calling `runWithLabels()`: +To specify which label keys you want to use for filtering, call `setCustomLabelKeys()` once before calling `runWithLabels()`: ```javascript tracer.profiling.setCustomLabelKeys(['customer_name']) ``` -Then, open wall time profiles for your service and select the `customer_name` value you're interested in under the `CPU time by` dropdown. +Then, open wall time or CPU time profiles for your service and select the `customer_name` value you're interested in under the `CPU time by` dropdown. {{< /programming-lang >}} {{< /programming-lang-wrapper >}} From 26eba1a1785a78ddaebaeb6552af61f9a6f951c7 Mon Sep 17 00:00:00 2001 From: Attila Szegedi Date: Thu, 16 Apr 2026 14:25:53 +0200 Subject: [PATCH 3/4] Small fix --- .../profiler/guide/isolate-outliers-in-monolithic-services.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/en/profiler/guide/isolate-outliers-in-monolithic-services.md b/content/en/profiler/guide/isolate-outliers-in-monolithic-services.md index 6818756284e..1a744f115c5 100644 --- a/content/en/profiler/guide/isolate-outliers-in-monolithic-services.md +++ b/content/en/profiler/guide/isolate-outliers-in-monolithic-services.md @@ -139,7 +139,7 @@ tracer.profiling.runWithLabels({ customer_name: }, () => { }) ``` -All wall time and CPU time samples taken during the function's execution, including across async continuations, carry the custom labels. Nested `runWithLabels` calls merge labels. Inner values taking precedence for duplicate keys. +All wall time and CPU time samples taken during the function's execution, including across async continuations, carry the custom labels. Nested `runWithLabels` calls merge labels. Inner values take precedence for duplicate keys. To specify which label keys you want to use for filtering, call `setCustomLabelKeys()` once before calling `runWithLabels()`: From d7b124bf412f89fe6f4bb05973d2729fa4f5c9b1 Mon Sep 17 00:00:00 2001 From: domalessi <111786334+domalessi@users.noreply.github.com> Date: Thu, 16 Apr 2026 14:28:53 -0400 Subject: [PATCH 4/4] Apply suggestions from code review Co-authored-by: domalessi <111786334+domalessi@users.noreply.github.com> --- .../profiler/guide/isolate-outliers-in-monolithic-services.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/en/profiler/guide/isolate-outliers-in-monolithic-services.md b/content/en/profiler/guide/isolate-outliers-in-monolithic-services.md index 1a744f115c5..343d849a3ec 100644 --- a/content/en/profiler/guide/isolate-outliers-in-monolithic-services.md +++ b/content/en/profiler/guide/isolate-outliers-in-monolithic-services.md @@ -141,7 +141,7 @@ tracer.profiling.runWithLabels({ customer_name: }, () => { All wall time and CPU time samples taken during the function's execution, including across async continuations, carry the custom labels. Nested `runWithLabels` calls merge labels. Inner values take precedence for duplicate keys. -To specify which label keys you want to use for filtering, call `setCustomLabelKeys()` once before calling `runWithLabels()`: +To specify which label keys you want to use for filtering, call `setCustomLabelKeys()` one time before calling `runWithLabels()`: ```javascript tracer.profiling.setCustomLabelKeys(['customer_name'])