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

Added Severity level to tracing #430

Merged
merged 1 commit into from Mar 27, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions JavaScript/JavaScriptSDK.Interfaces/IAppInsights.ts
Expand Up @@ -105,10 +105,11 @@ module Microsoft.ApplicationInsights {

/**
* Log a diagnostic message.
* @param message A message string
* @param message A message string
* @param properties map[string, string] - additional data used to filter traces in the portal. Defaults to empty.
* @param severityLevel AI.SeverityLevel - severity level
*/
trackTrace(message: string, properties?: { [name: string]: string; });
trackTrace(message: string, properties?: { [name: string]: string; }, severityLevel?: AI.SeverityLevel);


/**
Expand Down
5 changes: 3 additions & 2 deletions JavaScript/JavaScriptSDK/AppInsights.ts
Expand Up @@ -377,10 +377,11 @@ module Microsoft.ApplicationInsights {
* Log a diagnostic message.
* @param message A message string
* @param properties map[string, string] - additional data used to filter traces in the portal. Defaults to empty.
* @param severityLevel AI.SeverityLevel - severity level
*/
public trackTrace(message: string, properties?: Object) {
public trackTrace(message: string, properties?: Object, severityLevel?: AI.SeverityLevel) {
try {
var telemetry = new Telemetry.Trace(message, properties);
var telemetry = new Telemetry.Trace(message, properties, severityLevel);
var data = new ApplicationInsights.Telemetry.Common.Data<ApplicationInsights.Telemetry.Trace>(Telemetry.Trace.dataType, telemetry);
var envelope = new Telemetry.Common.Envelope(data, Telemetry.Trace.envelopeType);

Expand Down
8 changes: 6 additions & 2 deletions JavaScript/JavaScriptSDK/Telemetry/Trace.ts
Expand Up @@ -18,13 +18,17 @@ module Microsoft.ApplicationInsights.Telemetry {
};

/**
* Constructs a new instance of the MetricTelemetry object
* Constructs a new instance of the TraceTelemetry object
*/
constructor(message: string, properties?: any) {
constructor(message: string, properties?: any, severityLevel?: AI.SeverityLevel) {
super();
message = message || Util.NotSpecified;
this.message = Common.DataSanitizer.sanitizeMessage(message);
this.properties = Common.DataSanitizer.sanitizeProperties(properties);

if (severityLevel) {
this.severityLevel = severityLevel;
}
}
}
}
2 changes: 1 addition & 1 deletion JavaScript/JavaScriptSDK/Util.ts
Expand Up @@ -412,7 +412,7 @@ module Microsoft.ApplicationInsights {
if (Date.prototype.toISOString) {
return date.toISOString();
} else {
function pad(number) {
const pad = function(number) {
var r = String(number);
if (r.length === 1) {
r = "0" + r;
Expand Down