OpenTelemetry.Instrumentation.Remoting 0.1.0-alpha.1

Prefix Reserved
This is a prerelease version of OpenTelemetry.Instrumentation.Remoting.
dotnet add package OpenTelemetry.Instrumentation.Remoting --version 0.1.0-alpha.1
                    
NuGet\Install-Package OpenTelemetry.Instrumentation.Remoting -Version 0.1.0-alpha.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="OpenTelemetry.Instrumentation.Remoting" Version="0.1.0-alpha.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="OpenTelemetry.Instrumentation.Remoting" Version="0.1.0-alpha.1" />
                    
Directory.Packages.props
<PackageReference Include="OpenTelemetry.Instrumentation.Remoting" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add OpenTelemetry.Instrumentation.Remoting --version 0.1.0-alpha.1
                    
#r "nuget: OpenTelemetry.Instrumentation.Remoting, 0.1.0-alpha.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package OpenTelemetry.Instrumentation.Remoting@0.1.0-alpha.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=OpenTelemetry.Instrumentation.Remoting&version=0.1.0-alpha.1&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=OpenTelemetry.Instrumentation.Remoting&version=0.1.0-alpha.1&prerelease
                    
Install as a Cake Tool

.NET Remoting Instrumentation for OpenTelemetry .NET

Status
Stability Alpha
Code Owners @lewis800

NuGet version badge NuGet download count badge codecov.io

This is an Instrumentation Library, which instruments .NET Remoting and collects telemetry about incoming and outgoing requests on client and server objects.

.NET Remoting is a legacy technology that shouldn't be used for new .NET applications and doesn't exist in .NET 6 and later versions. However, if you do have a legacy application you are looking to instrument, consider using this package.

Installation

Add a reference to the OpenTelemetry.Instrumentation.Remoting package. Also, add any other instrumentations & exporters you will need.

dotnet add package --prerelease OpenTelemetry.Instrumentation.Remoting

Configuration

To enable .NET remoting instrumentation, call AddRemotingInstrumentation() on the TracerProviderBuilder during the application startup in both client and server code.

The following example demonstrates adding .NET Framework remoting instrumentation to a client console application. This example also sets up the OpenTelemetry Console exporter, which requires adding the OpenTelemetry.Exporter.Console package to the project.

using OpenTelemetry;
using OpenTelemetry.Trace;

namespace ExampleClient
{
    class Program
    {
        static void Main(string[] args)
        {
            using var tracerProvider = Sdk.CreateTracerProviderBuilder()
                .AddRemotingInstrumentation()
                .AddConsoleExporter()
                .Build();
        }
    }
}

When hosting server objects in IIS, adding instrumentation should typically be done in Global.asax.cs like in the below example.

This example also sets up the OpenTelemetry OTLP exporter, which requires adding the package OpenTelemetry.Exporter.OpenTelemetryProtocol to the project.

using System;
using OpenTelemetry;
using OpenTelemetry.Trace;

namespace ServerAspNet
{
    public class Global : System.Web.HttpApplication
    {
        private IDisposable _tracerProvider;

        protected void Application_Start(object sender, EventArgs e)
        {
            _tracerProvider = Sdk.CreateTracerProviderBuilder()
                .AddRemotingInstrumentation()
                .AddOtlpExporter(o =>
                {
                    o.Endpoint = new Uri("http://localhost:4317");
                })
                .Build();
        }

        // ...

        protected void Application_End(object sender, EventArgs e)
        {
            _tracerProvider?.Dispose();
        }
    }
}

Additionally, when using HttpChannel for remoting, consider registering OpenTelemetry.Instrumentation.Http on the client and OpenTelemetry.Instrumentation.AspNet on the server.

Filtering

By default AddRemotingInstrumentation will capture all calls leaving or entering current AppDomain. If you are only interested in calls on specific remote objects, you can use a Filter like below:

var tracerProvider = Sdk.CreateTracerProviderBuilder()
    .AddRemotingInstrumentation(options =>
        options.Filter = message =>
        {
            // Only capture calls to and from "RemoteObject"
            if (message is IMethodMessage methodMessage)
            {
                return methodMessage.TypeName.Contains("RemoteObject");
            }

            return false;
        })
    .Build()

The Filter takes an IMessage and returns a boolean. You can inspect the message to decide if you want to instrument it or not.

Implementation Details

The instrumentation is implemented via custom IDynamicMessageSink implementation, that is registered in the current AppDomain when you call AddRemotingInstrumentation and unregistered when the constructed TracerProvider is disposed.

References

Product Compatible and additional computed target framework versions.
.NET Framework net462 is compatible.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.0-alpha.1 57 6/1/2026