Skip to content

fix(general): clean up typos and code #62

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

Merged
merged 4 commits into from
Sep 1, 2020
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@ assignees: ''

> [How to enable debug mode](https://awslabs.github.io/aws-lambda-powertools-java/#debug-mode)**

```java
```text
# paste logs here
```
2 changes: 1 addition & 1 deletion docs/content/core/tracing.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public class App implements RequestHandler<APIGatewayProxyRequestEvent, APIGatew
Entity traceEntity = AWSXRay.getTraceEntity();

Thread anotherThread = new Thread(() -> withEntitySubsegment("inlineLog", traceEntity, subsegment -> {
// Business logic in sperate thread
// Business logic in separate thread
}));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,30 +13,34 @@
*/
package software.amazon.lambda.powertools.core.internal;

import java.io.InputStream;
import java.io.OutputStream;

import com.amazonaws.services.lambda.runtime.Context;
import com.amazonaws.services.lambda.runtime.RequestHandler;
import com.amazonaws.services.lambda.runtime.RequestStreamHandler;
import org.aspectj.lang.ProceedingJoinPoint;

import java.io.InputStream;
import java.io.OutputStream;

public final class LambdaHandlerProcessor {
private static String SERVICE_NAME = null != System.getenv("POWERTOOLS_SERVICE_NAME")
? System.getenv("POWERTOOLS_SERVICE_NAME") : "service_undefined";
private static Boolean IS_COLD_START = null;

public static boolean isHandlerMethod(ProceedingJoinPoint pjp) {
private LambdaHandlerProcessor() {
// Hide default constructor
}

public static boolean isHandlerMethod(final ProceedingJoinPoint pjp) {
return "handleRequest".equals(pjp.getSignature().getName());
}

public static boolean placedOnRequestHandler(ProceedingJoinPoint pjp) {
public static boolean placedOnRequestHandler(final ProceedingJoinPoint pjp) {
return RequestHandler.class.isAssignableFrom(pjp.getSignature().getDeclaringType())
&& pjp.getArgs().length == 2
&& pjp.getArgs()[1] instanceof Context;
}

public static boolean placedOnStreamHandler(ProceedingJoinPoint pjp) {
public static boolean placedOnStreamHandler(final ProceedingJoinPoint pjp) {
return RequestStreamHandler.class.isAssignableFrom(pjp.getSignature().getDeclaringType())
&& pjp.getArgs().length == 3
&& pjp.getArgs()[0] instanceof InputStream
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,10 @@
*/
package org.apache.logging.log4j.core.layout;

import java.io.IOException;
import java.io.Writer;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;

import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonGetter;
import com.fasterxml.jackson.annotation.JsonRootName;
import com.fasterxml.jackson.annotation.JsonUnwrapped;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.logging.log4j.core.Layout;
import org.apache.logging.log4j.core.LogEvent;
import org.apache.logging.log4j.core.config.Configuration;
Expand All @@ -36,11 +25,20 @@
import org.apache.logging.log4j.core.config.plugins.Plugin;
import org.apache.logging.log4j.core.config.plugins.PluginBuilderAttribute;
import org.apache.logging.log4j.core.config.plugins.PluginBuilderFactory;
import org.apache.logging.log4j.core.jackson.Log4jJsonObjectMapper;
import org.apache.logging.log4j.core.jackson.XmlConstants;
import org.apache.logging.log4j.core.util.KeyValuePair;
import org.apache.logging.log4j.util.Strings;

import java.io.IOException;
import java.io.Writer;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;

import static java.time.Instant.ofEpochMilli;
import static java.time.format.DateTimeFormatter.ISO_ZONED_DATE_TIME;

Expand All @@ -52,8 +50,6 @@ public class LambdaJsonLayout extends AbstractJacksonLayout {

static final String CONTENT_TYPE = "application/json";

private final ObjectMapper objectMapper;

public static class Builder<B extends Builder<B>> extends AbstractJacksonLayout.Builder<B>
implements org.apache.logging.log4j.core.util.Builder<LambdaJsonLayout> {

Expand Down Expand Up @@ -113,7 +109,6 @@ private LambdaJsonLayout(final Configuration config, final boolean locationInfo,
PatternLayout.newSerializerBuilder().setConfiguration(config).setPattern(footerPattern).setDefaultPattern(DEFAULT_FOOTER).build(),
includeNullDelimiter,
additionalFields);
this.objectMapper = new Log4jJsonObjectMapper(encodeThreadContextAsList, includeStacktrace, stacktraceAsString, objectMessageAsJsonObject);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
* <p>By default {@code PowertoolsLogging} will not log the event which has trigger the invoke of the Lambda function.
* This can be enabled using {@code @PowertoolsLogging(logEvent = true)}.</p>
*
* <p>By default {@code PowertoolsLogging} all debug loggs will follow log4j2 configuration unless configured via
* <p>By default {@code PowertoolsLogging} all debug logs will follow log4j2 configuration unless configured via
* POWERTOOLS_LOGGER_SAMPLE_RATE environment variable {@code @PowertoolsLogging(samplingRate = <0.0-1.0>)}.</p>
*
* <p>To append additional keys to each log entry you can use {@link PowertoolsLogger#appendKey(String, String)}</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import com.amazonaws.services.lambda.runtime.Context;
import com.amazonaws.services.lambda.runtime.RequestHandler;
import com.amazonaws.services.lambda.runtime.events.APIGatewayProxyRequestEvent;
import com.amazonaws.services.lambda.runtime.events.APIGatewayProxyResponseEvent;
import software.amazon.lambda.powertools.sqs.LargeMessageHandler;

public class LambdaHandlerApiGateway implements RequestHandler<APIGatewayProxyRequestEvent, String> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
* <p>By default {@code PowertoolsTracing} will capture responses and add them
* to a sub segment named after the method.</p>
*
* <p>To disable this functionality you can specify {@code @PowertoolsTracing( captureRespones = false)}</p>
* <p>To disable this functionality you can specify {@code @PowertoolsTracing( captureResponse = false)}</p>
*
* <p>By default {@code PowertoolsTracing} will capture errors and add them
* to a sub segment named after the method.</p>
Expand Down