Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Removing sample files
  • Loading branch information
rajkumar-rangaraj committed Jun 17, 2020
commit 07cdafa008b75284bb4822527d5760887817d8f3
5 changes: 1 addition & 4 deletions samples/Exporters/Console/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public static void Main(string[] args)
Parser.Default.ParseArguments<JaegerOptions, ZipkinOptions, PrometheusOptions, HttpClientOptions, ZPagesOptions, ConsoleOptions, ConsoleActivityOptions, OtlpOptions>(args)
.MapResult(
(JaegerOptions options) => TestJaeger.Run(options.Host, options.Port, options.UseActivitySource),
(ZipkinOptions options) => TestZipkin.Run(options.Uri, true),
(ZipkinOptions options) => TestZipkin.Run(options.Uri),
(PrometheusOptions options) => TestPrometheus.RunAsync(options.Port, options.PushIntervalInSecs, options.DurationInMins),
(HttpClientOptions options) => TestHttpClient.Run(),
(RedisOptions options) => TestRedis.Run(options.Uri),
Expand Down Expand Up @@ -74,9 +74,6 @@ internal class ZipkinOptions
{
[Option('u', "uri", HelpText = "Please specify the uri of Zipkin backend", Required = true)]
public string Uri { get; set; }

[Option('a', "activity", HelpText = "Set it to true to export ActivitySource data", Default = false)]
public bool UseActivitySource { get; set; }
}

[Verb("prometheus", HelpText = "Specify the options required to test Prometheus")]
Expand Down
77 changes: 14 additions & 63 deletions samples/Exporters/Console/TestZipkin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Threading;
using OpenTelemetry.Trace;
using OpenTelemetry.Trace.Configuration;
Expand All @@ -25,73 +24,25 @@ namespace Samples
{
internal class TestZipkin
{
internal static object Run(string zipkinUri, bool useActivitySource)
internal static object Run(string zipkinUri)
{
if (useActivitySource)
{
// Enable OpenTelemetry for the sources "Samples.SampleServer" and "Samples.SampleClient"
// and use the Jaeger exporter.
using var openTelemetry = OpenTelemetrySdk.EnableOpenTelemetry(
builder => builder
// .AddActivitySource("MyCompany.MyProduct.MyWebServer")
.AddActivitySource("Samples.SampleServer")
.AddActivitySource("Samples.SampleClient")
.UseZipkinActivityExporter(o =>
{
o.ServiceName = "test-zipkin";
o.Endpoint = new Uri(zipkinUri);
}));

// The above lines are required only in Applications
// which decide to use OT.

using (var sample = new InstrumentationWithActivitySource())
{
sample.Start();

Console.WriteLine("Sample is running on the background, press ENTER to stop");
Console.ReadLine();
}

/*
var source = new ActivitySource("MyCompany.MyProduct.MyWebServer");
using (var parent = source.StartActivity("HttpIn", ActivityKind.Server))
// Configure exporter to export traces to Zipkin
using (var tracerFactory = TracerFactory.Create(builder => builder
.UseZipkin(o =>
{
parent?.AddTag("http.method", "GET");
parent?.AddTag("http.url", "https://localhost/wiki/Rabbit");
using (var child = source.StartActivity("HttpOut", ActivityKind.Client))
{
child?.AddTag("http.method", "GET");
child?.AddTag("http.url", "https://www.wikipedia.org/wiki/Rabbit");
// TODO: change status code to int after .NET added support for int
child?.AddTag("http.status_code", "200");
}

// TODO: change status code to int after .NET added support for int
parent?.AddTag("http.status_code", "200");
parent?.AddTag("http.host", "localhost");
}*/
}
else
o.ServiceName = "test-zipkin";
o.Endpoint = new Uri(zipkinUri);
})))
{
// Configure exporter to export traces to Zipkin
using (var tracerFactory = TracerFactory.Create(builder => builder
.UseZipkin(o =>
{
o.ServiceName = "test-zipkin";
o.Endpoint = new Uri(zipkinUri);
})))
{
var tracer = tracerFactory.GetTracer("zipkin-test");
var tracer = tracerFactory.GetTracer("zipkin-test");

// Create a scoped span. It will end automatically when using statement ends
using (tracer.WithSpan(tracer.StartSpan("Main")))
// Create a scoped span. It will end automatically when using statement ends
using (tracer.WithSpan(tracer.StartSpan("Main")))
{
Console.WriteLine("About to do a busy work");
for (var i = 0; i < 10; i++)
{
Console.WriteLine("About to do a busy work");
for (var i = 0; i < 10; i++)
{
DoWork(i, tracer);
}
DoWork(i, tracer);
}
}
}
Expand Down