|
| 1 | +/* |
| 2 | + * Copyright The OpenTelemetry Authors |
| 3 | + * SPDX-License-Identifier: Apache-2.0 |
| 4 | + */ |
| 5 | + |
1 | 6 | package io.opentelemetry.javaagent.instrumentation.aerospike_client.v7_1; |
2 | 7 |
|
3 | 8 | import com.aerospike.client.AerospikeException; |
|
8 | 13 | import io.opentelemetry.instrumentation.api.instrumenter.db.AerospikeSemanticAttributes; |
9 | 14 | import javax.annotation.Nullable; |
10 | 15 |
|
11 | | -public class AerospikeClientAttributeExtractor implements |
12 | | - AttributesExtractor<AerospikeRequest, Void> { |
| 16 | +public class AerospikeClientAttributeExtractor |
| 17 | + implements AttributesExtractor<AerospikeRequest, Void> { |
13 | 18 |
|
14 | 19 | @Override |
15 | | - public void onStart(AttributesBuilder attributes, Context parentContext, |
16 | | - AerospikeRequest aerospikeRequest) { |
| 20 | + public void onStart( |
| 21 | + AttributesBuilder attributes, Context parentContext, AerospikeRequest aerospikeRequest) { |
17 | 22 | attributes.put( |
18 | | - AerospikeSemanticAttributes.AEROSPIKE_NAMESPACE, |
19 | | - aerospikeRequest.getNamespace()); |
| 23 | + AerospikeSemanticAttributes.AEROSPIKE_NAMESPACE, aerospikeRequest.getNamespace()); |
20 | 24 | attributes.put(AerospikeSemanticAttributes.AEROSPIKE_SET_NAME, aerospikeRequest.getSet()); |
21 | 25 | attributes.put(AerospikeSemanticAttributes.AEROSPIKE_USER_KEY, aerospikeRequest.getUserKey()); |
22 | 26 | } |
23 | 27 |
|
24 | 28 | @Override |
25 | | - public void onEnd(AttributesBuilder attributes, Context context, |
26 | | - AerospikeRequest aerospikeRequest, @Nullable Void unused, @Nullable Throwable error) { |
27 | | - attributes.put(AerospikeSemanticAttributes.AEROSPIKE_STATUS, |
28 | | - aerospikeRequest.getStatus().name()); |
| 29 | + public void onEnd( |
| 30 | + AttributesBuilder attributes, |
| 31 | + Context context, |
| 32 | + AerospikeRequest aerospikeRequest, |
| 33 | + @Nullable Void unused, |
| 34 | + @Nullable Throwable error) { |
| 35 | + attributes.put( |
| 36 | + AerospikeSemanticAttributes.AEROSPIKE_STATUS, aerospikeRequest.getStatus().name()); |
29 | 37 | if (error != null) { |
30 | 38 | if (error instanceof AerospikeException) { |
31 | 39 | AerospikeException aerospikeException = (AerospikeException) error; |
32 | | - attributes.put(AerospikeSemanticAttributes.AEROSPIKE_ERROR_CODE, |
33 | | - aerospikeException.getResultCode()); |
| 40 | + attributes.put( |
| 41 | + AerospikeSemanticAttributes.AEROSPIKE_ERROR_CODE, aerospikeException.getResultCode()); |
34 | 42 | } else { |
35 | 43 | attributes.put(AerospikeSemanticAttributes.AEROSPIKE_ERROR_CODE, ResultCode.CLIENT_ERROR); |
36 | 44 | } |
37 | 45 | } else { |
38 | 46 | attributes.put(AerospikeSemanticAttributes.AEROSPIKE_ERROR_CODE, ResultCode.OK); |
39 | 47 | if (aerospikeRequest.getSize() != null) { |
40 | | - attributes.put(AerospikeSemanticAttributes.AEROSPIKE_TRANSFER_SIZE, |
41 | | - aerospikeRequest.getSize()); |
| 48 | + attributes.put( |
| 49 | + AerospikeSemanticAttributes.AEROSPIKE_TRANSFER_SIZE, aerospikeRequest.getSize()); |
42 | 50 | } |
43 | 51 | } |
44 | 52 | } |
|
0 commit comments