-
Notifications
You must be signed in to change notification settings - Fork 870
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
11 changed files
with
462 additions
and
974 deletions.
There are no files selected for viewing
696 changes: 0 additions & 696 deletions
696
...rc/test/groovy/io/opentelemetry/javaagent/instrumentation/apachecamel/SnsCamelTest.groovy
This file was deleted.
Oops, something went wrong.
74 changes: 0 additions & 74 deletions
74
...t/src/test/groovy/io/opentelemetry/javaagent/instrumentation/apachecamel/SnsConfig.groovy
This file was deleted.
Oops, something went wrong.
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
67 changes: 67 additions & 0 deletions
67
...src/test/groovy/io/opentelemetry/javaagent/instrumentation/apachecamel/aws/AwsSpan.groovy
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,67 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.javaagent.instrumentation.apachecamel.aws | ||
|
||
import static io.opentelemetry.api.trace.SpanKind.CLIENT | ||
|
||
import io.opentelemetry.instrumentation.test.asserts.TraceAssert | ||
|
||
class AwsSpan { | ||
|
||
static s3(TraceAssert traceAssert, int index, spanName, bucketName, method="GET", parentSpan=null) { | ||
return traceAssert.span(index) { | ||
name spanName | ||
kind CLIENT | ||
if (index == 0) { | ||
hasNoParent() | ||
} else { | ||
childOf parentSpan | ||
} | ||
attributes { | ||
"aws.agent" "java-aws-sdk" | ||
"aws.endpoint" String | ||
"aws.operation" spanName.substring(3) | ||
"aws.service" "Amazon S3" | ||
"aws.bucket.name" bucketName | ||
"http.flavor" "1.1" | ||
"http.method" method | ||
"http.status_code" 200 | ||
"http.url" String | ||
"net.peer.name" String | ||
"net.transport" "IP.TCP" | ||
"net.peer.port" { it == null || Number } | ||
} | ||
} | ||
} | ||
|
||
static sqs(TraceAssert traceAssert, int index, spanName, queueUrl=null, queueName=null, spanKind=CLIENT, parentSpan=null) { | ||
return traceAssert.span(index) { | ||
name spanName | ||
kind spanKind | ||
if (index == 0) { | ||
hasNoParent() | ||
} else { | ||
childOf parentSpan | ||
} | ||
attributes { | ||
"aws.agent" "java-aws-sdk" | ||
"aws.endpoint" String | ||
"aws.operation" spanName.substring(4) | ||
"aws.service" "AmazonSQS" | ||
"aws.queue.name" {it == null || it == queueName} | ||
"aws.queue.url" {it == null || it == queueUrl} | ||
"http.flavor" "1.1" | ||
"http.method" "POST" | ||
"http.status_code" 200 | ||
"http.url" String | ||
"http.user_agent" { it == null || String } | ||
"net.peer.name" String | ||
"net.peer.port" { it == null || Number } | ||
"net.transport" "IP.TCP" | ||
} | ||
} | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
...t/groovy/io/opentelemetry/javaagent/instrumentation/apachecamel/aws/CamelSpringApp.groovy
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,51 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.javaagent.instrumentation.apachecamel.aws | ||
|
||
import org.apache.camel.CamelContext | ||
import org.apache.camel.ProducerTemplate | ||
import org.springframework.boot.SpringApplication | ||
import org.springframework.context.ApplicationContextInitializer | ||
import org.springframework.context.ConfigurableApplicationContext | ||
import org.springframework.context.support.AbstractApplicationContext | ||
|
||
class CamelSpringApp { | ||
|
||
private SpringApplication springApplication | ||
private ConfigurableApplicationContext context | ||
|
||
CamelSpringApp(AwsConnector awsConnector, Class config, Map<String, String> properties) { | ||
springApplication = new SpringApplication(config) | ||
springApplication.setDefaultProperties(properties) | ||
injectClients(awsConnector) | ||
} | ||
|
||
private injectClients(AwsConnector awsConnector) { | ||
springApplication.addInitializers(new ApplicationContextInitializer<AbstractApplicationContext>() { | ||
@Override | ||
void initialize(AbstractApplicationContext applicationContext) { | ||
applicationContext.getBeanFactory().registerSingleton("snsClient", awsConnector.getSnsClient()) | ||
applicationContext.getBeanFactory().registerSingleton("sqsClient", awsConnector.getSqsClient()) | ||
applicationContext.getBeanFactory().registerSingleton("s3Client", awsConnector.getS3Client()) | ||
} | ||
}) | ||
} | ||
|
||
def start() { | ||
context = springApplication.run() | ||
} | ||
|
||
ProducerTemplate producerTemplate() { | ||
def camelContext = context.getBean(CamelContext) | ||
return camelContext.createProducerTemplate() | ||
} | ||
|
||
def stop() { | ||
if (context != null) { | ||
SpringApplication.exit(context) | ||
} | ||
} | ||
} |
Oops, something went wrong.