-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature(examples) adding tracetest x aws-xray examples (#2030)
* feature: adding support for AWS X-RAY * updating README * cleanup * feat(server): implement viper (#1977) * added quick-start golang app in example (#1940) * added quick-start golnag app in example * Added quick-start-python in examples * chore(docs): add recipe for datadog (#1995) * chore(examples): adding documentation and example of datadog integration * adding datadog recipe * fixing details in docs * Apply suggestions from code review Co-authored-by: Julianne Fermi <julianne@kubeshop.io> --------- Co-authored-by: Julianne Fermi <julianne@kubeshop.io> * Update docs structure and config guides (#1984) * docs(1919): flatten tools and integration * docs(1919): flatten examples and tutorials * docs(recipes): edit naming * docs(config): fix 1982 * examples(tempo): edit config * docs(structure): add redirect * docs(config): update dd * feature(examples): adding net core x tracetest example (#1978) * feature(examples): adding net core x tracetest example * adding readme * addressing feedback comments * adding more information * adding support for the native xray client * refactor connectivity test to reuse components (#1994) * refactor connectivity test to reuse components * only run next step if previous step succeeded * simplify tester TestConnection Co-authored-by: Sebastian Choren <schoren@users.noreply.github.com> * add protocol in IsReachable function * ignore unused ctx * remove boolean return from IsReachable * use multierrors to wrap all endpoint errors * fix build * use const for IsReachable timeout * rename IsReachable to CheckReachability --------- Co-authored-by: Sebastian Choren <schoren@users.noreply.github.com> * cleanup * using the new test connection logic * config(server): allow provisioning from file or environent variable (#1999) * cleanup * adding support for session token * feat(server): implement viper (#1977) * config(server): allow provisioning from file or environent variable (#1999) * moving trace id generation to data store * fixing unit tests * chore: disable application exporter in demo (#2012) disable app exporter in demo * removing examples * feature(examples) adding tracetest x aws-xray examples * cleanup * cleanup * removing mysql dependency --------- Co-authored-by: Sebastian Choren <schoren@users.noreply.github.com> Co-authored-by: Mahesh Kasbe <60398112+maheshkasabe@users.noreply.github.com> Co-authored-by: Daniel Baptista Dias <danielbdias@users.noreply.github.com> Co-authored-by: Julianne Fermi <julianne@kubeshop.io> Co-authored-by: Adnan Rahi膰 <adnan@kubeshop.io> Co-authored-by: Matheus Nogueira <matheus.nogueira2008@gmail.com>
- Loading branch information
1 parent
3729481
commit e8b948f
Showing
34 changed files
with
5,074 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
AWS_ACCESS_KEY_ID="" | ||
AWS_SECRET_ACCESS_KEY="" | ||
AWS_SESSION_TOKEN="" | ||
AWS_REGION="us-west-2" |
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,2 @@ | ||
node_modules | ||
.DS_Store |
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,10 @@ | ||
FROM node:slim | ||
WORKDIR /usr/src/app | ||
|
||
COPY ./src/package*.json ./ | ||
|
||
RUN npm install | ||
COPY ./src . | ||
|
||
EXPOSE 3000 | ||
CMD [ "npm", "start" ] |
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,11 @@ | ||
# Tracetest + Amazon X-Ray (using ADOT Collector) | ||
|
||
This repository objective is to show how you can configure your Tracetest instance to connect to AWS X-Ray plus the ADOT collector and use it as its tracing backend. | ||
|
||
## Steps | ||
|
||
1. [Install the tracetest CLI](https://docs.tracetest.io/installing/) | ||
2. Run `tracetest configure --endpoint http://localhost:11633` on a terminal | ||
3. Update the `.env` file adding a valid set of AWS credentials | ||
4. Run the project by using docker-compose: `docker-compose up -d` (Linux) or `docker compose up -d` (Mac) | ||
5. Test if it works by running: `tracetest test run -d tests/test.yaml`. This would trigger a test that will send and retrieve spans from the X-Ray instance that is running on your machine. |
24 changes: 24 additions & 0 deletions
24
examples/tracetest-amazon-x-ray-adot/collector.config.yaml
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,24 @@ | ||
receivers: | ||
awsxray: | ||
transport: udp | ||
|
||
processors: | ||
batch: | ||
|
||
exporters: | ||
awsxray: | ||
region: ${AWS_REGION} | ||
otlp/tt: | ||
endpoint: tracetest:21321 | ||
tls: | ||
insecure: true | ||
|
||
service: | ||
pipelines: | ||
traces/tt: | ||
receivers: [awsxray] | ||
processors: [batch] | ||
exporters: [otlp/tt] | ||
traces/xr: | ||
receivers: [awsxray] | ||
exporters: [awsxray] |
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,63 @@ | ||
version: "3" | ||
services: | ||
app: | ||
build: . | ||
environment: | ||
AWS_REGION: ${AWS_REGION} | ||
ports: | ||
- "3000:3000" | ||
|
||
tracetest: | ||
image: kubeshop/tracetest:${TAG:-latest} | ||
platform: linux/amd64 | ||
volumes: | ||
- type: bind | ||
source: ./tracetest-config.yaml | ||
target: /app/tracetest.yaml | ||
- type: bind | ||
source: ./tracetest.provision.yaml | ||
target: /app/provisioning.yaml | ||
ports: | ||
- 11633:11633 | ||
command: --provisioning-file /app/provisioning.yaml | ||
extra_hosts: | ||
- "host.docker.internal:host-gateway" | ||
depends_on: | ||
postgres: | ||
condition: service_healthy | ||
adot-collector: | ||
condition: service_started | ||
healthcheck: | ||
test: ["CMD", "wget", "--spider", "localhost:11633"] | ||
interval: 1s | ||
timeout: 3s | ||
retries: 60 | ||
|
||
postgres: | ||
image: postgres:14 | ||
environment: | ||
POSTGRES_PASSWORD: postgres | ||
POSTGRES_USER: postgres | ||
healthcheck: | ||
test: pg_isready -U "$$POSTGRES_USER" -d "$$POSTGRES_DB" | ||
interval: 1s | ||
timeout: 5s | ||
retries: 60 | ||
ports: | ||
- 5432:5432 | ||
|
||
adot-collector: | ||
image: amazon/aws-otel-collector:latest | ||
command: | ||
- "--config" | ||
- "/otel-local-config.yaml" | ||
volumes: | ||
- ./collector.config.yaml:/otel-local-config.yaml | ||
environment: | ||
AWS_ACCESS_KEY_ID: ${AWS_ACCESS_KEY_ID} | ||
AWS_SECRET_ACCESS_KEY: ${AWS_SECRET_ACCESS_KEY} | ||
AWS_SESSION_TOKEN: ${AWS_SESSION_TOKEN} | ||
AWS_REGION: ${AWS_REGION} | ||
ports: | ||
- 4317:4317 | ||
- 2000:2000 |
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,15 @@ | ||
<!DOCTYPE html> | ||
<head> | ||
<title>X-Ray SDK for Node.js</title> | ||
</head> | ||
<body> | ||
<h2>Welcome to the sample app for the X-Ray SDK for Node.js!</h2> | ||
<p> | ||
View the traces generated with this sample app at any time in your | ||
<a | ||
href="https://us-west-2.console.aws.amazon.com/xray/home?region=us-west-2#/traces?filter=service(%22Tracetest%22)" | ||
>X-Ray Console</a | ||
>. | ||
</p> | ||
<p>To see a traced HTTP request, go <a href="/http-request/">here</a>.</p> | ||
</body> |
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,47 @@ | ||
const AWSXRay = require("aws-xray-sdk"); | ||
const XRayExpress = AWSXRay.express; | ||
const express = require("express"); | ||
|
||
AWSXRay.setDaemonAddress("adot-collector:2000"); | ||
|
||
// Capture all AWS clients we create | ||
const AWS = AWSXRay.captureAWS(require("aws-sdk")); | ||
AWS.config.update({ | ||
region: process.env.AWS_REGION || "us-west-2", | ||
}); | ||
|
||
// Capture all outgoing https requests | ||
AWSXRay.captureHTTPsGlobal(require("https")); | ||
const https = require("https"); | ||
|
||
const app = express(); | ||
const port = 3000; | ||
|
||
app.use(XRayExpress.openSegment("Tracetest")); | ||
|
||
app.get("/", (req, res) => { | ||
const seg = AWSXRay.getSegment(); | ||
const sub = seg.addNewSubsegment("customSubsegment"); | ||
setTimeout(() => { | ||
sub.close(); | ||
res.sendFile(`${process.cwd()}/index.html`); | ||
}, 500); | ||
}); | ||
|
||
app.get("/http-request/", (req, res) => { | ||
const endpoint = "https://amazon.com/"; | ||
https.get(endpoint, (response) => { | ||
response.on("data", () => {}); | ||
|
||
response.on("error", (err) => { | ||
res.send(`Encountered error while making HTTPS request: ${err}`); | ||
}); | ||
|
||
response.on("end", () => { | ||
res.send(`Successfully reached ${endpoint}.`); | ||
}); | ||
}); | ||
}); | ||
|
||
app.use(XRayExpress.closeSegment()); | ||
app.listen(port, () => console.log(`Example app listening on port ${port}!`)); |
Oops, something went wrong.