- Newest
- Most votes
- Most comments
Hi there,
DynamoDB streams right now is not integrated with X-Ray so the streams will not carry the tracing context to the downstream lambda function. If you enable active tracing to the downstream lambda function you should see a new subgraph starts from that lambda function.
Integrating with DynamoDB streams is a popular request and we are evaluating this feature with DynamoDB teams. To better understand your use case, could you provide how many streams you expect to see in a single lambda invoke? Do these streams usually come from a single API Getaway request?
We will provide updates once we make progress. Please stay tuned and thank you for your patience.
Thanks,
Haotian
answered 7 years ago
Any updates on the availability of tracing via DynamoDB streams?
Thanks,
Olja
answered 6 years ago
Hi @MichalPospisil
We are still in talks with the DDB team to iron out details of the integration with X-Ray. It's on our roadmap.
Thanks for providing the flow of your use case. I'm not sure if you noticed that you're missing the client -> API Gateway -> AWS Lambda flow in your first service map. This is because you're using API Gateway V2 and unlike V1, it's not supported with X-Ray yet. Any particular reason to use the V2?
We'll post updates about the support for DDB stream as soon as possible. Thanks for your patience.
Regards,
Prashant
answered 6 years ago
Hi Haotian,
Thank you for your reply. Let's go step-by-step.
- First use case:
API Gateway -> Lambda -> DynamoDB "Events" Table
I enabled tracing on API Gateway stage, but I only see API Gateway stage and Lambda in Service Map. What do I need to do to see the DynamoDB Table in the Service Map, similar to how you can see it here: https://docs.aws.amazon.com/xray/latest/devguide/xray-concepts.html#xray-concepts-servicegraph ?
- I am not sure what you mean by "how many streams". The "Events" Table I mentioned above has one DynamoDB stream that triggers another "Event Processor" Lambda function.
I appreciate the help!
Thanks,
Tanvir
answered 7 years ago
Hi, what is the SDK version? Could you also provide a code snippet that calls your "Event" table so we can take a further look at?
Thanks,
Haotian
answered 7 years ago
Hi Haotian,
I tried manually creating a subsegment but still no luck. Here's a snippet of my code:
// DynamoDBClient class
private val client: AmazonDynamoDB =
AmazonDynamoDBClientBuilder
.standard()
.withEndpointConfiguration(EndpointConfiguration(dynamodbEndpoint, dynamodbRegion))
.withRequestHandlers(TracingHandler(AWSXRay.getGlobalRecorder()))
.build()
fun publishEvent(notificationEvent: notificationEvent) {
val mapperConfig: DynamoDBMapperConfig =
DynamoDBMapperConfig
.builder()
.withTableNameOverride(DynamoDBMapperConfig.TableNameOverride(eventsTableName))
.build()
val mapper = DynamoDBMapper(client, mapperConfig)
val expectedAttributes = mapOf("AlertIdentifier" to ExpectedAttributeValue(false))
val subsegment: Subsegment = AWSXRay.beginSubsegment("DynamoDBClient.publishEvent")
try {
mapper.save(notificationEvent, DynamoDBSaveExpression().withExpected(expectedAttributes))
} catch (ex: Exception) {
subsegment.addException(ex)
throw ex
} finally {
logger.debug("Parent segment name: ${subsegment.parentSegment.name}")
logger.debug("Parent segment id: ${subsegment.parentSegment.id}")
subsegment.end()
}
}
// Some other class
DynamoDBClient.publishEvent(notificationEvent)
Here is a subset of my build.gradle file where you can see the SDK versions:
dependencyManagement {
imports {
mavenBom('com.amazonaws:aws-java-sdk-bom:1.11.559')
mavenBom('com.amazonaws:aws-xray-recorder-sdk-bom:2.2.1')
}
}
ext {
kotlinVersion = '1.3.31'
}
dependencies {
implementation(
'org.jetbrains.kotlin:kotlin-stdlib-jdk8',
'org.jetbrains.kotlin:kotlin-reflect',
'org.jetbrains.kotlinx:kotlinx-serialization-runtime-common:0.11.0',
'ch.qos.logback:logback-classic:1.2.3',
'com.amazonaws:aws-java-sdk-core',
'com.amazonaws:aws-java-sdk-dynamodb',
'com.amazonaws:aws-lambda-java-core:1.2.0',
'com.amazonaws:aws-lambda-java-events:2.2.6',
'com.amazonaws:aws-xray-recorder-sdk-core',
'com.amazonaws:aws-xray-recorder-sdk-aws-sdk',
'ch.qos.logback:logback-classic:1.2.3',
'com.fasterxml.jackson.module:jackson-module-kotlin:2.9.7'
)
}
Thanks,
Tanvir
answered 7 years ago
Hi Haotian,
I think I figured it out.
Turns out that the instrumentation works if I exclude the SDK Instrumentor submodule (aws-xray-recorder-sdk-aws-sdk-instrumentor), and I don't even need to manually create subsegments for the DynamoDB calls.
Just adding these two dependencies is enough for me:
'com.amazonaws:aws-xray-recorder-sdk-core',
'com.amazonaws:aws-xray-recorder-sdk-aws-sdk'
Perhaps, the documentation needs to be updated. Anyway, the only thing I'm missing right now is to record the segment in the Lambda triggered from a DynamoDB stream, but I suppose I can persist the Trace ID and Segment ID in DynamoDB and use them to manually create another segment, as a workaround. Any update on whether support for DynamoDB Streams is in the roadmap?
Thanks,
Tanvir
answered 7 years ago

Hi Prashant, are there any updates available about this feature?