Confluent.Kafka.Extensions.Diagnostics 0.4.0

dotnet add package Confluent.Kafka.Extensions.Diagnostics --version 0.4.0
NuGet\Install-Package Confluent.Kafka.Extensions.Diagnostics -Version 0.4.0
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.4.0" />
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.4.0
#r "nuget: Confluent.Kafka.Extensions.Diagnostics, 0.4.0"
#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.4.0

// Install Confluent.Kafka.Extensions.Diagnostics as a Cake Tool
#tool nuget:?package=Confluent.Kafka.Extensions.Diagnostics&version=0.4.0

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.4.0 62,214 7/27/2023
0.3.1-alpha.5 89 7/27/2023
0.3.1-alpha.4 173 5/29/2023
0.3.1-alpha.3 78 5/29/2023
0.3.1-alpha.2 72 5/29/2023
0.3.1-alpha.1 74 5/29/2023
0.3.0 36,211 3/14/2023
0.2.3-alpha.5 85 3/14/2023
0.2.3-alpha.1 104 11/8/2022
0.2.2 100,170 8/8/2022
0.2.2-alpha.1 97 8/8/2022
0.2.1 363 8/8/2022
0.2.0 368 8/7/2022
0.1.0 372 8/5/2022