Confluent.Kafka.Extensions.Diagnostics 0.3.1-alpha.5

This is a prerelease version of Confluent.Kafka.Extensions.Diagnostics.
There is a newer version of this package available.
See the version list below for details.
dotnet add package Confluent.Kafka.Extensions.Diagnostics --version 0.3.1-alpha.5                
NuGet\Install-Package Confluent.Kafka.Extensions.Diagnostics -Version 0.3.1-alpha.5                
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="Confluent.Kafka.Extensions.Diagnostics" Version="0.3.1-alpha.5" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Confluent.Kafka.Extensions.Diagnostics --version 0.3.1-alpha.5                
#r "nuget: Confluent.Kafka.Extensions.Diagnostics, 0.3.1-alpha.5"                
#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.
// Install Confluent.Kafka.Extensions.Diagnostics as a Cake Addin
#addin nuget:?package=Confluent.Kafka.Extensions.Diagnostics&version=0.3.1-alpha.5&prerelease

// Install Confluent.Kafka.Extensions.Diagnostics as a Cake Tool
#tool nuget:?package=Confluent.Kafka.Extensions.Diagnostics&version=0.3.1-alpha.5&prerelease                

Confluent.Kafka.Extensions.Diagnostics

GitHub Actions Badge NuGet Badge

The Confluent.Kafka.Extensions.Diagnostics package enables instrumentation of the Confluent.Kafka library via Activity API.

Installation

Install-Package Confluent.Kafka.Extensions.Diagnostics

Usage

Producer

Producer instrumentation is done via wrapper class and, for this reason, the producer usage is not needed to be rewritten. However, to enable producer instrumentation, BuildWithInstrumentation method should be called on the producer builder instead of Build. After that, all produce calls (sync and async) will be instrumented.

using Confluent.Kafka;
using Confluent.Kafka.Extensions.Diagnostics;


using var producer =
    new ProducerBuilder<Null, string>(new ProducerConfig(new ClientConfig { BootstrapServers = "localhost:9092" }))
        .SetKeySerializer(Serializers.Null)
        .SetValueSerializer(Serializers.Utf8)
        .BuildWithInstrumentation();

await producer.ProduceAsync("topic", new Message<Null, string> { Value = "Hello World!" });

Consumer

Unfortunately, consumer interface of Confluent.Kafka library is not very flexible. Therefore, the instrumentation is implemented via an extension method on the consumer itself. For this reason, the consumer usage should be rewritten as follows:

using Confluent.Kafka;
using Confluent.Kafka.Extensions.Diagnostics;

using var consumer = new ConsumerBuilder<Ignore, string>(
        new ConsumerConfig(new ClientConfig { BootstrapServers = "localhost:9092" })
        {
            GroupId = "group", AutoOffsetReset = AutoOffsetReset.Earliest
        })
    .SetValueDeserializer(Deserializers.Utf8)
    .Build();

consumer.Subscribe("topic");

try
{
    while (true)
    {
        try
        {
            consumer.ConsumeWithInstrumentation((result) =>
            {
                Console.WriteLine(result.Message.Value);
            }, 2000);
        }
        catch (ConsumeException e)
        {
            Console.WriteLine($"Error occured: {e.Error.Reason}");
        }
    }
}
catch (OperationCanceledException)
{
    consumer.Close();
}
Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  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 was computed.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Confluent.Kafka.Extensions.Diagnostics:

Package Downloads
Confluent.Kafka.Extensions.OpenTelemetry

OpenTelemetry instrumentation for Confluent.Kafka

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.5.1-alpha.4 46 11/5/2024
0.5.1-alpha.3 38 11/5/2024
0.5.1-alpha.2 203 8/18/2024
0.5.1-alpha.1 81 8/18/2024
0.5.0 60,327 8/7/2024
0.4.0 264,300 7/27/2023
0.3.1-alpha.5 106 7/27/2023
0.3.1-alpha.4 189 5/29/2023
0.3.1-alpha.3 92 5/29/2023
0.3.1-alpha.2 87 5/29/2023
0.3.1-alpha.1 89 5/29/2023
0.3.0 45,291 3/14/2023
0.2.3-alpha.5 98 3/14/2023
0.2.3-alpha.1 118 11/8/2022
0.2.2 120,541 8/8/2022
0.2.2-alpha.1 111 8/8/2022
0.2.1 396 8/8/2022
0.2.0 398 8/7/2022
0.1.0 422 8/5/2022