opentelemetry-dotnet
opentelemetry-dotnet copied to clipboard
OtlpExportProtocol does not exist in the namespace 'OpenTelemetry.Exporter.OpenTelemetryProtocol'.
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:
- use the above files in default dotnet app.
@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).
@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.
Reopening and transfering to main repository.
Updates ? Same issue here.