# Support for custom DiagnosticSource in APM .NET Agent

**URL:** <https://discuss.elastic.co/t/support-for-custom-diagnosticsource-in-apm-net-agent/180834>\
**Category:** APM\
**Tags:** dotnet\
**Created:** [May 13, 2019, 2:47pm UTC](https://discuss.elastic.co/t/support-for-custom-diagnosticsource-in-apm-net-agent/180834 "2019-05-13T14:47:03Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![oleh-zheleznyak](https://avatars.discourse-cdn.com/v4/letter/o/db5fbb/32.png) [@oleh-zheleznyak](https://discuss.elastic.co/u/oleh-zheleznyak)\
**Post date:** [May 13, 2019, 2:47pm UTC](https://discuss.elastic.co/t/support-for-custom-diagnosticsource-in-apm-net-agent/180834/1 "2019-05-13T14:47:03Z")

</div>

Hi All,

Currently apm-agent-dotnet only supports pre-defined DiagnosticSources: HttpDiagnosticListener, AspNetCoreDiagnosticListener and EfCoreDiagnosticListener.

If I want more trace ability, i need to revert to "manual" api, and wrap code in Transactions and Spans.

I would like to take a standard approach in .NET and use custom DiagnosticSource and Activity classes.

It would be great if apm-agent-dotnet could provide a hook and translate some of the Activities to Spans automatically for me.

Is this a viable idea? Could this work? Any plans for that in the future?

For example, diagnostics-eventflow does a similar thing, but it writes directly to ElasticSearch, not APM Server

OpenTracing project also does a similar thing, see GenericDiagnostics

> <https://github.com/opentracing-contrib/csharp-netcore/blob/master/src/OpenTracing.Contrib.NetCore/CoreFx/GenericDiagnostics.cs>

Thanks a lot for your feedback!

---

<div class="post-metadata">

**Author:** ![GregKalapos](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gregkalapos/32/37205_2.png) [@GregKalapos](https://discuss.elastic.co/u/GregKalapos)\
**Post date:** [May 15, 2019, 11:21am UTC](https://discuss.elastic.co/t/support-for-custom-diagnosticsource-in-apm-net-agent/180834/2 "2019-05-15T11:21:43Z")

</div>

Hi @oleh-zheleznyak,

this is very interesting idea; and also thanks for pointing out the other solutions!

We already talked about having something like this within the team.

I moved this to a [github issue](https://github.com/elastic/apm-agent-dotnet/issues/229). I think this would make sense and it could work, but I must say that I haven't spent enough time on this to think through every detail of it.

We will come up with a more detailed plan about this on GitHub, free to add more comments there, too.

---

<div class="post-metadata">

**Author:** ![oleh-zheleznyak](https://avatars.discourse-cdn.com/v4/letter/o/db5fbb/32.png) [@oleh-zheleznyak](https://discuss.elastic.co/u/oleh-zheleznyak)\
**Post date:** [May 15, 2019, 11:45am UTC](https://discuss.elastic.co/t/support-for-custom-diagnosticsource-in-apm-net-agent/180834/3 "2019-05-15T11:45:36Z")

</div>

Hi @GregKalapos, thanks for your reply! Looking forward!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [June 5, 2019, 7:47am UTC](https://discuss.elastic.co/t/support-for-custom-diagnosticsource-in-apm-net-agent/180834/4 "2019-06-05T07:47:24Z")

</div>

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.
