File tree Expand file tree Collapse file tree
instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/faas/internal
instrumentation/aws-lambda
aws-lambda-core-1.0/library/src/main/java/io/opentelemetry/instrumentation/awslambdacore/v1_0/internal
aws-lambda-events-common-2.2/library/src/main/java/io/opentelemetry/instrumentation/awslambdaevents/common/v2_2/internal Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright The OpenTelemetry Authors
3+ * SPDX-License-Identifier: Apache-2.0
4+ */
5+
6+ package io .opentelemetry .instrumentation .api .incubator .semconv .faas .internal ;
7+
8+ import com .google .errorprone .annotations .CanIgnoreReturnValue ;
9+ import io .opentelemetry .api .logs .Severity ;
10+ import io .opentelemetry .instrumentation .api .instrumenter .InstrumenterBuilder ;
11+ import io .opentelemetry .instrumentation .api .internal .Experimental ;
12+
13+ /**
14+ * This class is internal and is hence not for public use. Its APIs are unstable and can change at
15+ * any time.
16+ */
17+ public final class FaasExceptionEventExtractors {
18+
19+ /**
20+ * Configures the FaaS invocation exception event name and severity. Only takes effect when
21+ * emitting exceptions as logs is enabled via the {@code otel.semconv.exception.signal.preview}
22+ * flag.
23+ */
24+ @ CanIgnoreReturnValue
25+ public static <REQUEST , RESPONSE >
26+ InstrumenterBuilder <REQUEST , RESPONSE > setFaasInvocationExceptionEventExtractor (
27+ InstrumenterBuilder <REQUEST , RESPONSE > builder ) {
28+ Experimental .setExceptionEventExtractor (
29+ builder ,
30+ (logRecordBuilder , context , request ) -> {
31+ logRecordBuilder .setEventName ("faas.invocation.exception" );
32+ logRecordBuilder .setSeverity (Severity .ERROR );
33+ });
34+ return builder ;
35+ }
36+
37+ private FaasExceptionEventExtractors () {}
38+ }
Original file line number Diff line number Diff line change 55
66package io .opentelemetry .instrumentation .awslambdacore .v1_0 .internal ;
77
8+ import static io .opentelemetry .instrumentation .api .incubator .semconv .faas .internal .FaasExceptionEventExtractors .setFaasInvocationExceptionEventExtractor ;
9+
810import io .opentelemetry .api .OpenTelemetry ;
911import io .opentelemetry .instrumentation .api .instrumenter .Instrumenter ;
1012import io .opentelemetry .instrumentation .api .instrumenter .SpanKindExtractor ;
@@ -19,11 +21,12 @@ public final class AwsLambdaFunctionInstrumenterFactory {
1921 public static AwsLambdaFunctionInstrumenter createInstrumenter (OpenTelemetry openTelemetry ) {
2022 return new AwsLambdaFunctionInstrumenter (
2123 openTelemetry ,
22- Instrumenter .builder (
23- openTelemetry ,
24- "io.opentelemetry.aws-lambda-core-1.0" ,
25- AwsLambdaFunctionInstrumenterFactory ::spanName )
26- .addAttributesExtractor (new AwsLambdaFunctionAttributesExtractor ())
24+ setFaasInvocationExceptionEventExtractor (
25+ Instrumenter .builder (
26+ openTelemetry ,
27+ "io.opentelemetry.aws-lambda-core-1.0" ,
28+ AwsLambdaFunctionInstrumenterFactory ::spanName )
29+ .addAttributesExtractor (new AwsLambdaFunctionAttributesExtractor ()))
2730 .buildInstrumenter (SpanKindExtractor .alwaysServer ()));
2831 }
2932
Original file line number Diff line number Diff line change 55
66package io .opentelemetry .instrumentation .awslambdaevents .common .v2_2 .internal ;
77
8+ import static io .opentelemetry .instrumentation .api .incubator .semconv .faas .internal .FaasExceptionEventExtractors .setFaasInvocationExceptionEventExtractor ;
9+
810import com .amazonaws .services .lambda .runtime .events .APIGatewayProxyRequestEvent ;
911import io .opentelemetry .api .OpenTelemetry ;
1012import io .opentelemetry .instrumentation .api .instrumenter .Instrumenter ;
@@ -24,10 +26,13 @@ public static AwsLambdaFunctionInstrumenter createInstrumenter(
2426 OpenTelemetry openTelemetry , String instrumentationName , Set <String > knownMethods ) {
2527 return new AwsLambdaFunctionInstrumenter (
2628 openTelemetry ,
27- Instrumenter .builder (
28- openTelemetry , instrumentationName , AwsLambdaEventsInstrumenterFactory ::spanName )
29- .addAttributesExtractor (new AwsLambdaFunctionAttributesExtractor ())
30- .addAttributesExtractor (new ApiGatewayProxyAttributesExtractor (knownMethods ))
29+ setFaasInvocationExceptionEventExtractor (
30+ Instrumenter .builder (
31+ openTelemetry ,
32+ instrumentationName ,
33+ AwsLambdaEventsInstrumenterFactory ::spanName )
34+ .addAttributesExtractor (new AwsLambdaFunctionAttributesExtractor ())
35+ .addAttributesExtractor (new ApiGatewayProxyAttributesExtractor (knownMethods )))
3136 .buildInstrumenter (SpanKindExtractor .alwaysServer ()));
3237 }
3338
You can’t perform that action at this time.
0 commit comments