Skip to content

Upgrade AWS dependencies and general code cleanup #78

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
May 29, 2025
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/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # pin@v4
- uses: gradle/wrapper-validation-action@56b90f209b02bf6d1deae490e9ef18b21a389cd4 # pin@v1
- uses: gradle/actions/wrapper-validation@v3
- name: Set up JDK 11
uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # pin@v4
with:
Expand Down
13 changes: 2 additions & 11 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,8 @@ Before we can accept a pull request, you must sign our [Contributor Licensing Ag
Minimally, the [test suite](#testing-guidelines) must pass for us to accept a PR. Ideally, we would love it if you also added appropriate tests if you're implementing a feature!

## Coding Style Guidelines
Our code base is formatted according to the [Google Java Style Guide](https://google.github.io/styleguide/javaguide.html).

The project is configured to use the [google-java-format-gradle-plugin](https://github.com/sherter/google-java-format-gradle-plugin) which can be utilized as follows:

* Execute the task `googleJavaFormat` to format all `*.java` files in the project:

`./gradlew goJF`

* Execute the task `verifyGoogleJavaFormat` to verify that all `*.java` files are formatted properly:

`./gradlew verGJF`
- Use the style provided in `dev-tools/code-style/java-agent-code-style.xml` in the project.
- We encourage you to reduce tech debt you might find in the area. Leave the code better than you found it.

## Testing Guidelines
The AWS Lambda OpenTracing Java SDK comes with tests in `src/test` that can be run with `./gradlew test`.
Expand Down
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,17 @@ This SDK provides Open Tracing instrumentation for AWS Lambda. Releases for this

Versioning will have the following format: {majorVersion}.{minorVersion}.{pointVersion}

### Version 3.0.0

Version 3.0.0 of this library made changes to the versions of AWS dependencies. The following dependencies are now used:
- `com.amazonaws:aws-lambda-java-core:1.2.3` (previous version: 1.1.0)
- `com.amazonaws:aws-lambda-java-events:3.15.0` (previous version: 2.2.7)
- `software.amazon.awssdk:s3:2.31.43` (replaces com.amazonaws:aws-java-sdk-s3:1.12.771)
- `software.amazon.awssdk:s3-event-notifications:2.31.43` (replaces com.amazonaws:aws-java-sdk-s3:1.12.771)

It is recommended that functions that utilize the New Relic AWS Lamdba OpenTracing Java SDK utilize the same (or higher) versions
of the underlying AWS libraries as noted above. Functions that are unable to upgrade should remain on version 2.2.0 of this library.

### Supported OpenTracing Versions

* OpenTracing 0.31.0: [com.newrelic.opentracing:java-aws-lambda:1.0.0](https://mvnrepository.com/artifact/com.newrelic.opentracing/java-aws-lambda/1.0.0)
Expand Down
17 changes: 6 additions & 11 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ buildscript {
}

}
dependencies {
classpath "gradle.plugin.com.github.sherter.google-java-format:google-java-format-gradle-plugin:0.9"
}
}

plugins {
Expand All @@ -25,8 +22,6 @@ java {
withJavadocJar()
}

apply plugin: 'com.github.sherter.google-java-format'

repositories {
mavenCentral()
maven {
Expand All @@ -35,12 +30,12 @@ repositories {
}

dependencies {
implementation 'com.amazonaws:aws-lambda-java-core:1.1.0'
// 2.2.7 is earliest version that has all needed event sources
implementation 'com.amazonaws:aws-lambda-java-events:2.2.7'
implementation 'com.amazonaws:aws-java-sdk-s3:1.12.771'
implementation 'com.amazonaws:aws-java-sdk-kinesis:1.11.163'
implementation 'com.amazonaws:aws-java-sdk-dynamodb:1.11.163'
implementation 'software.amazon.awssdk:s3:2.31.43'
implementation 'software.amazon.awssdk:s3-event-notifications:2.31.43'

implementation 'com.amazonaws:aws-lambda-java-core:1.2.3'
implementation 'com.amazonaws:aws-lambda-java-events:3.15.0'

implementation('io.opentracing:opentracing-api:0.33.0')
implementation('io.opentracing:opentracing-util:0.33.0')
implementation('io.opentracing:opentracing-noop:0.33.0')
Expand Down
32 changes: 32 additions & 0 deletions dev-tools/code-style/java-agent-code-style.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<code_scheme name="java-agent">
<option name="CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND" value="999" />
<option name="NAMES_COUNT_TO_USE_IMPORT_ON_DEMAND" value="999" />
<option name="RIGHT_MARGIN" value="160" />
<option name="JD_ALIGN_PARAM_COMMENTS" value="false" />
<option name="JD_ALIGN_EXCEPTION_COMMENTS" value="false" />
<option name="JD_P_AT_EMPTY_LINES" value="false" />
<codeStyleSettings language="JAVA">
<option name="KEEP_BLANK_LINES_IN_DECLARATIONS" value="1" />
<option name="KEEP_BLANK_LINES_IN_CODE" value="1" />
<option name="KEEP_BLANK_LINES_BEFORE_RBRACE" value="1" />
<option name="ALIGN_MULTILINE_PARAMETERS" value="false" />
<option name="SPACE_WITHIN_ARRAY_INITIALIZER_BRACES" value="true" />
<option name="SPACE_BEFORE_ARRAY_INITIALIZER_LBRACE" value="true" />
<option name="CALL_PARAMETERS_WRAP" value="1" />
<option name="METHOD_PARAMETERS_WRAP" value="1" />
<option name="RESOURCE_LIST_WRAP" value="1" />
<option name="EXTENDS_LIST_WRAP" value="1" />
<option name="THROWS_LIST_WRAP" value="1" />
<option name="EXTENDS_KEYWORD_WRAP" value="1" />
<option name="THROWS_KEYWORD_WRAP" value="1" />
<option name="METHOD_CALL_CHAIN_WRAP" value="5" />
<option name="BINARY_OPERATION_WRAP" value="1" />
<option name="TERNARY_OPERATION_WRAP" value="5" />
<option name="ARRAY_INITIALIZER_WRAP" value="1" />
<option name="IF_BRACE_FORCE" value="3" />
<option name="DOWHILE_BRACE_FORCE" value="3" />
<option name="WHILE_BRACE_FORCE" value="3" />
<option name="FOR_BRACE_FORCE" value="3" />
<option name="VARIABLE_ANNOTATION_WRAP" value="2" />
</codeStyleSettings>
</code_scheme>
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
group = com.newrelic.opentracing
version = 2.3.0
version = 3.0.0
104 changes: 55 additions & 49 deletions src/main/java/com/newrelic/opentracing/aws/EnhancedSpanBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,66 +10,72 @@
import io.opentracing.Tracer;

public class EnhancedSpanBuilder {
private final Tracer.SpanBuilder spanBuilder;
private final Tracer.SpanBuilder spanBuilder;

public static EnhancedSpanBuilder basedOn(Tracer tracer, String operationName) {
return new EnhancedSpanBuilder(tracer.buildSpan(operationName));
}
public static EnhancedSpanBuilder basedOn(Tracer tracer, String operationName) {
return new EnhancedSpanBuilder(tracer.buildSpan(operationName));
}

private EnhancedSpanBuilder(Tracer.SpanBuilder innerSpanBuilder) {
spanBuilder = innerSpanBuilder;
}
private EnhancedSpanBuilder(Tracer.SpanBuilder innerSpanBuilder) {
spanBuilder = innerSpanBuilder;
}

public EnhancedSpanBuilder asChildOf(SpanContext spanContext) {
this.spanBuilder.asChildOf(spanContext);
return this;
}
public EnhancedSpanBuilder asChildOf(SpanContext spanContext) {
this.spanBuilder.asChildOf(spanContext);
return this;
}

/** Same as {@link Span#setTag(String, String)}, but for the span to be built. */
EnhancedSpanBuilder withTag(String key, String value) {
this.spanBuilder.withTag(key, value);
return this;
}
/**
* Same as {@link Span#setTag(String, String)}, but for the span to be built.
*/
EnhancedSpanBuilder withTag(String key, String value) {
this.spanBuilder.withTag(key, value);
return this;
}

/** Same as {@link Span#setTag(String, boolean)}, but for the span to be built. */
EnhancedSpanBuilder withTag(String key, boolean value) {
this.spanBuilder.withTag(key, value);
return this;
}
/**
* Same as {@link Span#setTag(String, boolean)}, but for the span to be built.
*/
EnhancedSpanBuilder withTag(String key, boolean value) {
this.spanBuilder.withTag(key, value);
return this;
}

/** Same as {@link Span#setTag(String, Number)}, but for the span to be built. */
EnhancedSpanBuilder withTag(String key, Number value) {
this.spanBuilder.withTag(key, value);
return this;
}
/**
* Same as {@link Span#setTag(String, Number)}, but for the span to be built.
*/
EnhancedSpanBuilder withTag(String key, Number value) {
this.spanBuilder.withTag(key, value);
return this;
}

/**
* A shorthand for withTag("key", "value").
*
* <p>If parent==null, this is a noop.
*/
EnhancedSpanBuilder optionallyWithTag(String key, String value) {
if (value != null) {
this.spanBuilder.withTag(key, value);
/**
* A shorthand for withTag("key", "value").
*
* <p>If parent==null, this is a noop.
*/
EnhancedSpanBuilder optionallyWithTag(String key, String value) {
if (value != null) {
this.spanBuilder.withTag(key, value);
}
return this;
}
return this;
}

EnhancedSpanBuilder optionallyWithTag(String key, boolean value) {
if (value) {
this.spanBuilder.withTag(key, true);
EnhancedSpanBuilder optionallyWithTag(String key, boolean value) {
if (value) {
this.spanBuilder.withTag(key, true);
}
return this;
}
return this;
}

EnhancedSpanBuilder optionallyWithTag(String key, Number value) {
if (value != null) {
this.spanBuilder.withTag(key, value);
EnhancedSpanBuilder optionallyWithTag(String key, Number value) {
if (value != null) {
this.spanBuilder.withTag(key, value);
}
return this;
}
return this;
}

public Span start() {
return this.spanBuilder.start();
}
public Span start() {
return this.spanBuilder.start();
}
}
Loading
Loading