Skip to content
This repository has been archived by the owner on Dec 4, 2023. It is now read-only.

Commit

Permalink
Formatting changes (#1076)
Browse files Browse the repository at this point in the history
  • Loading branch information
tracyboehrer authored Mar 24, 2021
1 parent c01ecdd commit 9d60e67
Show file tree
Hide file tree
Showing 11 changed files with 511 additions and 401 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@
import java.util.concurrent.ConcurrentMap;

/**
* We took this class from https://github.com/microsoft/ApplicationInsights-Java/issues/1099
* as this is not already migrated in ApplicationInsights-Java library.
* We took this class from
* https://github.com/microsoft/ApplicationInsights-Java/issues/1099 as this is
* not already migrated in ApplicationInsights-Java library.
*/
public final class AvailabilityTelemetry extends BaseSampleSourceTelemetry<AvailabilityData> {
private Double samplingPercentage;
Expand All @@ -23,7 +24,6 @@ public final class AvailabilityTelemetry extends BaseSampleSourceTelemetry<Avail

public static final String BASE_TYPE = "AvailabilityData";


/**
* Initializes a new instance of the AvailabilityTelemetry class.
*/
Expand All @@ -38,19 +38,26 @@ public AvailabilityTelemetry() {
}

/**
* Initializes a new instance of the AvailabilityTelemetry class with the given name,
* time stamp, duration, HTTP response code and success property values.
* @param name A user-friendly name for the request.
* @param duration The time of the request.
* @param runLocation The duration, in milliseconds, of the request processing.
* @param message The HTTP response code.
* @param success 'true' if the request was a success, 'false' otherwise.
* Initializes a new instance of the AvailabilityTelemetry class with the given
* name, time stamp, duration, HTTP response code and success property values.
*
* @param name A user-friendly name for the request.
* @param duration The time of the request.
* @param runLocation The duration, in milliseconds, of the request processing.
* @param message The HTTP response code.
* @param success 'true' if the request was a success, 'false' otherwise.
* @param measurements The measurements.
* @param properties The corresponding properties.
* @param properties The corresponding properties.
*/
public AvailabilityTelemetry(String name, Duration duration, String runLocation, String message,
boolean success, ConcurrentMap<String, Double> measurements,
ConcurrentMap<String, String> properties) {
public AvailabilityTelemetry(
String name,
Duration duration,
String runLocation,
String message,
boolean success,
ConcurrentMap<String, Double> measurements,
ConcurrentMap<String, String> properties
) {

this.data = new AvailabilityData();

Expand All @@ -70,9 +77,9 @@ public AvailabilityTelemetry(String name, Duration duration, String runLocation,
setSuccess(success);
}


/**
* Gets the ver value from the data object.
*
* @return The ver value.
*/
@Override
Expand All @@ -82,14 +89,17 @@ public int getVer() {

/**
* Gets a map of application-defined request metrics.
*
* @return The map of metrics
*/
public ConcurrentMap<String, Double> getMetrics() {
return data.getMeasurements();
}

/**
* Sets the StartTime. Uses the default behavior and sets the property on the 'data' start time.
* Sets the StartTime. Uses the default behavior and sets the property on the
* 'data' start time.
*
* @param timestamp The timestamp as Date.
*/
@Override
Expand All @@ -103,6 +113,7 @@ public void setTimestamp(Date timestamp) {

/**
* Gets or human-readable name of the requested page.
*
* @return A human-readable name.
*/
public String getName() {
Expand All @@ -111,6 +122,7 @@ public String getName() {

/**
* Sets or human-readable name of the requested page.
*
* @param name A human-readable name.
*/
public void setName(String name) {
Expand All @@ -119,6 +131,7 @@ public void setName(String name) {

/**
* Gets or human-readable name of the run location.
*
* @return A human-readable name.
*/
public String getRunLocation() {
Expand All @@ -127,6 +140,7 @@ public String getRunLocation() {

/**
* Sets or human-readable name of the run location.
*
* @param runLocation A human-readable name
*/
public void setRunLocation(String runLocation) {
Expand All @@ -135,6 +149,7 @@ public void setRunLocation(String runLocation) {

/**
* Gets the unique identifier of the request.
*
* @return Unique identifier.
*/
public String getId() {
Expand All @@ -143,6 +158,7 @@ public String getId() {

/**
* Sets the unique identifier of the request.
*
* @param id Unique identifier.
*/
public void setId(String id) {
Expand All @@ -151,6 +167,7 @@ public void setId(String id) {

/**
* Gets a value indicating whether application handled the request successfully.
*
* @return Success indication.
*/
public boolean isSuccess() {
Expand All @@ -159,6 +176,7 @@ public boolean isSuccess() {

/**
* Sets a value indicating whether application handled the request successfully.
*
* @param success Success indication.
*/
public void setSuccess(boolean success) {
Expand All @@ -167,6 +185,7 @@ public void setSuccess(boolean success) {

/**
* Gets the amount of time it took the application to handle the request.
*
* @return Amount of time in milliseconds.
*/
public Duration getDuration() {
Expand All @@ -175,7 +194,9 @@ public Duration getDuration() {

/**
* Sets the amount of time it took the application to handle the request.
* @param duration Amount of time in captured in a {@link com.microsoft.applicationinsights.telemetry.Duration}.
*
* @param duration Amount of time in captured in a
* {@link com.microsoft.applicationinsights.telemetry.Duration}.
*/
public void setDuration(Duration duration) {
data.setDuration(duration);
Expand Down Expand Up @@ -214,4 +235,3 @@ public String getBaseTypeName() {
return BASE_TYPE;
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,15 @@ public class TelemetryInitializerMiddleware implements Middleware {

/**
* Initializes a new instance of the {@link TelemetryInitializerMiddleware}.
*
* @param withTelemetryLoggerMiddleware The TelemetryLoggerMiddleware to use.
* @param withLogActivityTelemetry Boolean determining if you want to log telemetry activity
* @param withLogActivityTelemetry Boolean determining if you want to log
* telemetry activity
*/
public TelemetryInitializerMiddleware(TelemetryLoggerMiddleware withTelemetryLoggerMiddleware,
Boolean withLogActivityTelemetry) {
public TelemetryInitializerMiddleware(
TelemetryLoggerMiddleware withTelemetryLoggerMiddleware,
Boolean withLogActivityTelemetry
) {
telemetryLoggerMiddleware = withTelemetryLoggerMiddleware;
if (withLogActivityTelemetry == null) {
withLogActivityTelemetry = true;
Expand All @@ -40,9 +44,11 @@ public TelemetryInitializerMiddleware(TelemetryLoggerMiddleware withTelemetryLog
}

/**
* Stores the incoming activity as JSON in the items collection on the HttpContext.
* Stores the incoming activity as JSON in the items collection on the
* HttpContext.
*
* @param context The incoming TurnContext
* @param next Delegate to run next on
* @param next Delegate to run next on
* @return Returns a CompletableFuture with Void value
*/
public CompletableFuture<Void> onTurn(TurnContext context, NextDelegate next) {
Expand Down Expand Up @@ -71,4 +77,3 @@ public CompletableFuture<Void> onTurn(TurnContext context, NextDelegate next) {
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,21 @@ public void initialize() {
telemetryConfiguration.setChannel(mockTelemetryChannel);
TelemetryClient telemetryClient = new TelemetryClient(telemetryConfiguration);

botTelemetryClient = new BotTelemetryClientImpl(telemetryClient);
botTelemetryClient = new ApplicationInsightsBotTelemetryClient(telemetryClient);
}

@Test
public void nullTelemetryClientThrows() {
Assert.assertThrows(IllegalArgumentException.class, () -> {
new BotTelemetryClientImpl(null);
new ApplicationInsightsBotTelemetryClient(null);
});
}

@Test
public void nonNullTelemetryClientSucceeds() {
TelemetryClient telemetryClient = new TelemetryClient();

BotTelemetryClient botTelemetryClient = new BotTelemetryClientImpl(telemetryClient);
BotTelemetryClient botTelemetryClient = new ApplicationInsightsBotTelemetryClient(telemetryClient);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import java.time.OffsetDateTime;
import java.util.Map;

public class MyBotTelemetryClient extends BotTelemetryClientImpl {
public class MyBotTelemetryClient extends ApplicationInsightsBotTelemetryClient {
public MyBotTelemetryClient(TelemetryClient telemetryClient) {
super(telemetryClient);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ private CosmosDbKeyEscape() {
* means a key of "?test?" would be escaped as "*3ftest*3f".
*/
private static final Map<Character, String> ILLEGAL_KEY_CHARACTER_REPLACEMENT_MAP = Arrays
.stream(ArrayUtils.toObject(ILLEGAL_KEYS))
.collect(Collectors.toMap(c -> c, c -> "*" + String.format("%02x", (int) c)));
.stream(ArrayUtils.toObject(ILLEGAL_KEYS))
.collect(Collectors.toMap(c -> c, c -> "*" + String.format("%02x", (int) c)));

/**
* Converts the key into a DocumentID that can be used safely with Cosmos DB.
Expand Down Expand Up @@ -94,8 +94,8 @@ public static String escapeKey(String key, String suffix, Boolean compatibilityM
// Allocate a builder that assumes that all remaining characters might be
// replaced
// to avoid any extra allocations
StringBuilder sanitizedKeyBuilder = new StringBuilder(
key.length() + ((key.length() - firstIllegalCharIndex) * ESCAPE_LENGTH));
StringBuilder sanitizedKeyBuilder =
new StringBuilder(key.length() + ((key.length() - firstIllegalCharIndex) * ESCAPE_LENGTH));

// Add all good characters up to the first bad character to the builder first
for (Integer index = 0; index < firstIllegalCharIndex; index++) {
Expand Down
Loading

0 comments on commit 9d60e67

Please sign in to comment.