-
Notifications
You must be signed in to change notification settings - Fork 791
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enhance AWS DynamoDB instrumentation #1191
Conversation
This turned out much larger than I was anticipating :-) One thing I should have mentioned earlier is it's on my plate to refactor the handling of the "custom attributes" in a generic way. AWS has essentially semantic conventions defined for the AWS SDK, which we implement in xray and think otel should as well since they're benifecial for any tracing vendor. They are a generic transformation of the JSON itself like here https://github.com/aws/aws-xray-sdk-java/blob/master/aws-xray-recorder-sdk-aws-sdk-v2/src/main/java/com/amazonaws/xray/interceptors/TracingInterceptor.java#L187 So it'd be great if we can hold off on adding refactoring to make a generic way of adding custom attributes since I think much of the logic we have right now will actually go away. Also, I don't think the intention of the DB conventions is to normalize DB statements into something SQL-like. DynamoDB is essentially the same type of DB as MongoDB, but the example recommends not setting statement probably because it's JSON, not a statement So I don't think we should fill statement, which makes a lot of the complexity go away I think, the PR could probably just be something like if (awsServiceName.equals("DynamoDB")) {
db.system = "dynamodb"
db.operation = awsOperationName
} Sorry for not being stronger about not including statement in the issue itself >< |
Alternatively, if we do really want to include statement, I would just put the |
@anuraaga can you elaborate on |
I can see the benefit of having some sort of statement-like info on DynomoDB span. I am not very familiar with AWS SDK and I don't see what json are we talking about? :) But I do see that subclasses of |
Yeah basically we have a mapping from JSON fields to semantic convention attributes in this data file. So we generically map SDK requests to richer information using it. One of my "job milestone tasks" is to port those conventions to OTel ;)
Yeah I think |
I think the spec section on mongodb is just an example, e.g. it doesn't show Our MongoDB instrumentation captures both Capturing |
I should have looked at the mongodb code :D Seems like we record a scrubbed JSON object there. @kubawach Do you think it's possible to implement similar scrubbing in a generic way instead of having to manually serialize each different type of request? I think for the most part, any
What do you think? |
I like the idea of smaller PRs |
@kubawach ^^ |
Thanks for the comments, I appreciate all of them. I'm really happy to see that the proposal sparked a discussion regarding handling of the DynamoDB. Before I attend the comments and proposals, let me give you some background my motivations of particular design choices.
Regarding ideas that were mentioned in the course of the discussion (thanks once again): @iNikem I believe that regular toString() serialisation of requests won't do the trick, as for exemplary request it looks like that: "CreateTableRequest(AttributeDefinitions=software.amazon.awssdk.core.util.DefaultSdkAutoConstructList@103f73a, TableName=sometable, KeySchema=software.amazon.awssdk.core.util.DefaultSdkAutoConstructList@103f73a, LocalSecondaryIndexes=software.amazon.awssdk.core.util.DefaultSdkAutoConstructList@103f73a, GlobalSecondaryIndexes=software.amazon.awssdk.core.util.DefaultSdkAutoConstructList@103f73a)" @anuraaga regarding "generic" scrubbing instead of custom-per-request one - happy to do so, but we need to mind two issues here:
@anuraaga regarding splitting the PR - happy to do so as well, once we agree on the final approach (mainly attributes scrubbing). I'd then go for 2 separate PRs:
Let me know what you think :) |
I understand your point of view, @kubawach. I think we have a contention around Then, as a follow up task, let us discuss our options how to add proper db statement. That will be tougher task, so let us address it separately. |
@iNikem great idea, splitting the MR then. |
...-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/SpanFactory.java
Outdated
Show resolved
Hide resolved
...g/src/main/groovy/io/opentelemetry/instrumentation/awssdk/v2_2/AbstractAws2ClientTest.groovy
Show resolved
Hide resolved
...g/src/main/groovy/io/opentelemetry/instrumentation/awssdk/v2_2/AbstractAws2ClientTest.groovy
Show resolved
Hide resolved
...g/src/main/groovy/io/opentelemetry/instrumentation/awssdk/v2_2/AbstractAws2ClientTest.groovy
Show resolved
Hide resolved
...brary/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/HttpAwsSdkClientTracer.java
Outdated
Show resolved
Hide resolved
.../src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/TracingExecutionInterceptor.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kubawach Thanks a lot for the summary of your reasoning it helps me a lot :) I agree that we want to add statement in some form, and thanks for separating it out since it's definitely a much harder topic than the standard DB attributes so glad to focus on those here.
.../src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/TracingExecutionInterceptor.java
Show resolved
Hide resolved
.../src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/TracingExecutionInterceptor.java
Outdated
Show resolved
Hide resolved
.../src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/TracingExecutionInterceptor.java
Outdated
Show resolved
Hide resolved
.../src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/TracingExecutionInterceptor.java
Show resolved
Hide resolved
...-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/SpanFactory.java
Outdated
Show resolved
Hide resolved
...ibrary/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/db/DbRequestDecorator.java
Outdated
Show resolved
Hide resolved
...g/src/main/groovy/io/opentelemetry/instrumentation/awssdk/v2_2/AbstractAws2ClientTest.groovy
Show resolved
Hide resolved
.../src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/TracingExecutionInterceptor.java
Outdated
Show resolved
Hide resolved
@Override | ||
public void decorate(Span span, SdkRequest sdkRequest, ExecutionAttributes attributes) { | ||
|
||
span.setAttribute(SemanticAttributes.DB_SYSTEM.key(), "dynamodb"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SemanticAttributes.DB_SYSTEM.set(span, "dynamodb")
makes it easier to find non-semantic attributes in the future
...-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/RequestType.java
Outdated
Show resolved
Hide resolved
...-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/RequestType.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just one small nit, and addressing it will kick the CI so hopefully it doesn't flake
Resolves #1181