Skip to content

feat: remove deprecated attributes on Tracing annotation #347

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

Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@
* <p>By default {@code Tracing} will capture responses and add them
* to a sub segment named after the method.</p>
*
* <p>To disable this functionality you can specify {@code @Tracing( captureResponse = false)}</p>
* <p>To disable this functionality you can specify {@code @Tracing( captureMode = CaptureMode.DISABLED)}</p>
*
* <p>By default {@code Tracing} will capture errors and add them
* to a sub segment named after the method.</p>
*
* <p>To disable this functionality you can specify {@code @Tracing( captureError = false)}</p>
* <p>To disable this functionality you can specify {@code @Tracing( captureMode = CaptureMode.DISABLED)}</p>
*e
* <p>All traces have a namespace set. If {@code @Tracing( namespace = "ExampleService")} is set
* this takes precedent over any value set in the environment variable {@code POWER_TOOLS_SERVICE_NAME}.
Expand All @@ -48,20 +48,6 @@
@Target(ElementType.METHOD)
public @interface Tracing {
String namespace() default "";
/**
* @deprecated As of release 1.2.0, replaced by captureMode()
* in order to support different modes and support via
* environment variables
*/
@Deprecated
boolean captureResponse() default true;
/**
* @deprecated As of release 1.2.0, replaced by captureMode()
* in order to support different modes and support via
* environment variables
*/
@Deprecated
boolean captureError() default true;
String segmentName() default "";
CaptureMode captureMode() default CaptureMode.ENVIRONMENT_VAR;
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ private boolean captureResponse(Tracing powerToolsTracing) {
switch (powerToolsTracing.captureMode()) {
case ENVIRONMENT_VAR:
boolean captureResponse = environmentVariable("POWERTOOLS_TRACER_CAPTURE_RESPONSE");
return isEnvironmentVariableSet("POWERTOOLS_TRACER_CAPTURE_RESPONSE") ? captureResponse : powerToolsTracing.captureResponse();
return !isEnvironmentVariableSet("POWERTOOLS_TRACER_CAPTURE_RESPONSE") || captureResponse;
case RESPONSE:
case RESPONSE_AND_ERROR:
return true;
Expand All @@ -93,7 +93,7 @@ private boolean captureError(Tracing powerToolsTracing) {
switch (powerToolsTracing.captureMode()) {
case ENVIRONMENT_VAR:
boolean captureError = environmentVariable("POWERTOOLS_TRACER_CAPTURE_ERROR");
return isEnvironmentVariableSet("POWERTOOLS_TRACER_CAPTURE_ERROR") ? captureError : powerToolsTracing.captureError();
return !isEnvironmentVariableSet("POWERTOOLS_TRACER_CAPTURE_ERROR") || captureError;
case ERROR:
case RESPONSE_AND_ERROR:
return true;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
import software.amazon.lambda.powertools.tracing.handlers.PowerTracerToolEnabledForStreamWithNoMetaData;
import software.amazon.lambda.powertools.tracing.handlers.PowerTracerToolEnabledWithException;
import software.amazon.lambda.powertools.tracing.handlers.PowerTracerToolEnabledWithNoMetaData;
import software.amazon.lambda.powertools.tracing.handlers.PowerTracerToolEnabledWithNoMetaDataDeprecated;
import software.amazon.lambda.powertools.tracing.nonhandler.PowerToolNonHandler;

import static org.apache.commons.lang3.reflect.FieldUtils.writeStaticField;
Expand Down Expand Up @@ -208,24 +207,6 @@ void shouldCaptureTracesForStreamWithNoMetadata() throws IOException {
});
}

@Test
void shouldCaptureTracesWithNoMetadataDeprecated() {
requestHandler = new PowerTracerToolEnabledWithNoMetaDataDeprecated();

requestHandler.handleRequest(new Object(), context);

assertThat(AWSXRay.getTraceEntity().getSubsegments())
.hasSize(1)
.allSatisfy(subsegment -> {
assertThat(subsegment.getAnnotations())
.hasSize(1)
.containsEntry("ColdStart", true);

assertThat(subsegment.getMetadata())
.isEmpty();
});
}

@Test
void shouldNotCaptureTracesIfDisabledViaEnvironmentVariable() {
try (MockedStatic<SystemWrapper> mocked = mockStatic(SystemWrapper.class)) {
Expand Down