Add otelcol docker to otlp example (#1073)

* Add OTel Collector docker to OTLP example

Adding a configuration and instructions on how to run the OpenTelemetry Collector to receive the spans generated using the OTLP exporter.

* Correct example instructions

* Separate Unix and Windows instructions

* Move collector config file to its own folder

Co-authored-by: Cijo Thomas <cithomas@microsoft.com>
This commit is contained in:
Paulo Janotti 2020-08-17 11:52:58 -07:00 committed by GitHub
parent 4a70a53782
commit 13672a7c84
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 46 additions and 2 deletions

View File

@ -28,6 +28,30 @@ namespace Examples.Console
private static object RunWithActivitySource(string endpoint)
{
/*
* Setup an OpenTelemetry Collector to run on local docker.
*
* Open a terminal window at the examples/Console/ directory and
* launch the OpenTelemetry Collector with an OTLP receiver, by running:
*
* - On Unix based systems use:
* docker run --rm -it -p 55680:55680 -v $(pwd):/cfg otel/opentelemetry-collector:0.7.0 --config=/cfg/otlp-collector-example/config.yaml
*
* - On Windows use:
* docker run --rm -it -p 55680:55680 -v "%cd%":/cfg otel/opentelemetry-collector:0.7.0 --config=/cfg/otlp-collector-example/config.yaml
*
* On another terminal window at the examples/Console/ directory and
* launch the OTLP example by running:
*
* dotnet run -p Examples.Console.csproj otlp
*
* The OpenTelemetry Collector will output all received spans to the stdout of its terminal until
* it is stopped via CTRL+C.
*
* For more information about the OpenTelemetry Collector go to https://github.com/open-telemetry/opentelemetry-collector
*
*/
// Enable OpenTelemetry for the sources "Samples.SampleServer" and "Samples.SampleClient"
// and use OTLP exporter.
using var openTelemetry = Sdk.CreateTracerProviderBuilder()
@ -42,7 +66,7 @@ namespace Examples.Console
sample.Start();
System.Console.WriteLine("Traces are being created and exported" +
"to OTLP in the background." +
"to OTLP in the background. " +
"Press ENTER to stop.");
System.Console.ReadLine();
}

View File

@ -47,7 +47,7 @@ namespace Examples.Console
sample.Start();
System.Console.WriteLine("Traces are being created and exported" +
"to Zipkin in the background. Use Zipkin to view them." +
"to Zipkin in the background. Use Zipkin to view them. " +
"Press ENTER to stop.");
System.Console.ReadLine();
}

View File

@ -0,0 +1,20 @@
# This is a configuration file for the OpenTelemetry Collector intended to be
# used in conjunction with the OTLP Exporter example (see ../TestOtlpExporter.cs)
#
# For more information about the OpenTelemetry Collector see:
# https://github.com/open-telemetry/opentelemetry-collector
#
receivers:
otlp:
protocols:
grpc:
exporters:
logging:
loglevel: debug
service:
pipelines:
traces:
receivers: [otlp]
exporters: [logging]