Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attempt to migrate App Insights TrackEvent logic to OpenTelemetry isn't sending data #47580

Open
RickKra opened this issue Dec 16, 2024 · 0 comments
Labels
Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team OpenTelemetry OpenTelemetry instrumentation (not Monitor-specific) question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Service Attention Workflow: This issue is responsible by Azure service team.

Comments

@RickKra
Copy link

RickKra commented Dec 16, 2024

Library name and version

Azure.Monitor.OpenTelemetry.Exporter 1.3.0

Query/Question

I am attempting to migrate a .NET console app that is using the Application Insights SDK to TrackEvent some data (which shows up in my App Insights instance as a customEvent) to OpenTelemetry. IIUC the closest thing to TrackEvent in OpenTelemetry is the Trace signal.

This is what I did before:

public static void SendTelemetry(TelemetryEvent e)
{
    var client = CreateAppInsightsTelemetryClient(e.InstrumentationKey);
    client.TrackEvent(e.EventName, e.Properties, e.Metrics);
    client.Flush();
    Task.Delay(1000).Wait(); // Allow time for flushing
}

Here's what I'm trying now:

public static void SendTelemetry(TelemetryEvent e)
{
    var source = new ActivitySource("Engineering.Telemetry");

    using (Sdk.CreateTracerProviderBuilder()
        .AddAzureMonitorTraceExporter(o => o.ConnectionString = $"InstrumentationKey={e.InstrumentationKey}")
        .AddSource(source.Name)
        .Build())
    {
        using (var activity = source.StartActivity(e.EventName, ActivityKind.Internal))
        {
            foreach (var property in e.Properties)
            {
                activity.SetTag(property.Key, property.Value);
            }

            foreach (var metric in e.Metrics)
            {
                activity.SetTag(metric.Key, metric.Value);
            }
        }
    }
}

But when I run the code nothing appears to be sent. I've checked both customEvents and traces and neither has new data.

The Instrumentation key in TelemetryEvent is correct for my App Insights resource and works fine with the old code. I've also tried replacing that InstrumentationKey={e.InstrumentationKey} string with the Connection String value that you get from the App Insights portal--no luck with that either.

What am I doing wrong?

Environment

  • net8.0
  • /subscriptions/68a57f95-9a3f-43a1-b3a7-37f6e163d5c5/resourceGroups/Telemetry/providers/microsoft.insights/components/vseng-microbuild-v2-telemetry-test (don't know what OS the app insights resources is using)
  • Running the code on Windows 11 24H2 (OS Build 26100.2606)
  • Visual Studio 17.13.0 Preview 3.0 [35609.207.main]
@github-actions github-actions bot added customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels Dec 16, 2024
@jsquire jsquire added Service Attention Workflow: This issue is responsible by Azure service team. Client This issue points to a problem in the data-plane of the library. needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team OpenTelemetry OpenTelemetry instrumentation (not Monitor-specific) and removed needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. labels Dec 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team OpenTelemetry OpenTelemetry instrumentation (not Monitor-specific) question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Service Attention Workflow: This issue is responsible by Azure service team.
Projects
None yet
Development

No branches or pull requests

2 participants