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

Use Spotless for formatting #1619

Merged
merged 7 commits into from
Jun 23, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Apply spotless to existing Java classes.
  • Loading branch information
tylerbenson committed Jun 19, 2020
commit 28b11ff734ab13a7d7a5e8e76c53e0ce27a3b362
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ public static Multimap<String, Object> parseProfilingRequestParameters(
}

public static Map<String, String> parseTags(final Collection<Object> params) {
return params
.stream()
return params.stream()
.map(p -> ((String) p).split(":", 2))
.collect(Collectors.toMap(p -> p[0], p -> p[1]));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -376,8 +376,7 @@ private boolean canEnqueueMoreRequests() {
}

private List<String> tagsToList(final Map<String, String> tags) {
return tags.entrySet()
.stream()
return tags.entrySet().stream()
.filter(e -> e.getValue() != null && !e.getValue().isEmpty())
.map(e -> e.getKey() + ":" + e.getValue())
.collect(Collectors.toList());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@

import datadog.trace.bootstrap.instrumentation.api.AgentScope;
import datadog.trace.bootstrap.instrumentation.api.AgentSpan;
import java.util.function.Consumer;

import datadog.trace.bootstrap.instrumentation.api.InstrumentationTags;
import java.util.function.Consumer;
import software.amazon.awssdk.core.client.builder.SdkClientBuilder;
import software.amazon.awssdk.core.client.config.ClientOverrideConfiguration;
import software.amazon.awssdk.core.interceptor.Context;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
package com.datadog.profiling.exceptions;

import datadog.trace.api.Config;
import jdk.jfr.EventType;
import jdk.jfr.FlightRecorder;
import lombok.extern.slf4j.Slf4j;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.LongAdder;
import java.util.stream.Stream;
import jdk.jfr.EventType;
import jdk.jfr.FlightRecorder;
import lombok.extern.slf4j.Slf4j;

/**
* A simple exception type histogram implementation.<br>
* It tracks a fixed number of exception types and for each of them it keeps the number of instances created since
* the last {@linkplain ExceptionHistogram#emit()} call (or creating a new {@linkplain ExceptionHistogram} instance
* if {@linkplain ExceptionHistogram#emit()} hasn't been called yet).<br>
*
* An {@linkplain ExceptionHistogram} instance is registered with JFR to call {@linkplain ExceptionHistogram#emit()}
* method at chunk end, as specified in {@linkplain ExceptionCountEvent} class. This callback will then emit a number
* of {@linkplain ExceptionCountEvent} events.
* It tracks a fixed number of exception types and for each of them it keeps the number of instances
* created since the last {@linkplain ExceptionHistogram#emit()} call (or creating a new {@linkplain
* ExceptionHistogram} instance if {@linkplain ExceptionHistogram#emit()} hasn't been called yet).
* <br>
* An {@linkplain ExceptionHistogram} instance is registered with JFR to call {@linkplain
* ExceptionHistogram#emit()} method at chunk end, as specified in {@linkplain ExceptionCountEvent}
* class. This callback will then emit a number of {@linkplain ExceptionCountEvent} events.
*/
@Slf4j
public class ExceptionHistogram {
Expand All @@ -40,17 +38,17 @@ public class ExceptionHistogram {
FlightRecorder.addPeriodicEvent(ExceptionCountEvent.class, eventHook);
}

/**
* Remove this instance from JFR periodic events callbacks
*/
/** Remove this instance from JFR periodic events callbacks */
void deregister() {
FlightRecorder.removePeriodicEvent(eventHook);
}

/**
* Record a new exception instance
*
* @param exception instance
* @return {@literal true} if this is the first record of the given exception type; {@literal false} otherwise
* @return {@literal true} if this is the first record of the given exception type; {@literal
* false} otherwise
*/
public boolean record(final Throwable exception) {
if (exception == null) {
Expand All @@ -69,12 +67,7 @@ private boolean record(String typeName) {
typeName = CLIPPED_ENTRY_TYPE_NAME;
}

long count = histogram
.computeIfAbsent(
typeName,
k -> new AtomicLong()
)
.getAndIncrement();
long count = histogram.computeIfAbsent(typeName, k -> new AtomicLong()).getAndIncrement();

/*
* This is supposed to signal that a particular exception type was seen the first time in a particular time span.
Expand All @@ -94,12 +87,10 @@ private void emit() {

void doEmit() {
Stream<Pair<String, Long>> items =
histogram
.entrySet()
.stream()
.map(e -> Pair.of(e.getKey(), e.getValue().getAndSet(0)))
.filter(p -> p.getValue() != 0)
.sorted((l1, l2) -> Long.compare(l2.getValue(), l1.getValue()));
histogram.entrySet().stream()
.map(e -> Pair.of(e.getKey(), e.getValue().getAndSet(0)))
.filter(p -> p.getValue() != 0)
.sorted((l1, l2) -> Long.compare(l2.getValue(), l1.getValue()));

if (maxTopItems > 0) {
items = items.limit(maxTopItems);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
* spectrum, there will be to few incoming events and the sampler will not be able to generate the
* target number of samples.
*
* <p>To smooth out these hicups the sampler maintains an under-sampling budget which can be used
* to compensate for too rapid changes in the incoming events rate and maintain the target average
* <p>To smooth out these hicups the sampler maintains an under-sampling budget which can be used to
* compensate for too rapid changes in the incoming events rate and maintain the target average
* number of samples per window.
*/
class StreamingSampler {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package datadog.exceptions.instrumentation;

/**
* A simple utility class to provide re-entrancy guard support
*/
/** A simple utility class to provide re-entrancy guard support */
public final class ThrowableInstanceAdviceHelper {
private static final ThreadLocal<Boolean> enteredFlag = ThreadLocal.withInitial(() -> false);

/**
* Try to enter 'handler' code
* @return {@literal true} if the handler hasn't been entered yet on this thread, {@literal false} otherwise
*
* @return {@literal true} if the handler hasn't been entered yet on this thread, {@literal false}
* otherwise
*/
public static boolean enterHandler() {
if (enteredFlag.get()) {
Expand All @@ -18,10 +18,7 @@ public static boolean enterHandler() {
return true;
}

/**
* Exit the 'handler' code.
* Should be always called in finally block of the handler.
*/
/** Exit the 'handler' code. Should be always called in finally block of the handler. */
public static void exitHandler() {
enteredFlag.remove();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.activeScope;
import static datadog.trace.instrumentation.play24.PlayHttpServerDecorator.DECORATE;

import datadog.trace.context.TraceScope;
import datadog.trace.bootstrap.instrumentation.api.AgentSpan;
import datadog.trace.context.TraceScope;
import lombok.extern.slf4j.Slf4j;
import play.api.mvc.Result;
import scala.util.Try;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.activeScope;
import static datadog.trace.instrumentation.play26.PlayHttpServerDecorator.DECORATE;

import datadog.trace.context.TraceScope;
import datadog.trace.bootstrap.instrumentation.api.AgentSpan;
import datadog.trace.context.TraceScope;
import lombok.extern.slf4j.Slf4j;
import play.api.mvc.Result;
import scala.util.Try;
Expand Down