Opentelemetry-dotnet: Connecting with a local opentelemetry-collector instance

Created on 19 Mar 2021  路  2Comments  路  Source: open-telemetry/opentelemetry-dotnet

Question

I have a bit of a problem getting some example code running.
The ConsoleExporter seems to work, OtlpExporter not.

I'm running a local otelcol_windows_amd64 v0.22.0 (config below). The endpoint information used in my .NET code was extracted from otelcols console output. I expected to see at least some information regarding a connection, but nothing happens when I run my code. the defined file exporter also doesn't wrote anything to disk.

Any hint on what I might do wrong? It's totally possible the problem is due to a wrong configuration of otelcol, I wasn't sure where to post my question.

static void Main(string[] args)
        {

            var openTelemetry = Sdk.CreateTracerProviderBuilder()
                    .AddSource("MyCompany.MyProduct.MyLibrary")
                    .SetSampler(new AlwaysOnSampler())
                    .AddOtlpExporter(opt =>
                    {
                        opt.Endpoint = new Uri("http://localhost:55681");
                    })
                    .AddConsoleExporter()
                    .Build();

            using (var activity = MyActivitySource.StartActivity("SayHello"))
            {
                activity?.SetTag("foo", 1);
                activity?.SetTag("bar", "Hello, World!");
                activity?.SetTag("baz", new int[] { 1, 2, 3 });
            }
        }

Describe your environment.

  <package id="OpenTelemetry" version="1.0.1" targetFramework="net48" />
  <package id="OpenTelemetry.Api" version="1.0.1" targetFramework="net48" />
  <package id="OpenTelemetry.Exporter.Console" version="1.0.1" targetFramework="net48" />
  <package id="OpenTelemetry.Exporter.OpenTelemetryProtocol" version="1.0.1" targetFramework="net48" />

2021-03-19T15:25:14.357+0100 info service/service.go:411 Starting OpenTelemetry Collector... {"Version": "v0.22.0", "GitHash": "0345f0d2", "NumCPU": 12}


receivers:
  otlp:
    protocols:
      http:
  otlp/2:
    protocols:
      grpc:
      http:

processors:

exporters:
  # Data sources: traces, metrics, logs
  file:
    path: ./metrics.json

extensions:

service:
  extensions: []
  pipelines:
    metrics:
      receivers: [otlp/2]
      processors: []
      exporters: [file]
    traces:
      receivers: [otlp/2]
      processors: []
      exporters: [file]

question

All 2 comments

@MatthiasSchilder Currently, OTLP exporter only supports gRPC protocol so you'll have to update the endpoint to match that of the OTLP receiver's gRPC endpoint which is http://localhost:4317.

http://localhost:55681 is the OTLP receiver's http endpoint.

https://github.com/open-telemetry/opentelemetry-collector/blob/main/receiver/otlpreceiver/README.md#getting-started

Thank you. This, combined with an issue due to an over-motivated proxy, was the problem. Closed.

Was this page helpful?
0 / 5 - 0 ratings