[BUG] trackTrace with ICustomProperties does not allow numeric values
See original GitHub issueI’m using applicationinsights-web with an Angular application. When logging a trace message using a custom properties object, any values which are not strings are ignored (with no error message). If I intercept the properties object and convert the values to strings then all the values are logged as expected. As far as I understand the index signature { key: string]: any } should allow numeric values to be logged?
Example of logging code with the workaround in place:
logTrace(
message: string,
severityLevel: SeverityLevel,
properties?: { [key: string]: any }
) {
// convert the properties object into keys with only string values
Object.keys(properties).forEach(k => { properties[k] = properties[k].toString() })
this.appInsights.trackTrace(
{ message: message, severityLevel: severityLevel },
properties
);
}
Steps to Reproduce
- Windows/Chrome
- “@microsoft/applicationinsights-web”: “^2.7.0”
- SDK initialised like this:
this.appInsights = new ApplicationInsights({
config: {
connectionString: config.connectionStringAI,
enableAutoRouteTracking: true,
disableFetchTracking: false,
enableUnhandledPromiseRejectionTracking: true,
},
});
this.appInsights.loadAppInsights();
this.appInsights.addTelemetryInitializer((envelope) => {
envelope.data.appVersion = environment.appVersion;
envelope.tags['ai.cloud.role'] = 'IonicAngularApp';
});
Issues #1737 and #1057 may be related?
Expected behavior Numeric or boolean or other types should be logged against object keys (strings) in object with type ICustomProperties
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Send custom complex properties to Telemetry to Azure Portal ...
The problem is with the SDK version. In Azure portal and in tags property from browser AJAX calls it shows that i'm using...
Read more >Tracing and logging with Application Insights - Andrei Dzimchuk
Metrics allow you to send numeric data such as time measurements or uploaded data size that you want to be associated with the...
Read more >Azure Application Insights for JavaScript web apps
Add the JavaScript SDK; Configuration; Cookie handling; Enable ... If you use the npm setup, don't use the snippet and vice versa.
Read more >Azure Application Insights series part 1: How to instrument ...
Instrumentation is code added to an application that allows us to ... Note: The instrumentation key is not considered a secret value.
Read more >Error.prototype.stack - JavaScript - MDN Web Docs - Mozilla
Value. A string. Because the stack property is non-standard, implementations differ about where it's installed.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@Karlie-777 can you please investigate this a bit further (create a repro and a unit test for the issue and then address any issues).
For reference
get flattened, stringified or ignored altogether.
is the design but the ignored should be causing some logging / failures (for exceptions), this may only currently be documented in the code so we should add this somewhere more visible as per @baxxos suggestion.I don’t think we want to change the
ICustomProperties
to be specific as I’m aware of several internal / external users the use theget flattened
(JSON.stringify()) functionality of the any aspect.The properties interface is defined in a way that allows us to pass in any kind of value - e.g. a deeply nested object, but from my experience, it only works reliably with strings. More complex values will either get flattened, stringified or ignored altogether.
Example:
results in:
It would be nice to define the
ICustomProperties
in a way that would reflect only the supported data types or describe the value processing behavior in documentation.