# How to Instrument Custom Methods in .NET with Elastic APM (Like New Relic XML Configuration)

**URL:** <https://discuss.elastic.co/t/how-to-instrument-custom-methods-in-net-with-elastic-apm-like-new-relic-xml-configuration/374879>\
**Category:** APM\
**Tags:** elastic-stack-monitoring, dotnet, open-telemetry\
**Created:** [February 22, 2025, 11:03am UTC](https://discuss.elastic.co/t/how-to-instrument-custom-methods-in-net-with-elastic-apm-like-new-relic-xml-configuration/374879 "2025-02-22T11:03:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mehedy\_Hasan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mehedy_hasan/32/80565_2.png) [@Mehedy\_Hasan](https://discuss.elastic.co/u/Mehedy_Hasan)\
**Post date:** [February 22, 2025, 11:03am UTC](https://discuss.elastic.co/t/how-to-instrument-custom-methods-in-net-with-elastic-apm-like-new-relic-xml-configuration/374879/1 "2025-02-22T11:03:58Z")

</div>

Hi everyone,

We are migrating to Elastic APM and trying to achieve custom **method instrumentation** for our **.NET** application. In **New Relic** , we used **XML configuration** to declare specific methods for instrumentation (as described ([https://docs.newrelic.com/docs/apm/agents/net-agent/custom-instrumentation/add-detail-transactions-xml-net/](https://docs.newrelic.com/docs/apm/agents/net-agent/custom-instrumentation/add-detail-transactions-xml-net/))).

We followed the Elastic APM .NET agent auto-instrumentation guide ([Profiler Auto instrumentation | APM .NET Agent Reference [1.x] | Elastic](https://www.elastic.co/guide/en/apm/agent/dotnet/current/setup-auto-instrumentation.html))), but the results only show **HTTP requests, database queries, and Redis calls** — our custom code methods don’t appear in the traces.

Is there a way to manually configure or declare custom methods for instrumentation that are similar to **New Relic’s XML** approach? Or is there an alternative solution to achieve this with Elastic APM without changing my existing code?

We’d really appreciate any guidance or best practices to get this working!

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![stevejgordon](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stevejgordon/32/80912_2.png) [@stevejgordon](https://discuss.elastic.co/u/stevejgordon)\
**Post date:** [February 25, 2025, 12:04pm UTC](https://discuss.elastic.co/t/how-to-instrument-custom-methods-in-net-with-elastic-apm-like-new-relic-xml-configuration/374879/2 "2025-02-25T12:04:23Z")

</div>

@Mehedy_Hasan APM Agent does not support external configuration of auto-instrumentation. You will need to switch to the NuGet-based installation and manual code instrumentation.
