|
8 | 8 | import com.amazonaws.services.lambda.runtime.events.SQSEvent;
|
9 | 9 | import io.opentelemetry.api.GlobalOpenTelemetry;
|
10 | 10 | import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter;
|
| 11 | +import io.opentelemetry.instrumentation.awslambdacore.v1_0.internal.AwsLambdaFunctionInstrumenter; |
| 12 | +import io.opentelemetry.instrumentation.awslambdacore.v1_0.internal.WrapperConfiguration; |
11 | 13 | import io.opentelemetry.instrumentation.awslambdaevents.v2_2.internal.AwsLambdaEventsInstrumenterFactory;
|
12 | 14 | import io.opentelemetry.instrumentation.awslambdaevents.v2_2.internal.AwsLambdaSqsInstrumenterFactory;
|
13 | 15 | import io.opentelemetry.javaagent.bootstrap.internal.AgentCommonConfig;
|
| 16 | +import io.opentelemetry.javaagent.bootstrap.internal.AgentInstrumentationConfig; |
| 17 | +import java.time.Duration; |
14 | 18 |
|
15 | 19 | public final class AwsLambdaInstrumentationHelper {
|
16 | 20 |
|
17 |
| - private static final io.opentelemetry.instrumentation.awslambdacore.v1_0.internal |
18 |
| - .AwsLambdaFunctionInstrumenter |
19 |
| - FUNCTION_INSTRUMENTER = |
20 |
| - AwsLambdaEventsInstrumenterFactory.createInstrumenter( |
21 |
| - GlobalOpenTelemetry.get(), AgentCommonConfig.get().getKnownHttpRequestMethods()); |
22 |
| - |
23 |
| - public static io.opentelemetry.instrumentation.awslambdacore.v1_0.internal |
24 |
| - .AwsLambdaFunctionInstrumenter |
25 |
| - functionInstrumenter() { |
26 |
| - return FUNCTION_INSTRUMENTER; |
27 |
| - } |
28 |
| - |
| 21 | + private static final AwsLambdaFunctionInstrumenter FUNCTION_INSTRUMENTER = |
| 22 | + AwsLambdaEventsInstrumenterFactory.createInstrumenter( |
| 23 | + GlobalOpenTelemetry.get(), AgentCommonConfig.get().getKnownHttpRequestMethods()); |
29 | 24 | private static final Instrumenter<SQSEvent, Void> MESSAGE_TRACER =
|
30 | 25 | AwsLambdaSqsInstrumenterFactory.forEvent(GlobalOpenTelemetry.get());
|
| 26 | + private static final Duration FLUSH_TIMEOUT = |
| 27 | + Duration.ofMillis( |
| 28 | + AgentInstrumentationConfig.get() |
| 29 | + .getLong( |
| 30 | + "otel.instrumentation.aws-lambda.flush-timeout", |
| 31 | + WrapperConfiguration.OTEL_LAMBDA_FLUSH_TIMEOUT_DEFAULT.toMillis())); |
| 32 | + |
| 33 | + public static AwsLambdaFunctionInstrumenter functionInstrumenter() { |
| 34 | + return FUNCTION_INSTRUMENTER; |
| 35 | + } |
31 | 36 |
|
32 | 37 | public static Instrumenter<SQSEvent, Void> messageInstrumenter() {
|
33 | 38 | return MESSAGE_TRACER;
|
34 | 39 | }
|
35 | 40 |
|
| 41 | + public static Duration flushTimeout() { |
| 42 | + return FLUSH_TIMEOUT; |
| 43 | + } |
| 44 | + |
36 | 45 | private AwsLambdaInstrumentationHelper() {}
|
37 | 46 | }
|
0 commit comments