Improvements to the OTLP trace example (#3141)
This commit is contained in:
parent
4384c3ceef
commit
950c6162b4
|
|
@ -27,14 +27,18 @@ namespace Examples.Console
|
||||||
/// Main method - invoke this using command line.
|
/// Main method - invoke this using command line.
|
||||||
/// For example:
|
/// For example:
|
||||||
///
|
///
|
||||||
/// dotnet run --project Examples.Console.csproj console
|
/// dotnet run --project Examples.Console.csproj -- console
|
||||||
/// dotnet run --project Examples.Console.csproj inmemory
|
/// dotnet run --project Examples.Console.csproj -- inmemory
|
||||||
/// dotnet run --project Examples.Console.csproj zipkin -u http://localhost:9411/api/v2/spans
|
/// dotnet run --project Examples.Console.csproj -- zipkin -u http://localhost:9411/api/v2/spans
|
||||||
/// dotnet run --project Examples.Console.csproj jaeger -h localhost -p 6831
|
/// dotnet run --project Examples.Console.csproj -- jaeger -h localhost -p 6831
|
||||||
/// dotnet run --project Examples.Console.csproj prometheus -p 9464
|
/// dotnet run --project Examples.Console.csproj -- prometheus -p 9464
|
||||||
/// dotnet run --project Examples.Console.csproj otlp -e "http://localhost:4317" -p "grpc"
|
/// dotnet run --project Examples.Console.csproj -- otlp -e "http://localhost:4317" -p "grpc"
|
||||||
/// dotnet run --project Examples.Console.csproj zpages
|
/// dotnet run --project Examples.Console.csproj -- zpages
|
||||||
/// dotnet run --project Examples.Console.csproj metrics --help
|
/// dotnet run --project Examples.Console.csproj -- metrics --help
|
||||||
|
///
|
||||||
|
/// To see all available examples in the project run:
|
||||||
|
///
|
||||||
|
/// dotnet run --project Examples.Console.csproj -- --help
|
||||||
///
|
///
|
||||||
/// 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\examples\Console\).
|
/// (eg: C:\repos\opentelemetry-dotnet\examples\Console\).
|
||||||
|
|
@ -153,7 +157,7 @@ namespace Examples.Console
|
||||||
[Verb("otlp", HelpText = "Specify the options required to test OpenTelemetry Protocol (OTLP)")]
|
[Verb("otlp", HelpText = "Specify the options required to test OpenTelemetry Protocol (OTLP)")]
|
||||||
internal class OtlpOptions
|
internal class OtlpOptions
|
||||||
{
|
{
|
||||||
[Option('e', "endpoint", HelpText = "Target to which the exporter is going to send traces or metrics", Default = "http://localhost:4317")]
|
[Option('e', "endpoint", HelpText = "Target to which the exporter is going to send traces or metrics (default value depends on protocol).", Default = null)]
|
||||||
public string Endpoint { get; set; }
|
public string Endpoint { get; set; }
|
||||||
|
|
||||||
[Option('p', "protocol", HelpText = "Transport protocol used by exporter. Supported values: grpc and http/protobuf.", Default = "grpc")]
|
[Option('p', "protocol", HelpText = "Transport protocol used by exporter. Supported values: grpc and http/protobuf.", Default = "grpc")]
|
||||||
|
|
|
||||||
|
|
@ -34,10 +34,10 @@ namespace Examples.Console
|
||||||
* launch the OpenTelemetry Collector with an OTLP receiver, by running:
|
* launch the OpenTelemetry Collector with an OTLP receiver, by running:
|
||||||
*
|
*
|
||||||
* - On Unix based systems use:
|
* - On Unix based systems use:
|
||||||
* docker run --rm -it -p 4317:4317 -v $(pwd):/cfg otel/opentelemetry-collector:0.33.0 --config=/cfg/otlp-collector-example/config.yaml
|
* docker run --rm -it -p 4317:4317 -p 4318:4318 -v $(pwd):/cfg otel/opentelemetry-collector:0.48.0 --config=/cfg/otlp-collector-example/config.yaml
|
||||||
*
|
*
|
||||||
* - On Windows use:
|
* - On Windows use:
|
||||||
* docker run --rm -it -p 4317:4317 -v "%cd%":/cfg otel/opentelemetry-collector:0.33.0 --config=/cfg/otlp-collector-example/config.yaml
|
* docker run --rm -it -p 4317:4317 -p 4318:4318 -v "%cd%":/cfg otel/opentelemetry-collector:0.48.0 --config=/cfg/otlp-collector-example/config.yaml
|
||||||
*
|
*
|
||||||
* Open another terminal window at the examples/Console/ directory and
|
* Open another terminal window at the examples/Console/ directory and
|
||||||
* launch the OTLP example by running:
|
* launch the OTLP example by running:
|
||||||
|
|
@ -74,8 +74,15 @@ namespace Examples.Console
|
||||||
.SetResourceBuilder(ResourceBuilder.CreateDefault().AddService("otlp-test"))
|
.SetResourceBuilder(ResourceBuilder.CreateDefault().AddService("otlp-test"))
|
||||||
.AddOtlpExporter(opt =>
|
.AddOtlpExporter(opt =>
|
||||||
{
|
{
|
||||||
opt.Endpoint = new Uri(endpoint);
|
// If endpoint was not specified, the proper one will be selected according to the protocol.
|
||||||
|
if (!string.IsNullOrEmpty(endpoint))
|
||||||
|
{
|
||||||
|
opt.Endpoint = new Uri(endpoint);
|
||||||
|
}
|
||||||
|
|
||||||
opt.Protocol = otlpExportProtocol.Value;
|
opt.Protocol = otlpExportProtocol.Value;
|
||||||
|
|
||||||
|
System.Console.WriteLine($"OTLP Exporter is using {opt.Protocol} protocol and endpoint {opt.Endpoint}");
|
||||||
})
|
})
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ receivers:
|
||||||
otlp:
|
otlp:
|
||||||
protocols:
|
protocols:
|
||||||
grpc:
|
grpc:
|
||||||
|
http:
|
||||||
|
|
||||||
exporters:
|
exporters:
|
||||||
logging:
|
logging:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue