microsoft / ApplicationInsights-Java

Application Insights for Java
http://aka.ms/application-insights
Other
297 stars 199 forks source link

Custom telemetry is not sent after upgrading to 3.4.15 from 2.6.3 #3236

Closed tamasvincze closed 1 year ago

tamasvincze commented 1 year ago

Expected behavior

Custom telemetry is not sent after upgrading to 3.4.15 from 2.6.3.

Actual behavior

Custom telemetry is being sent to Azure Application Insights.

To Reproduce

With version 2.6.3 I had this piece of code:

TelemetryConfiguration configuration = TelemetryConfiguration();
configuration.setInstrumentationKey(instrumentationKey);
InProcessTelemetryChannel channel = new InProcessTelemetryChannel(configuration);
configuration.setChannel(channel);
telemetryClient = new TelemetryClient(configuration);
...
telemetryClient.trackEvent(
        "AppEvents",
        ImmutableMap.of("AppEvents",
                objectMapper.writeValueAsString(telemetry)),
        ImmutableMap.of());

The telemetry object is a map consisting of data I need for Azure workbooks.

After upgrading to 3.4.15, I changed the setup part of the previous snippet to this:

telemetryClient = new TelemetryClient();
telemetryClient.getContext().setConnectionString(instrumentationKey);

I also noticed, the TelemetryClient.class file has an empty method:

public void track(Telemetry telemetry) {
}

This way the library itself is unusable and there is no clear migration guide.

System information

Please provide the following information:

Logs

Turn on SDK logs and attach/paste them to the issue. If using an application server, also attach any relevant server logs. No logs, I was unable to setup debug logging (the internal logger seems to disregard all my tries)

Screenshots

None.

trask commented 1 year ago

hi @tamasvincze! check out the migration guide at https://learn.microsoft.com/en-us/azure/azure-monitor/app/java-standalone-upgrade-from-2x and let us know if that answers your questions, thx

tamasvincze commented 1 year ago

hi @tamasvincze! check out the migration guide at https://learn.microsoft.com/en-us/azure/azure-monitor/app/java-standalone-upgrade-from-2x and let us know if that answers your questions, thx

Hey trask, Thanks for the link, somehow it avoided my eyes.

I see it has an early step: "Step 2: Add the 3.x Java agent". For the 2.x agent we did not use agent. Is this a new requirement for 3.x?

trask commented 1 year ago

@tamasvincze no worries. yes, the agent gives you much better out-of-the-box auto-instrumentation from the upstream https://github.com/open-telemetry/opentelemetry-java-instrumentation project with much less effort.

if you are unable to use a Java agent, you can also explore https://github.com/Azure/azure-sdk-for-java/tree/main/sdk/monitor/azure-monitor-opentelemetry-exporter (which is still in beta)

tamasvincze commented 1 year ago

Thanks. I'll close this issue then, it seems i just missed some key information regarding this upgrade. Appreciate the help!