Azure-sdk-for-net: [BUG] Microsoft.OpenTelemetry.Exporter.AzureMonitor not working with OpenTelemetry RC1.1

Created on 1 Dec 2020  Â·  6Comments  Â·  Source: Azure/azure-sdk-for-net

Describe the bug
The Azure Monitor Exporter (1.0.0-beta.1) Nuget-Package is incompatible with Nuget-Package OpenTelemetry (1.0.0-rc1.1).
When trying to compile an ASP.NET Core (3.1) solution using these packages, I get the error
CS7069: Reference to type 'TracerProviderBuilder' claims it is defined in 'OpenTelemetry', but it could not be found.

Reverting OpenTelemetry to v0.8.0-beta.1 fixes the issue.

Expected behavior
Solution should compile given the dependency of Azure Monitor Exporter on OpenTelemetry >= 0.8.0-beta.1

Actual behavior (include Exception or Stack Trace)
I get the following error when trying to compile the project
CS7069: Reference to type 'TracerProviderBuilder' claims it is defined in 'OpenTelemetry', but it could not be found.

To Reproduce
Steps to reproduce the behavior (include a code snippet, screenshot, or any additional information that might help us reproduce the issue)

  1. dotnet new web
  2. dotnet add package Microsoft.OpenTelemetry.Exporter.AzureMonitor -v 1.0.0-beta.1
  3. dotnet add package OpenTelemetry -v 1.0.0-rc1.1
  4. Add following code to Startup.Configure as instructed by the Getting Started Guide
using Microsoft.OpenTelemetry.Exporter.AzureMonitor;
using OpenTelemetry.Trace;

OpenTelemetry.Sdk.CreateTracerProviderBuilder()
    .AddSource("Demo.DemoClient")
    .AddAzureMonitorTraceExporter(o => {
        o.ConnectionString = "<Your Connection String>";
    })
    .Build();
  1. dotnet build

Environment:

  • Microsoft.OpenTelemetry.Exporter.AzureMonitor 1.0.0-beta.1

    • OpenTelemetry (1.0.0-rc1.1)

    • .NET Core SDK 3.1.403

    • Visual Studio 2019 Enterprise Version 16.7.5

Client Monitor - Exporter Service Attention customer-reported needs-team-attention question

All 6 comments

Thank you for your feedback. Tagging and routing to the team best able to assist.

It's most likely because the extension for adding the exporter is not in the OpenTelemetry.Trace namespace.

as a quick walkaround you can add the process manually with
.AddProcessor(new BatchExportProcessor<Activity>(new AzureMonitorTraceExporter(new AzureMonitorExporterOptions()))

You can also call the extension explicitly by calling the static function and sending in the builder.

On Dec 8, 2020, at 11:35 AM, Maciej Boguta notifications@github.com wrote:



as a quick walkaround you can add the process manually with
.AddProcessor(new BatchExportProcessor(new AzureMonitorTraceExporter(new AzureMonitorExporterOptions()))

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHubhttps://github.com/Azure/azure-sdk-for-net/issues/17253#issuecomment-740746549, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABYGNLA6SC3UDDXP6A3MXLLSTZIWJANCNFSM4UI3QODA.

as a quick walkaround you can add the process manually with
.AddProcessor(new BatchExportProcessor<Activity>(new AzureMonitorTraceExporter(new AzureMonitorExporterOptions()))

This quick fix seems to compile, thanks @macfocha!

Update:
I tried to create a minimal example using:
services.AddOpenTelemetryTracing((builder) => builder .AddAspNetCoreInstrumentation() .AddProcessor(new BatchExportProcessor<Activity>(new AzureMonitorTraceExporter(new AzureMonitorExporterOptions() { ConnectionString = "PLACEHOLDER" }))));

Although I invoke my controller multiple time, nothing shows up in Application Insights...

You can also call the extension explicitly by calling the static function and sending in the builder. On Dec 8, 2020, at 11:35 AM

I tried doing this:
var builder = OpenTelemetry.Sdk.CreateTracerProviderBuilder().AddSource("Demo.DemoClient"); Microsoft.OpenTelemetry.Exporter.AzureMonitor.AzureMonitorExporterHelperExtensions.AddAzureMonitorTraceExporter(builder, (opt) => { });

but I still get
CS7069: Reference to type 'TracerProviderBuilder' claims it is defined in 'OpenTelemetry', but it could not be found.

Was this page helpful?
0 / 5 - 0 ratings