Skip to content

Commit

Permalink
Added instructions to run console examples (#1525)
Browse files Browse the repository at this point in the history
  • Loading branch information
cijothomas authored Nov 12, 2020
1 parent 93f614b commit 4385164
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 14 deletions.
2 changes: 1 addition & 1 deletion examples/Console/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class Program
/// dotnet run -p Examples.Console.csproj zpages
///
/// The above must be run from the project root folder
/// (eg: C:\repos\opentelemetry-dotnet\src\examples\Console\).
/// (eg: C:\repos\opentelemetry-dotnet\examples\Console\).
/// </summary>
/// <param name="args">Arguments from command line.</param>
public static void Main(string[] args)
Expand Down
5 changes: 5 additions & 0 deletions examples/Console/TestConsoleExporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ namespace Examples.Console
{
internal class TestConsoleExporter
{
// To run this example, run the following command from
// the reporoot\examples\Console\.
// (eg: C:\repos\opentelemetry-dotnet\examples\Console\)
//
// dotnet run console
internal static object Run(ConsoleOptions options)
{
// Enable TracerProvider for the source "MyCompany.MyProduct.MyWebServer"
Expand Down
2 changes: 1 addition & 1 deletion examples/Console/TestGrpcNetClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ internal static object Run()
var source = new ActivitySource("grpc-net-client-test");
using (var parent = source.StartActivity("Main", ActivityKind.Server))
{
using var channel = GrpcChannel.ForAddress("https://localhost:5001");
using var channel = GrpcChannel.ForAddress("https://localhost:44335");
var client = new Greeter.GreeterClient(channel);

try
Expand Down
7 changes: 6 additions & 1 deletion examples/Console/TestHttpClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ namespace Examples.Console
{
internal class TestHttpClient
{
// To run this example, run the following command from
// the reporoot\examples\Console\.
// (eg: C:\repos\opentelemetry-dotnet\examples\Console\)
//
// dotnet run httpclient
internal static object Run()
{
System.Console.WriteLine("Hello World!");
Expand All @@ -41,7 +46,7 @@ internal static object Run()
client.GetStringAsync("http://bing.com").GetAwaiter().GetResult();
}

System.Console.ReadLine();
System.Console.WriteLine("Press Enter key to exit.");

return null;
}
Expand Down
5 changes: 5 additions & 0 deletions examples/Console/TestJaegerExporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ internal class TestJaegerExporter
{
internal static object Run(string host, int port)
{
// To run this example, run the following command from
// the reporoot\examples\Console\.
// (eg: C:\repos\opentelemetry-dotnet\examples\Console\)
//
// dotnet run jaeger -h localhost -p 6831
return RunWithActivity(host, port);
}

Expand Down
10 changes: 5 additions & 5 deletions examples/Console/TestOtlpExporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,9 @@ namespace Examples.Console
internal static class TestOtlpExporter
{
internal static object Run(string endpoint)
{
return RunWithActivitySource(endpoint);
}

private static object RunWithActivitySource(string endpoint)
{
/*
* Prerequisite to run this example:
* Setup an OpenTelemetry Collector to run on local docker.
*
* Open a terminal window at the examples/Console/ directory and
Expand All @@ -51,7 +47,11 @@ private static object RunWithActivitySource(string endpoint)
* For more information about the OpenTelemetry Collector go to https://github.com/open-telemetry/opentelemetry-collector
*
*/
return RunWithActivitySource(endpoint);
}

private static object RunWithActivitySource(string endpoint)
{
// Enable OpenTelemetry for the sources "Samples.SampleServer" and "Samples.SampleClient"
// and use OTLP exporter.
using var openTelemetry = Sdk.CreateTracerProviderBuilder()
Expand Down
15 changes: 9 additions & 6 deletions examples/Console/TestZipkinExporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,15 @@ internal class TestZipkinExporter
{
internal static object Run(string zipkinUri)
{
/*
* Setup zipkin inside local docker.
* docker run -d -p 9411:9411 openzipkin/zipkin
*
* In zipkinUri, use http://localhost:9411/api/v2/spans
*/
// Prerequisite for running this example.
// Setup zipkin inside local docker using following command:
// docker run -d -p 9411:9411 openzipkin/zipkin

// To run this example, run the following command from
// the reporoot\examples\Console\.
// (eg: C:\repos\opentelemetry-dotnet\examples\Console\)
//
// dotnet run zipkin -u http://localhost:9411/api/v2/spans

// Enable OpenTelemetry for the sources "Samples.SampleServer" and "Samples.SampleClient"
// and use the Zipkin exporter.
Expand Down

0 comments on commit 4385164

Please sign in to comment.