-
Notifications
You must be signed in to change notification settings - Fork 133
feat: Add telemetry to espressif-ide #1082
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,26 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /******************************************************************************* | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * Copyright 2024 Espressif Systems (Shanghai) PTE LTD. All rights reserved. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * Use is subject to license terms. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| *******************************************************************************/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| package com.espressif.idf.core.logging; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import java.util.Map; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import com.microsoft.applicationinsights.TelemetryClient; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * Azure Telemetry logger | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * @author Kondal Kolipaka <[email protected]> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| public class TelemetryLogger | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| private static final TelemetryClient telemetryClient = new TelemetryClient(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| public static void logEvent(String eventName, Map<String, String> properties) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| telemetryClient.trackEvent(eventName, properties, null); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| telemetryClient.flush(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+19
to
+24
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| private static final TelemetryClient telemetryClient = new TelemetryClient(); | |
| public static void logEvent(String eventName, Map<String, String> properties) | |
| { | |
| telemetryClient.trackEvent(eventName, properties, null); | |
| telemetryClient.flush(); | |
| private static final TelemetryClient telemetryClient; | |
| static { | |
| TelemetryClient client = null; | |
| try { | |
| // Try to get connection string or instrumentation key from environment or system properties | |
| String connectionString = System.getenv("APPLICATIONINSIGHTS_CONNECTION_STRING"); | |
| if (connectionString == null || connectionString.isEmpty()) { | |
| connectionString = System.getProperty("APPLICATIONINSIGHTS_CONNECTION_STRING"); | |
| } | |
| if (connectionString != null && !connectionString.isEmpty()) { | |
| TelemetryConfiguration configuration = TelemetryConfiguration.getActive(); | |
| configuration.setConnectionString(connectionString); | |
| client = new TelemetryClient(configuration); | |
| } else { | |
| // Optionally, try instrumentation key for legacy support | |
| String instrumentationKey = System.getenv("APPINSIGHTS_INSTRUMENTATIONKEY"); | |
| if (instrumentationKey == null || instrumentationKey.isEmpty()) { | |
| instrumentationKey = System.getProperty("APPINSIGHTS_INSTRUMENTATIONKEY"); | |
| } | |
| if (instrumentationKey != null && !instrumentationKey.isEmpty()) { | |
| TelemetryConfiguration configuration = TelemetryConfiguration.getActive(); | |
| configuration.setInstrumentationKey(instrumentationKey); | |
| client = new TelemetryClient(configuration); | |
| } else { | |
| System.err.println("TelemetryLogger: No Application Insights connection string or instrumentation key found. Telemetry is disabled."); | |
| } | |
| } | |
| } catch (Exception e) { | |
| System.err.println("TelemetryLogger: Failed to initialize TelemetryClient: " + e.getMessage()); | |
| } | |
| telemetryClient = client; | |
| } | |
| public static void logEvent(String eventName, Map<String, String> properties) | |
| { | |
| if (telemetryClient == null) { | |
| // Telemetry is not configured; optionally log or ignore | |
| return; | |
| } | |
| try { | |
| telemetryClient.trackEvent(eventName, properties, null); | |
| telemetryClient.flush(); | |
| } catch (Exception e) { | |
| System.err.println("TelemetryLogger: Failed to log telemetry event: " + e.getMessage()); | |
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <classpath> | ||
| <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"> | ||
| <attributes> | ||
| <attribute name="maven.pomderived" value="true"/> | ||
| </attributes> | ||
| </classpathentry> | ||
| <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> | ||
| <classpathentry kind="src" output="bin" path="src"> | ||
| <attributes> | ||
| <attribute name="optional" value="true"/> | ||
| <attribute name="maven.pomderived" value="true"/> | ||
| </attributes> | ||
| </classpathentry> | ||
| <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"> | ||
| <attributes> | ||
| <attribute name="maven.pomderived" value="true"/> | ||
| </attributes> | ||
| </classpathentry> | ||
| <classpathentry kind="output" path="bin"/> | ||
| </classpath> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| /target/ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <projectDescription> | ||
| <name>com.espressif.idf.telemetry</name> | ||
| <comment></comment> | ||
| <projects> | ||
| </projects> | ||
| <buildSpec> | ||
| <buildCommand> | ||
| <name>org.eclipse.jdt.core.javabuilder</name> | ||
| <arguments> | ||
| </arguments> | ||
| </buildCommand> | ||
| <buildCommand> | ||
| <name>org.eclipse.pde.ManifestBuilder</name> | ||
| <arguments> | ||
| </arguments> | ||
| </buildCommand> | ||
| <buildCommand> | ||
| <name>org.eclipse.pde.SchemaBuilder</name> | ||
| <arguments> | ||
| </arguments> | ||
| </buildCommand> | ||
| <buildCommand> | ||
| <name>org.eclipse.m2e.core.maven2Builder</name> | ||
| <arguments> | ||
| </arguments> | ||
| </buildCommand> | ||
| </buildSpec> | ||
| <natures> | ||
| <nature>org.eclipse.m2e.core.maven2Nature</nature> | ||
| <nature>org.eclipse.pde.PluginNature</nature> | ||
| <nature>org.eclipse.jdt.core.javanature</nature> | ||
| </natures> | ||
| </projectDescription> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| eclipse.preferences.version=1 | ||
| encoding/<project>=UTF-8 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| eclipse.preferences.version=1 | ||
| org.eclipse.jdt.core.compiler.codegen.targetPlatform=21 | ||
| org.eclipse.jdt.core.compiler.compliance=21 | ||
| org.eclipse.jdt.core.compiler.problem.assertIdentifier=error | ||
| org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled | ||
| org.eclipse.jdt.core.compiler.problem.enumIdentifier=error | ||
| org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning | ||
| org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning | ||
| org.eclipse.jdt.core.compiler.release=enabled | ||
| org.eclipse.jdt.core.compiler.source=21 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| activeProfiles= | ||
| eclipse.preferences.version=1 | ||
| resolveWorkspaceProjects=true | ||
| version=1 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| Manifest-Version: 1.0 | ||
| Bundle-ManifestVersion: 2 | ||
| Bundle-Name: Telemetry | ||
| Bundle-SymbolicName: com.espressif.idf.telemetry | ||
| Bundle-Version: 1.0.0.qualifier | ||
| Eclipse-BundleShape: dir | ||
| Bundle-Vendor: Espressif Systems | ||
| Automatic-Module-Name: com.espressif.idf.telemetry | ||
| Bundle-RequiredExecutionEnvironment: JavaSE-17 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| source.. = src/ | ||
| output.. = bin/ | ||
| bin.includes = META-INF/,\ | ||
| .,\ | ||
| rootfiles/ | ||
| root=rootfiles | ||
| root.files=rootfiles/** |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
| <modelVersion>4.0.0</modelVersion> | ||
| <artifactId>com.espressif.idf.telemetry</artifactId> | ||
| <version>1.0.0-SNAPSHOT</version> | ||
| <packaging>eclipse-plugin</packaging> | ||
|
|
||
| <parent> | ||
| <groupId>com.espressif.idf</groupId> | ||
| <artifactId>com.espressif.idf.bundles</artifactId> | ||
| <version>1.0.0-SNAPSHOT</version> | ||
| </parent> | ||
|
|
||
| </project> |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,6 @@ | ||||||
| { | ||||||
| "connectionString": "InstrumentationKey=912cbb4e-e606-4c4f-9a00-1731acb15117;IngestionEndpoint=https://eastasia-0.in.applicationinsights.azure.com/;LiveEndpoint=https://eastasia.livediagnostics.monitor.azure.com/;ApplicationId=1efdbec9-ed3f-4e75-a44d-67c6708b6d79", | ||||||
|
||||||
| "connectionString": "InstrumentationKey=912cbb4e-e606-4c4f-9a00-1731acb15117;IngestionEndpoint=https://eastasia-0.in.applicationinsights.azure.com/;LiveEndpoint=https://eastasia.livediagnostics.monitor.azure.com/;ApplicationId=1efdbec9-ed3f-4e75-a44d-67c6708b6d79", | |
| "connectionString": "InstrumentationKey=${INSTRUMENTATION_KEY};IngestionEndpoint=https://eastasia-0.in.applicationinsights.azure.com/;LiveEndpoint=https://eastasia.livediagnostics.monitor.azure.com/;ApplicationId=${APPLICATION_ID}", |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -5,6 +5,8 @@ | |||||
| package com.espressif.idf.ui.wizard; | ||||||
|
|
||||||
| import java.io.File; | ||||||
| import java.util.HashMap; | ||||||
| import java.util.Map; | ||||||
|
|
||||||
| import org.eclipse.cdt.debug.internal.core.InternalDebugCoreMessages; | ||||||
| import org.eclipse.core.resources.IProject; | ||||||
|
|
@@ -40,8 +42,10 @@ | |||||
| import com.espressif.idf.core.LaunchBarTargetConstants; | ||||||
| import com.espressif.idf.core.build.IDFLaunchConstants; | ||||||
| import com.espressif.idf.core.logging.Logger; | ||||||
| import com.espressif.idf.core.logging.TelemetryLogger; | ||||||
| import com.espressif.idf.core.util.ClangFormatFileHandler; | ||||||
| import com.espressif.idf.core.util.ClangdConfigFileHandler; | ||||||
| import com.espressif.idf.core.util.EclipseIniUtil; | ||||||
|
||||||
| import com.espressif.idf.core.util.EclipseIniUtil; |
Copilot
AI
Aug 6, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Use diamond operator for better code readability: new HashMap<>() instead of new HashMap<String, String>().
| Map<String, String> properties = new HashMap<String, String>(); | |
| Map<String, String> properties = new HashMap<>(); |
Check warning on line 213 in bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/wizard/NewIDFProjectWizard.java
GitHub Actions / spotbugs
NP_NULL_ON_SOME_PATH
Possible null pointer dereference of NewIDFProjectWizard.projectCreationWizardPage in com.espressif.idf.ui.wizard.NewIDFProjectWizard.getGenerator()
Raw output
There is a branch of statement that, if executed, guarantees that a null value will be dereferenced, which would generate a NullPointerException when the code is executed. Of course, the problem might be that the branch or statement is infeasible and that the null pointer exception cannot ever be executed; deciding that is beyond the ability of SpotBugs.
Check warning on line 294 in bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/wizard/NewIDFProjectWizard.java
GitHub Actions / spotbugs
SIC_INNER_SHOULD_BE_STATIC
Should com.espressif.idf.ui.wizard.NewIDFProjectWizard$TargetSwitchJob be a _static_ inner class?
Raw output
This class is an inner class, but does not use its embedded reference to the object which created it. This reference makes the instances of the class larger, and may keep the reference to the creator object alive longer than necessary. If possible, the class should be made static.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,11 +14,13 @@ | |
| </configIni> | ||
|
|
||
| <launcherArgs> | ||
| <vmArgsLin>-Xms2048m -Xmx4096m -Dosgi.requiredJavaVersion=17 [email protected]/workspace | ||
| <vmArgsLin>-javaagent:resources/applicationinsights-agent-3.6.2.jar | ||
| -Xms2048m -Xmx4096m -Dosgi.requiredJavaVersion=17 [email protected]/workspace | ||
| </vmArgsLin> | ||
| <vmArgsMac>-Xms2048m -Xmx4096m -Xdock:icon=../Resources/espressif.icns -XstartOnFirstThread -Dosgi.requiredJavaVersion=17 -Dorg.eclipse.swt.internal.carbon.smallFonts [email protected]/workspace | ||
| <vmArgsMac>-javaagent:resources/applicationinsights-agent-3.6.2.jar | ||
| -Xms2048m -Xmx4096m -Xdock:icon=../Resources/espressif.icns -XstartOnFirstThread -Dosgi.requiredJavaVersion=17 -Dorg.eclipse.swt.internal.carbon.smallFonts [email protected]/workspace | ||
| </vmArgsMac> | ||
| <vmArgsWin>-Xms2048m -Xmx4096m -Dosgi.requiredJavaVersion=17 [email protected]/workspace | ||
| <vmArgsWin>-javaagent:resources/applicationinsights-agent-3.6.2.jar -Xms2048m -Xmx4096m -Dosgi.requiredJavaVersion=17 [email protected]/workspace | ||
| </vmArgsWin> | ||
| </launcherArgs> | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Calling flush() after every event can impact performance as it forces immediate transmission. Consider batching events or using async transmission, especially if this method will be called frequently.