Skip to content

Commit

Permalink
Merge pull request #431 from Microsoft/reorganizeSanitizationLogic
Browse files Browse the repository at this point in the history
Reorganize sanitization logic (Please review carefully)
  • Loading branch information
Dmitry-Matveev committed Sep 25, 2017
2 parents 96ca725 + 4e29a75 commit bc4a4a4
Show file tree
Hide file tree
Showing 57 changed files with 531 additions and 1,896 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# CHANGELOG

## Version 1.0.10
- `track()` method of 'com.microsoft.applicationinsights.TelemetryClient' is now modified. No longer performing pre-sanitization
- All Sanitization will now occur in `com.microsoft.applicationinsights.telemetry.JsonTelemetryDataSerializer` class.
- Method `sanitize` of interface `com.microsoft.applicationinsights.telemetry.Telemetry` is now obsolete.
- The auto generated schema classes now have writer method with limits according to endpoint.
- Fixed issue #403 (Exceeding property length invalidates custom event)
- Fixed issue #401 (Custom key and property sanitized)
- Fixed Request Telemetry Sending bug with new schema.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -416,12 +416,6 @@ public void track(Telemetry telemetry) {
throw new IllegalArgumentException("Instrumentation key cannot be undefined.");
}

try {
telemetry.sanitize();
} catch (Throwable t) {
InternalLogger.INSTANCE.error("Exception while sanitizing telemetry: '%s'",t.getMessage());
}

if (!activateProcessors(telemetry)) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,16 @@

package com.microsoft.applicationinsights;

import java.util.ArrayList;
import java.util.List;

import com.google.common.base.Strings;
import com.microsoft.applicationinsights.channel.TelemetryChannel;

import com.microsoft.applicationinsights.extensibility.ContextInitializer;
import com.microsoft.applicationinsights.extensibility.TelemetryInitializer;
import com.microsoft.applicationinsights.extensibility.TelemetryModule;
import com.microsoft.applicationinsights.extensibility.TelemetryProcessor;
import com.microsoft.applicationinsights.internal.config.TelemetryConfigurationFactory;
import com.microsoft.applicationinsights.internal.logger.InternalLogger;
import com.microsoft.applicationinsights.internal.util.Sanitizer;

import com.google.common.base.Strings;
import java.util.ArrayList;
import java.util.List;

/**
* Encapsulates the global telemetry configuration typically loaded from the ApplicationInsights.xml file.
Expand Down Expand Up @@ -186,9 +182,6 @@ public String getInstrumentationKey() {
* @throws IllegalArgumentException when the new value is null or empty
*/
public void setInstrumentationKey(String key) {
if (!Sanitizer.isUUID(key)) {
InternalLogger.INSTANCE.trace("Telemetry Configuration: instrumentation key '%s' is not in UUID format", key);
}

// A non null, non empty instrumentation key is a must
if (Strings.isNullOrEmpty(key)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,24 @@ public void setId(String id) {
MapUtil.setStringValueOrRemove(tags, ContextTagKeys.getKeys().getOperationId(), id);
}

/**
* Set the Operation Parent id
* @param parentId
*/
public void setParentId(String parentId) {
MapUtil.setStringValueOrRemove(tags, ContextTagKeys.getKeys().getOperationParentId(), parentId);
}


/**
* Get the operation parent id
* @return
*/

public String getParentId() {
return MapUtil.getValueOrNull(tags, ContextTagKeys.getKeys().getOperationParentId());
}

/**
* Gets the operation name.
* @return Operation name.
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -232,17 +232,12 @@ protected void serializeContent(JsonTelemetryDataSerializer writer) throws IOExc
{
super.serializeContent(writer);
writer.write("ver", ver);

writer.write("id", id);

writer.write("name", name);

writer.writeRequired("id", id, 64);
writer.writeRequired("name", name, 1024);
writer.write("duration", duration);

writer.write("success", success);

writer.write("runLocation", runLocation);
writer.write("message", message);
writer.write("runLocation", runLocation, 1024);
writer.write("message", message, 8192);
writer.write("properties", properties);
writer.write("measurements", measurements);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,12 @@
* Generated from Base.bond (https://github.com/Microsoft/bond)
*/
package com.microsoft.applicationinsights.internal.schemav2;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.ArrayList;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.ConcurrentHashMap;

import com.google.common.base.Preconditions;
import com.microsoft.applicationinsights.telemetry.JsonSerializable;
import com.microsoft.applicationinsights.telemetry.Duration;
import com.microsoft.applicationinsights.telemetry.JsonTelemetryDataSerializer;
import com.google.common.base.Preconditions;

import java.io.IOException;

/**
* Data contract class Base.
Expand Down Expand Up @@ -84,7 +80,7 @@ public void serialize(JsonTelemetryDataSerializer writer) throws IOException
*/
protected void serializeContent(JsonTelemetryDataSerializer writer) throws IOException
{
writer.write("baseType", baseType);
writer.writeRequired("baseType", baseType, 1000);
}

/**
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,10 @@
* Generated from Data.bond (https://github.com/Microsoft/bond)
*/
package com.microsoft.applicationinsights.internal.schemav2;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.ArrayList;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.ConcurrentHashMap;
import com.microsoft.applicationinsights.telemetry.JsonSerializable;
import com.microsoft.applicationinsights.telemetry.Duration;

import com.microsoft.applicationinsights.telemetry.JsonTelemetryDataSerializer;
import com.google.common.base.Preconditions;

import java.io.IOException;

/**
* Data contract class Data.
Expand Down

0 comments on commit bc4a4a4

Please sign in to comment.