Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.hasClassesNamed;
import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.implementsInterface;
import static io.opentelemetry.javaagent.instrumentation.awslambdacore.v1_0.AwsLambdaInstrumentationHelper.flushTimeout;
import static io.opentelemetry.javaagent.instrumentation.awslambdacore.v1_0.AwsLambdaInstrumentationHelper.functionInstrumenter;
import static io.opentelemetry.javaagent.instrumentation.awslambdacore.v1_0.AwsLambdaSingletons.flushTimeout;
import static io.opentelemetry.javaagent.instrumentation.awslambdacore.v1_0.AwsLambdaSingletons.functionInstrumenter;
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
import static net.bytebuddy.matcher.ElementMatchers.isPublic;
import static net.bytebuddy.matcher.ElementMatchers.nameStartsWith;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.hasClassesNamed;
import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.implementsInterface;
import static io.opentelemetry.javaagent.instrumentation.awslambdacore.v1_0.AwsLambdaInstrumentationHelper.flushTimeout;
import static io.opentelemetry.javaagent.instrumentation.awslambdacore.v1_0.AwsLambdaInstrumentationHelper.functionInstrumenter;
import static io.opentelemetry.javaagent.instrumentation.awslambdacore.v1_0.AwsLambdaSingletons.flushTimeout;
import static io.opentelemetry.javaagent.instrumentation.awslambdacore.v1_0.AwsLambdaSingletons.functionInstrumenter;
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
import static net.bytebuddy.matcher.ElementMatchers.isPublic;
import static net.bytebuddy.matcher.ElementMatchers.nameStartsWith;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import io.opentelemetry.javaagent.bootstrap.internal.AgentInstrumentationConfig;
import java.time.Duration;

public final class AwsLambdaInstrumentationHelper {
public final class AwsLambdaSingletons {

private static final AwsLambdaFunctionInstrumenter FUNCTION_INSTRUMENTER =
AwsLambdaFunctionInstrumenterFactory.createInstrumenter(GlobalOpenTelemetry.get());
Expand All @@ -31,5 +31,5 @@ public static Duration flushTimeout() {
return FLUSH_TIMEOUT;
}

private AwsLambdaInstrumentationHelper() {}
private AwsLambdaSingletons() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@
import org.mockito.junit.jupiter.MockitoExtension;

@ExtendWith(MockitoExtension.class)
public class AwsLambdaStreamHandlerTest {
class AwsLambdaStreamHandlerTest {

@RegisterExtension
public static final InstrumentationExtension testing = AgentInstrumentationExtension.create();
static final InstrumentationExtension testing = AgentInstrumentationExtension.create();

@Mock private Context context;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

public class AwsLambdaTest extends AbstractAwsLambdaTest {
class AwsLambdaTest extends AbstractAwsLambdaTest {

@RegisterExtension
public static final InstrumentationExtension testing = AgentInstrumentationExtension.create();
static final InstrumentationExtension testing = AgentInstrumentationExtension.create();

@Override
protected RequestHandler<String, String> handler() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@
key = WrappedLambda.OTEL_LAMBDA_HANDLER_ENV_KEY,
value =
"io.opentelemetry.instrumentation.awslambdacore.v1_0.AwsLambdaStreamWrapperHttpPropagationTest$TestRequestHandler::handleRequest")
public class AwsLambdaStreamWrapperHttpPropagationTest {
class AwsLambdaStreamWrapperHttpPropagationTest {

@RegisterExtension
public static final InstrumentationExtension testing = LibraryInstrumentationExtension.create();
static final InstrumentationExtension testing = LibraryInstrumentationExtension.create();

@Mock private Context context;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@
key = WrappedLambda.OTEL_LAMBDA_HANDLER_ENV_KEY,
value =
"io.opentelemetry.instrumentation.awslambdacore.v1_0.AwsLambdaStreamWrapperTest$TestRequestHandler::handleRequest")
public class AwsLambdaStreamWrapperTest {
class AwsLambdaStreamWrapperTest {

@RegisterExtension
public static final InstrumentationExtension testing = LibraryInstrumentationExtension.create();
static final InstrumentationExtension testing = LibraryInstrumentationExtension.create();

@Mock private Context context;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
import io.opentelemetry.sdk.OpenTelemetrySdk;
import org.junit.jupiter.api.extension.RegisterExtension;

public class AwsLambdaTest extends AbstractAwsLambdaTest {
class AwsLambdaTest extends AbstractAwsLambdaTest {

@RegisterExtension
public static final InstrumentationExtension testing = LibraryInstrumentationExtension.create();
static final InstrumentationExtension testing = LibraryInstrumentationExtension.create();

@Override
protected RequestHandler<String, String> handler() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ void resetOpenTelemetry() {
}

@Test
public void shouldCreateNoopRequestIfNoPropagatorsSet() throws IOException {
void shouldCreateNoopRequestIfNoPropagatorsSet() throws IOException {
// given
InputStream mock = mock(InputStream.class);
GlobalOpenTelemetry.set(OpenTelemetry.noop());
Expand All @@ -42,7 +42,7 @@ public void shouldCreateNoopRequestIfNoPropagatorsSet() throws IOException {
}

@Test
public void shouldCreateNoopRequestIfXrayPropagatorsSet() throws IOException {
void shouldCreateNoopRequestIfXrayPropagatorsSet() throws IOException {
// given
InputStream mock = mock(InputStream.class);
GlobalOpenTelemetry.set(
Expand All @@ -55,7 +55,7 @@ public void shouldCreateNoopRequestIfXrayPropagatorsSet() throws IOException {
}

@Test
public void shouldUseStreamMarkingIfHttpPropagatorsSet() throws IOException {
void shouldUseStreamMarkingIfHttpPropagatorsSet() throws IOException {
// given
InputStream mock = mock(InputStream.class);
when(mock.markSupported()).thenReturn(true);
Expand All @@ -70,7 +70,7 @@ public void shouldUseStreamMarkingIfHttpPropagatorsSet() throws IOException {
}

@Test
public void shouldUseNoopIfMarkingNotAvailableAndHttpPropagatorsSet() throws IOException {
void shouldUseNoopIfMarkingNotAvailableAndHttpPropagatorsSet() throws IOException {
// given
InputStream mock = mock(InputStream.class);
when(mock.markSupported()).thenReturn(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
class HeadersFactoryTest {

@Test
public void shouldReadHeadersFromStream() {
void shouldReadHeadersFromStream() {
// given
String json =
"{"
Expand All @@ -40,7 +40,7 @@ public void shouldReadHeadersFromStream() {
}

@Test
public void shouldReturnNullIfNoHeadersInStream() {
void shouldReturnNullIfNoHeadersInStream() {
// given
String json = "{\"something\" : \"else\"}";
InputStream inputStream = new ByteArrayInputStream(json.getBytes(Charset.defaultCharset()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

class InstrumenterExtractionTest {
@Test
public void useCustomContext() {
void useCustomContext() {
AwsLambdaFunctionInstrumenter instr =
AwsLambdaFunctionInstrumenterFactory.createInstrumenter(
OpenTelemetry.propagating(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.hasClassesNamed;
import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.implementsInterface;
import static io.opentelemetry.javaagent.instrumentation.awslambdaevents.v2_2.AwsLambdaInstrumentationHelper.flushTimeout;
import static io.opentelemetry.javaagent.instrumentation.awslambdaevents.v2_2.AwsLambdaSingletons.flushTimeout;
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
import static net.bytebuddy.matcher.ElementMatchers.isPublic;
import static net.bytebuddy.matcher.ElementMatchers.named;
Expand Down Expand Up @@ -70,23 +70,20 @@ public static void onEnter(
}
input = AwsLambdaRequest.create(context, arg, headers);
io.opentelemetry.context.Context parentContext =
AwsLambdaInstrumentationHelper.functionInstrumenter().extract(input);
AwsLambdaSingletons.functionInstrumenter().extract(input);

if (!AwsLambdaInstrumentationHelper.functionInstrumenter()
.shouldStart(parentContext, input)) {
if (!AwsLambdaSingletons.functionInstrumenter().shouldStart(parentContext, input)) {
return;
}

functionContext =
AwsLambdaInstrumentationHelper.functionInstrumenter().start(parentContext, input);
functionContext = AwsLambdaSingletons.functionInstrumenter().start(parentContext, input);
functionScope = functionContext.makeCurrent();

if (arg instanceof SQSEvent) {
if (AwsLambdaInstrumentationHelper.messageInstrumenter()
if (AwsLambdaSingletons.messageInstrumenter()
.shouldStart(functionContext, (SQSEvent) arg)) {
messageContext =
AwsLambdaInstrumentationHelper.messageInstrumenter()
.start(functionContext, (SQSEvent) arg);
AwsLambdaSingletons.messageInstrumenter().start(functionContext, (SQSEvent) arg);
messageScope = messageContext.makeCurrent();
}
}
Expand All @@ -105,14 +102,13 @@ public static void stopSpan(

if (messageScope != null) {
messageScope.close();
AwsLambdaInstrumentationHelper.messageInstrumenter()
AwsLambdaSingletons.messageInstrumenter()
.end(messageContext, (SQSEvent) arg, null, throwable);
}

if (functionScope != null) {
functionScope.close();
AwsLambdaInstrumentationHelper.functionInstrumenter()
.end(functionContext, input, result, throwable);
AwsLambdaSingletons.functionInstrumenter().end(functionContext, input, result, throwable);
}

OpenTelemetrySdkAccess.forceFlush(flushTimeout().toNanos(), TimeUnit.NANOSECONDS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.hasClassesNamed;
import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.implementsInterface;
import static io.opentelemetry.javaagent.instrumentation.awslambdaevents.v2_2.AwsLambdaInstrumentationHelper.flushTimeout;
import static io.opentelemetry.javaagent.instrumentation.awslambdaevents.v2_2.AwsLambdaSingletons.flushTimeout;
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
import static net.bytebuddy.matcher.ElementMatchers.isPublic;
import static net.bytebuddy.matcher.ElementMatchers.named;
Expand Down Expand Up @@ -62,15 +62,13 @@ public static void onEnter(
Map<String, String> headers = Collections.emptyMap();
otelInput = AwsLambdaRequest.create(context, input, headers);
io.opentelemetry.context.Context parentContext =
AwsLambdaInstrumentationHelper.functionInstrumenter().extract(otelInput);
AwsLambdaSingletons.functionInstrumenter().extract(otelInput);

if (!AwsLambdaInstrumentationHelper.functionInstrumenter()
.shouldStart(parentContext, otelInput)) {
if (!AwsLambdaSingletons.functionInstrumenter().shouldStart(parentContext, otelInput)) {
return;
}

otelContext =
AwsLambdaInstrumentationHelper.functionInstrumenter().start(parentContext, otelInput);
otelContext = AwsLambdaSingletons.functionInstrumenter().start(parentContext, otelInput);
otelScope = otelContext.makeCurrent();
}

Expand All @@ -82,8 +80,7 @@ public static void stopSpan(
@Advice.Local("otelScope") Scope functionScope) {
if (functionScope != null) {
functionScope.close();
AwsLambdaInstrumentationHelper.functionInstrumenter()
.end(functionContext, input, null, throwable);
AwsLambdaSingletons.functionInstrumenter().end(functionContext, input, null, throwable);
}

OpenTelemetrySdkAccess.forceFlush(flushTimeout().toNanos(), TimeUnit.NANOSECONDS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import io.opentelemetry.javaagent.bootstrap.internal.AgentInstrumentationConfig;
import java.time.Duration;

public final class AwsLambdaInstrumentationHelper {
public final class AwsLambdaSingletons {

private static final AwsLambdaFunctionInstrumenter FUNCTION_INSTRUMENTER =
AwsLambdaEventsInstrumenterFactory.createInstrumenter(
Expand All @@ -42,5 +42,5 @@ public static Duration flushTimeout() {
return FLUSH_TIMEOUT;
}

private AwsLambdaInstrumentationHelper() {}
private AwsLambdaSingletons() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@

@ExtendWith(MockitoExtension.class)
@MockitoSettings(strictness = Strictness.LENIENT)
public class AwsLambdaApiGatewayHandlerTest {
class AwsLambdaApiGatewayHandlerTest {

@RegisterExtension
public static final InstrumentationExtension testing = AgentInstrumentationExtension.create();
static final InstrumentationExtension testing = AgentInstrumentationExtension.create();

@Mock private Context context;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension;
import org.junit.jupiter.api.extension.RegisterExtension;

public class AwsLambdaSqsEventHandlerTest extends AbstractAwsLambdaSqsEventHandlerTest {
class AwsLambdaSqsEventHandlerTest extends AbstractAwsLambdaSqsEventHandlerTest {

@RegisterExtension
public static final InstrumentationExtension testing = AgentInstrumentationExtension.create();
static final InstrumentationExtension testing = AgentInstrumentationExtension.create();

@Override
protected RequestHandler<SQSEvent, Void> handler() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@
import org.mockito.junit.jupiter.MockitoExtension;

@ExtendWith(MockitoExtension.class)
public class AwsLambdaStreamHandlerTest {
class AwsLambdaStreamHandlerTest {

@RegisterExtension
public static final InstrumentationExtension testing = AgentInstrumentationExtension.create();
static final InstrumentationExtension testing = AgentInstrumentationExtension.create();

@Mock private Context context;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@

@ExtendWith(MockitoExtension.class)
@MockitoSettings(strictness = Strictness.LENIENT)
public class AwsLambdaApiGatewayWrapperTest {
class AwsLambdaApiGatewayWrapperTest {

@RegisterExtension
public static final InstrumentationExtension testing = LibraryInstrumentationExtension.create();
static final InstrumentationExtension testing = LibraryInstrumentationExtension.create();

@Mock private Context context;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
import io.opentelemetry.sdk.OpenTelemetrySdk;
import org.junit.jupiter.api.extension.RegisterExtension;

public class AwsLambdaSqsEventHandlerTest extends AbstractAwsLambdaSqsEventHandlerTest {
class AwsLambdaSqsEventHandlerTest extends AbstractAwsLambdaSqsEventHandlerTest {

@RegisterExtension
public static final InstrumentationExtension testing = LibraryInstrumentationExtension.create();
static final InstrumentationExtension testing = LibraryInstrumentationExtension.create();

@Override
protected RequestHandler<SQSEvent, Void> handler() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@
key = WrappedLambda.OTEL_LAMBDA_HANDLER_ENV_KEY,
value =
"io.opentelemetry.instrumentation.awslambdaevents.v2_2.AwsLambdaSqsEventWrapperTest$TestRequestHandler::handleRequest")
public class AwsLambdaSqsEventWrapperTest {
class AwsLambdaSqsEventWrapperTest {

@RegisterExtension
public static final InstrumentationExtension testing = LibraryInstrumentationExtension.create();
static final InstrumentationExtension testing = LibraryInstrumentationExtension.create();

@Mock private Context context;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@
import org.mockito.junit.jupiter.MockitoExtension;

@ExtendWith(MockitoExtension.class)
public class AwsLambdaSqsMessageHandlerTest {
class AwsLambdaSqsMessageHandlerTest {

private static final String AWS_TRACE_HEADER1 =
"Root=1-5759e988-bd862e3fe1be46a994272793;Parent=53995c3f42cd8ad8;Sampled=1";
private static final String AWS_TRACE_HEADER2 =
"Root=1-5759e988-bd862e3fe1be46a994272793;Parent=53995c3f42cd8ad9;Sampled=1";

@RegisterExtension
public static final InstrumentationExtension testing = LibraryInstrumentationExtension.create();
static final InstrumentationExtension testing = LibraryInstrumentationExtension.create();

@Mock private Context context;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@
import org.mockito.junit.jupiter.MockitoExtension;

@ExtendWith(MockitoExtension.class)
public class AwsLambdaWrapperTest {
class AwsLambdaWrapperTest {

@RegisterExtension
public static final InstrumentationExtension testing = LibraryInstrumentationExtension.create();
static final InstrumentationExtension testing = LibraryInstrumentationExtension.create();

@Mock private Context context;

Expand Down
Loading