Skip to content

Commit

Permalink
Camel instrumentation - SNS propagation impl + tests (#2562)
Browse files Browse the repository at this point in the history
* Camel instrumentation - SNS propagation impl + tests

* code review
  • Loading branch information
kuba-wu authored Mar 17, 2021
1 parent 0ce9ca5 commit fcc7004
Show file tree
Hide file tree
Showing 6 changed files with 784 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,9 @@ dependencies {
testImplementation group: 'org.spockframework', name: 'spock-spring', version: "$versions.spock"
testImplementation 'javax.xml.bind:jaxb-api:2.3.1'
testImplementation group: 'org.elasticmq', name: 'elasticmq-rest-sqs_2.12', version: '1.0.0'
/**
* Temporarily using emq instead of localstack till the latter supports AWS trace propagation
*
* testImplementation deps.testcontainers
* testImplementation "org.testcontainers:localstack:${versions.testcontainers}
**/

testImplementation deps.testcontainers
testImplementation "org.testcontainers:localstack:${versions.testcontainers}"

latestDepTestLibrary group: 'org.apache.camel', name: 'camel-core', version: '2.+'
latestDepTestLibrary group: 'org.apache.camel', name: 'camel-spring-boot-starter', version: '2.+'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@ final class CamelPropagationUtil {

private CamelPropagationUtil() {}

private static boolean isAwsPropagated(Endpoint endpoint) {
return endpoint.getClass().getName().endsWith("SqsEndpoint");
}

static Context extractParent(final Map<String, Object> exchangeHeaders, Endpoint endpoint) {
return (isAwsPropagated(endpoint)
? extractAwsPropagationParent(exchangeHeaders)
: extractHttpPropagationParent(exchangeHeaders));
}

private static boolean isAwsPropagated(Endpoint endpoint) {
return endpoint.getClass().getName().endsWith("SqsEndpoint");
}

private static Context extractAwsPropagationParent(final Map<String, Object> exchangeHeaders) {
return AwsXrayPropagator.getInstance()
.extract(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ protected String getDestination(Exchange exchange, Endpoint endpoint) {
@Override
public SpanKind getInitiatorSpanKind() {
switch (component) {
case "aws-sns":
case "aws-sqs":
return SpanKind.INTERNAL;
default:
Expand All @@ -105,6 +106,7 @@ public SpanKind getInitiatorSpanKind() {
@Override
public SpanKind getReceiverSpanKind() {
switch (component) {
case "aws-sns":
case "aws-sqs":
return SpanKind.INTERNAL;
default:
Expand Down
Loading

0 comments on commit fcc7004

Please sign in to comment.