opentelemetry-dotnet icon indicating copy to clipboard operation
opentelemetry-dotnet copied to clipboard

OtlpExportProtocol does not exist in the namespace 'OpenTelemetry.Exporter.OpenTelemetryProtocol'.

Open saikalyan-bhagavathula opened this issue 2 years ago • 4 comments

Bug Report

Symptom

Describe the bug OtlpExportProtocol does not exist in the namespace 'OpenTelemetry.Exporter.OpenTelemetryProtocol'.

My Program.cs file


using System.Diagnostics;
using OpenTelemetry.Resources;
using OpenTelemetry.Trace;
using OpenTelemetry;
using OpenTelemetry.Exporter.OpenTelemetryProtocol.OtlpExportProtocol;


var builder = WebApplication.CreateBuilder(args);

builder.Services.AddOpenTelemetry()
  .WithTracing(b =>
  {
    b.AddSource(DiagnosticsConfig.ActivitySource.Name);
    b.ConfigureResource(resource => resource
    .AddService(DiagnosticsConfig.ServiceName));
    b.AddAspNetCoreInstrumentation() 
    .AddOtlpExporter(opt =>
    {
        opt.Endpoint = new Uri("http://localhost:4317");
        opt.Protocol = OpenTelemetry.Exporter.OpenTelemetryProtocol.OtlpExportProtocol.Grpc;
    });
    b.AddConsoleExporter();
  });


var app = builder.Build();
app.MapGet("/", () => "Hello World!");
app.Run();


public static class DiagnosticsConfig
{
    public const string ServiceName = "MyService";
    public static ActivitySource ActivitySource = new ActivitySource(ServiceName);
}



My MyWebApp.csproj

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>net7.0</TargetFramework>
    <Nullable>enable</Nullable>
    <ImplicitUsings>enable</ImplicitUsings>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="OpenTelemetry.Exporter.Console" Version="1.5.1" />
    <PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.5.1" />
    <PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.5.1" />
    <PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.5.0-beta.1" />
  </ItemGroup>

</Project>

Getting Following error when I do dotnet run using above code files

/MyWebApp# dotnet run
Building...
/home/dotnet/Automatic/MyWebApp/Program.cs(5,52): error CS0234: The type or namespace name 'OtlpExportProtocol' does not exist in the namespace 'OpenTelemetry.Exporter.OpenTelemetryProtocol' (are you missing an assembly reference?) [/home/dotnet/Automatic/MyWebApp/MyWebApp.csproj]

The build failed. Fix the build errors and run again.

Expected behavior Push traces to http://localhost:4317 without any error.

Runtime environment (please complete the following information): NAME="Ubuntu" VERSION="20.04.5 LTS (Focal Fossa)" ID=ubuntu ID_LIKE=debian PRETTY_NAME="Ubuntu 20.04.5 LTS" VERSION_ID="20.04" HOME_URL="https://www.ubuntu.com/" SUPPORT_URL="https://help.ubuntu.com/" BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/" PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy" VERSION_CODENAME=focal UBUNTU_CODENAME=focal

Additional context

  • Even for Http i am getting the same error. Able to get trace/span data in console but with Otlp exporter getting the mentioned error.
  • If we remove the protocol option no error is throwing but unable to see the trace data in listener side.

Reproduce

Steps to reproduce the behavior:

  1. use the above files in default dotnet app.

saikalyan-bhagavathula avatar Jul 04 '23 12:07 saikalyan-bhagavathula

@saikalyan-bhagavathula seems like this issue is more suitable for opentelemetry-dotnet. Could not notice anything connected to AutoInstrumentation (since you are setting up everything manually).

RassK avatar Jul 05 '23 16:07 RassK

@open-telemetry/dotnet-approvers and @open-telemetry/dotnet-maintainers this issue was submitted to the auto-instrumentation repo, but appears to be a problem when using the SDK directly. I'm closing the issue in this repo but you may want to follow up with the submitter in case you need more information.

nrcventura avatar Jul 12 '23 16:07 nrcventura

Reopening and transfering to main repository.

Kielek avatar Jul 19 '23 08:07 Kielek

Updates ? Same issue here.

chrisribe avatar Jan 08 '24 21:01 chrisribe