OTel.Exporter.Elasticsearch.Http 2.0.0

Install-Package OTel.Exporter.Elasticsearch.Http -Version 2.0.0
dotnet add package OTel.Exporter.Elasticsearch.Http --version 2.0.0
<PackageReference Include="OTel.Exporter.Elasticsearch.Http" Version="2.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add OTel.Exporter.Elasticsearch.Http --version 2.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: OTel.Exporter.Elasticsearch.Http, 2.0.0"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install OTel.Exporter.Elasticsearch.Http as a Cake Addin
#addin nuget:?package=OTel.Exporter.Elasticsearch.Http&version=2.0.0

// Install OTel.Exporter.Elasticsearch.Http as a Cake Tool
#tool nuget:?package=OTel.Exporter.Elasticsearch.Http&version=2.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

opentelemetry-elk-exporter

Open Telemetry Exporter for Elasticsearch using http protocol.

How to use?

1. Install OTel.Exporter.Elasticsearch.Http package using Nuget Package Manager in .NET 5.0 above project
2. add Below code in programe.cs or startup.cs 

using var loggerFactory = LoggerFactory.Create(builder =>
    {
        builder.AddOpenTelemetry(options => options
            .AddElasticsearchExporter(new ElasticsearchExporterHttpOptions("telemetry", "http://localhost:9200"))
        );
    });

    "telemetry":  this is index name in Elasticsearch for which data will be pushed
    "http://localhost:9200": This is url of Elasticsearch server.

Example:
    internal class Program
      {
        private static ActivitySource activitySource = new ActivitySource("OTel.POC.Web", "ASP.NET Core 5.0");

        private static void Main(string[] args)
        {
          Activity.DefaultIdFormat = ActivityIdFormat.W3C;
          Activity.ForceDefaultIdFormat = true;
          using var loggerFactory = LoggerFactory.Create(builder =>
          {
            builder.AddOpenTelemetry(options => options
                .AddElasticsearchExporter(new ElasticsearchExporterHttpOptions("telemetry", "http://localhost:9200"))
                );
          });
          using (var activity = activitySource.StartActivity("ActivityName"))
          {
            var logger = loggerFactory.CreateLogger<Program>();
            logger.LogInformation("Hello from {name} {price}.", "tomato", 2.99);
            Stopwatch s = new Stopwatch();
            s.Start();
            Stopwatch s1 = new Stopwatch();
            long[] timekeeping = new long[1000];   
            for (int i = 0; i < 1000; i++)
            {

                        s1.Reset();
                        s1.Start();
                        logger.LogInformation($"Counting from {i} to 100");
                        s1.Stop();
                        timekeeping[i] = s1.ElapsedMilliseconds;
            }
            s.Stop();
            Console.WriteLine($"Time Elapsed - {s.ElapsedMilliseconds} ms");
            Console.WriteLine("Average time takemn:"+ timekeeping.Average()+" ms");
          }
          Console.ReadLine();
        }
      }

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
2.0.0 64 12/12/2021
1.0.0 128 10/31/2021

Upgraded to .NET 6, Added retry logic to push message to Elasticsearch