OpenTelemetry.Instrumentation.Wcf 1.13.0-beta.1

Prefix Reserved
This is a prerelease version of OpenTelemetry.Instrumentation.Wcf.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package OpenTelemetry.Instrumentation.Wcf --version 1.13.0-beta.1
                    
NuGet\Install-Package OpenTelemetry.Instrumentation.Wcf -Version 1.13.0-beta.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.Wcf" Version="1.13.0-beta.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="OpenTelemetry.Instrumentation.Wcf" Version="1.13.0-beta.1" />
                    
Directory.Packages.props
<PackageReference Include="OpenTelemetry.Instrumentation.Wcf" />
                    
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.Wcf --version 1.13.0-beta.1
                    
#r "nuget: OpenTelemetry.Instrumentation.Wcf, 1.13.0-beta.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.Wcf@1.13.0-beta.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.Wcf&version=1.13.0-beta.1&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=OpenTelemetry.Instrumentation.Wcf&version=1.13.0-beta.1&prerelease
                    
Install as a Cake Tool

WCF Instrumentation for OpenTelemetry .NET

Status
Stability Beta
Code Owners @open-telemetry/dotnet-contrib-maintainers

NuGet version badge NuGet download count badge codecov.io

Instruments WCF clients and/or services.

The following configurations are verified to work with this instrumentation. Other configurations may work as well but have not been tested.

  • SOAP and JSON payloads on HTTP/HTTPS transport
  • SOAP payloads on Net.TCP transport
    • Encrypted and unencrypted transports
    • Streamed and buffered transfer modes
    • Signed and unsigned messages

This component is based on the OpenTelemetry semantic conventions for traces. These conventions are in Development, and hence, this package is a pre-release. Until a stable version is released, there can be breaking changes.

Installation

Add the OpenTelemetry.Instrumentation.Wcf package via NuGet.

OpenTelemetry Configuration

Use the AddWcfInstrumentation extension method to add WCF instrumentation to an OpenTelemetry TracerProvider:

using var openTelemetry = Sdk.CreateTracerProviderBuilder()
    .AddWcfInstrumentation()
    .Build();

Instrumentation can be configured via options overload for AddWcfInstrumentation method:

using var openTelemetry = Sdk.CreateTracerProviderBuilder()
    .AddWcfInstrumentation(options =>
    {
        options.SuppressDownstreamInstrumentation = false;

        // Enable enriching an activity after it is created.
        options.Enrich = (activity, eventName,  message) =>
        {
            var wcfMessage = message as Message;

            // For event names, please refer to string constants in
            // WcfEnrichEventNames class.
            if (eventName == WcfEnrichEventNames.AfterReceiveReply)
            {
                activity.SetTag(
                    "companyname.messagetag",
                    wcfMessage.Properties["CustomProperty"]);
            }
        };
    })
    .Build();

WCF Client Configuration (.NET Framework)

Configure the TelemetryEndpointBehaviorExtensionElement on the clients you want to instrument:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.serviceModel>
    <extensions>
      <behaviorExtensions>
        <add name="telemetryExtension" type="OpenTelemetry.Instrumentation.Wcf.TelemetryEndpointBehaviorExtensionElement, OpenTelemetry.Instrumentation.Wcf"   />
      </behaviorExtensions>
    </extensions>
    <behaviors>
      <endpointBehaviors>
        <behavior name="telemetry">
          <telemetryExtension />
        </behavior>
      </endpointBehaviors>
    </behaviors>
    <bindings>
      <netTcpBinding>
        <binding name="netTCPConfig">
          <security mode="None" />
        </binding>
      </netTcpBinding>
    </bindings>
    <client>
      <endpoint address="net.tcp://localhost:9090/Telemetry" binding="netTcpBinding" bindingConfiguration="netTCPConfig" behaviorConfiguration="telemetry" contract="Examples.Wcf.IStatusServiceContract" name="StatusService_Tcp" />
    </client>
  </system.serviceModel>
</configuration>

Example project available in examples/wcf/client-netframework folder.

WCF Client Configuration (.NET Core)

Add the TelemetryEndpointBehavior extension to the clients you want to instrument:

StatusServiceClient client = new StatusServiceClient(binding, remoteAddress);
client.Endpoint.EndpointBehaviors.Add(new TelemetryEndpointBehavior());

Example project available in examples/wcf/client-core folder.

WCF Server Configuration (.NET Framework)

Option 1: Instrument by endpoint

To add the IDispatchMessageInspector instrumentation to select endpoints of a service, use the endpoint behavior extension on the service endpoints you want to instrument:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.serviceModel>
    <extensions>
      <behaviorExtensions>
        <add name="telemetryExtension" type="OpenTelemetry.Instrumentation.Wcf.TelemetryEndpointBehaviorExtensionElement, OpenTelemetry.Instrumentation.Wcf" />
      </behaviorExtensions>
    </extensions>
    <behaviors>
      <endpointBehaviors>
        <behavior name="telemetry">
          <telemetryExtension />
        </behavior>
      </endpointBehaviors>
    </behaviors>
    <bindings>
      <netTcpBinding>
        <binding name="netTCPConfig">
          <security mode="None" />
        </binding>
      </netTcpBinding>
    </bindings>
    <services>
      <service name="Examples.Wcf.Server.StatusService">
        <endpoint binding="netTcpBinding" bindingConfiguration="netTCPConfig" behaviorConfiguration="telemetry" contract="Examples.Wcf.IStatusServiceContract" />
        <host>
          <baseAddresses>
            <add baseAddress="net.tcp://localhost:9090/Telemetry" />
          </baseAddresses>
        </host>
      </service>
    </services>
  </system.serviceModel>
</configuration>

Example project available in examples/wcf/server-netframework folder.

Option 2: Instrument by service

To add the IDispatchMessageInspector instrumentation for all endpoints of a service, use the service behavior extension on the services you want to instrument:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.serviceModel>
    <extensions>
      <behaviorExtensions>
        <add name="telemetryExtension" type="OpenTelemetry.Instrumentation.Wcf.TelemetryServiceBehaviorExtensionElement, OpenTelemetry.Instrumentation.Wcf" />
      </behaviorExtensions>
    </extensions>
    <behaviors>
      <serviceBehaviors>
        <behavior name="telemetry">
          <telemetryExtension />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <bindings>
      <netTcpBinding>
        <binding name="netTCPConfig">
          <security mode="None" />
        </binding>
      </netTcpBinding>
    </bindings>
    <services>
      <service name="Examples.Wcf.Server.StatusService" behaviorConfiguration="telemetry">
        <endpoint binding="netTcpBinding" bindingConfiguration="netTCPConfig" contract="Examples.Wcf.IStatusServiceContract" />
        <host>
          <baseAddresses>
            <add baseAddress="net.tcp://localhost:9090/Telemetry" />
          </baseAddresses>
        </host>
      </service>
    </services>
  </system.serviceModel>
</configuration>

WCF Programmatic Configuration Server and/or Client (.NET Framework + .NET Core)

To programmatically add instrumentation for servers (.NET Framework only) and/or for clients (.NET Framework & .NET Core), use the TelemetryContractBehaviorAttribute on the service contracts you want to instrument:

    [ServiceContract(
        Namespace = "http://opentelemetry.io/",
        Name = "StatusService",
        SessionMode = SessionMode.Allowed)]
    [TelemetryContractBehavior]
    public interface IStatusServiceContract
    {
        [OperationContract]
        Task<StatusResponse> PingAsync(StatusRequest request);
    }

Advanced configuration

This instrumentation can be configured to change the default behavior by using WcfInstrumentationOptions.

RecordException

This instrumentation automatically sets Activity Status to Error if an unhandled exception is thrown. Additionally, RecordException feature may be turned on, to store the exception to the Activity itself as ActivityEvent. This feature applies both on instrumented servers and clients.

References

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 is compatible.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (7)

Showing the top 5 NuGet packages that depend on OpenTelemetry.Instrumentation.Wcf:

Package Downloads
OpenTelemetry.AutoInstrumentation.Runtime.Managed

Managed components used by the OpenTelemetry.AutoInstrumentation project.

Grafana.OpenTelemetry

Full Grafana distribution of OpenTelemetry .NET

Honeycomb.OpenTelemetry.CommonInstrumentations

Honeycomb's OpenTelemetry common instrumentations package. Adds support for many common instrumentation libraries for you.

Honeycomb.OpenTelemetry.AutoInstrumentations

Honeycomb's OpenTelemetry autoinstrumentations package. Adds support for many common instrumentation libraries for you.

Highlight.ASP4

Session replay, error monitoring, logging, and tracing: stop guessing why bugs happen!

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.13.0-beta.2 4,098 10/20/2025
1.13.0-beta.1 1,391 10/15/2025
1.12.0-beta.1 732,741 5/6/2025
1.11.0-beta.2 572,614 3/5/2025
1.11.0-beta.1 151,863 1/27/2025
1.10.0-beta.1 22,042 12/9/2024
1.0.0-rc.18 686,474 10/28/2024
1.0.0-rc.17 1,700,441 6/18/2024
1.0.0-rc.16 546,693 4/5/2024
1.0.0-rc.15 173,875 2/7/2024
1.0.0-rc.14 264,019 1/4/2024
1.0.0-rc.13 563,688 10/27/2023
1.0.0-rc.12 279,495 8/30/2023
1.0.0-rc.11 1,322 8/14/2023
1.0.0-rc.10 94,810 6/9/2023
1.0.0-rc.9 437,717 2/28/2023
1.0.0-rc.8 24,765 12/28/2022
1.0.0-rc.7 62,238 8/23/2022
1.0.0-rc.6 95,662 3/17/2022