Added instructions to run console examples (#1525)

This commit is contained in:
Cijo Thomas 2020-11-12 12:19:07 -08:00 committed by GitHub
parent 93f614ba58
commit 4385164d85
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 32 additions and 14 deletions

View File

@ -35,7 +35,7 @@ namespace Examples.Console
/// dotnet run -p Examples.Console.csproj zpages /// dotnet run -p Examples.Console.csproj zpages
/// ///
/// The above must be run from the project root folder /// 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> /// </summary>
/// <param name="args">Arguments from command line.</param> /// <param name="args">Arguments from command line.</param>
public static void Main(string[] args) public static void Main(string[] args)

View File

@ -24,6 +24,11 @@ namespace Examples.Console
{ {
internal class TestConsoleExporter 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) internal static object Run(ConsoleOptions options)
{ {
// Enable TracerProvider for the source "MyCompany.MyProduct.MyWebServer" // Enable TracerProvider for the source "MyCompany.MyProduct.MyWebServer"

View File

@ -36,7 +36,7 @@ namespace Examples.Console
var source = new ActivitySource("grpc-net-client-test"); var source = new ActivitySource("grpc-net-client-test");
using (var parent = source.StartActivity("Main", ActivityKind.Server)) 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); var client = new Greeter.GreeterClient(channel);
try try

View File

@ -23,6 +23,11 @@ namespace Examples.Console
{ {
internal class TestHttpClient 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() internal static object Run()
{ {
System.Console.WriteLine("Hello World!"); System.Console.WriteLine("Hello World!");
@ -41,7 +46,7 @@ namespace Examples.Console
client.GetStringAsync("http://bing.com").GetAwaiter().GetResult(); client.GetStringAsync("http://bing.com").GetAwaiter().GetResult();
} }
System.Console.ReadLine(); System.Console.WriteLine("Press Enter key to exit.");
return null; return null;
} }

View File

@ -22,6 +22,11 @@ namespace Examples.Console
{ {
internal static object Run(string host, int port) 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); return RunWithActivity(host, port);
} }

View File

@ -22,13 +22,9 @@ namespace Examples.Console
internal static class TestOtlpExporter internal static class TestOtlpExporter
{ {
internal static object Run(string endpoint) 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. * Setup an OpenTelemetry Collector to run on local docker.
* *
* Open a terminal window at the examples/Console/ directory and * Open a terminal window at the examples/Console/ directory and
@ -51,7 +47,11 @@ namespace Examples.Console
* For more information about the OpenTelemetry Collector go to https://github.com/open-telemetry/opentelemetry-collector * 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" // Enable OpenTelemetry for the sources "Samples.SampleServer" and "Samples.SampleClient"
// and use OTLP exporter. // and use OTLP exporter.
using var openTelemetry = Sdk.CreateTracerProviderBuilder() using var openTelemetry = Sdk.CreateTracerProviderBuilder()

View File

@ -24,12 +24,15 @@ namespace Examples.Console
{ {
internal static object Run(string zipkinUri) internal static object Run(string zipkinUri)
{ {
/* // Prerequisite for running this example.
* Setup zipkin inside local docker. // Setup zipkin inside local docker using following command:
* docker run -d -p 9411:9411 openzipkin/zipkin // docker run -d -p 9411:9411 openzipkin/zipkin
*
* In zipkinUri, use http://localhost:9411/api/v2/spans // 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" // Enable OpenTelemetry for the sources "Samples.SampleServer" and "Samples.SampleClient"
// and use the Zipkin exporter. // and use the Zipkin exporter.