-
Notifications
You must be signed in to change notification settings - Fork 866
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added dynamodb instrumenter for aws v1_11 sdk
- Loading branch information
Showing
4 changed files
with
69 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
...rc/main/java/io/opentelemetry/instrumentation/awssdk/v1_11/DynamoAttributesExtractor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package io.opentelemetry.instrumentation.awssdk.v1_11; | ||
|
||
import com.amazonaws.Request; | ||
import com.amazonaws.Response; | ||
import io.opentelemetry.api.common.AttributeKey; | ||
import io.opentelemetry.api.common.AttributesBuilder; | ||
import io.opentelemetry.context.Context; | ||
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor; | ||
import io.opentelemetry.instrumentation.api.internal.AttributesExtractorUtil; | ||
import javax.annotation.Nullable; | ||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
public class DynamoAttributesExtractor implements AttributesExtractor<Request<?>, Response<?>> { | ||
|
||
private static final AttributeKey<String> DB_SYSTEM = | ||
AttributeKey.stringKey("db.system"); | ||
private static final AttributeKey<List<String>> AWS_TABLE_NAMES = | ||
AttributeKey.stringArrayKey("aws.dynamodb.table_names"); | ||
|
||
private static final String DYNAMODB = "dynamodb"; | ||
|
||
@Override | ||
public void onStart(AttributesBuilder attributes, Context parentContext, Request<?> request) { | ||
AttributesExtractorUtil.internalSet(attributes,DB_SYSTEM,DYNAMODB); | ||
String tableName = RequestAccess.getTableName(request.getOriginalRequest()); | ||
AttributesExtractorUtil.internalSet(attributes,AWS_TABLE_NAMES, Collections.singletonList(tableName)); | ||
} | ||
|
||
@Override | ||
public void onEnd( | ||
AttributesBuilder attributes, | ||
Context context, | ||
Request<?> request, | ||
@Nullable Response<?> response, | ||
@Nullable Throwable error) {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters