Skip to content

Commit

Permalink
docs(recipes): Add Python recipe to sidebar (#2425)
Browse files Browse the repository at this point in the history
* docs(recipes): add to sidebars and update recipes

* docs(config): edit config
  • Loading branch information
Adnan Rahić authored Apr 24, 2023
1 parent 638d0a4 commit aab9683
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
This page contains a reference for using the OpenTelemetry Collector to send trace data from your application to any of Tracetest's supported trace data stores.

:::tip
Examples of configuring Tracetest can be found in the [`examples` folder of the Tracetest GitHub repo](https://github.com/kubeshop/tracetest/tree/main/examples).
Examples of configuring Tracetest can be found in the [`examples` folder of the Tracetest GitHub repo](https://github.com/kubeshop/tracetest/tree/main/examples).
:::

## Supported Trace Data Stores
Expand All @@ -19,6 +19,7 @@ Currently, Tracetest supports the following data stores. Click on the respective
- [Grafana Tempo](./connecting-to-data-stores/tempo)
- [Lightstep](./connecting-to-data-stores/lightstep)
- [New Relic](./connecting-to-data-stores/new-relic)
- [Datadog](./connecting-to-data-stores/datadog)

Continue reading below to learn how to configure the OpenTelemetry Collector to send trace data from your application to any of the trace data stores above.

Expand Down
3 changes: 3 additions & 0 deletions docs/docs/examples-tutorials/recipes.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
These recipes will show you the best practices for using Tracetest.

- [Sending traces directly to Tracetest from a Node.js app using OpenTelemetry Collector](./recipes/running-tracetest-without-a-trace-data-store)
- [Sending traces with manual instrumentation directly to Tracetest from a Node.js app using OpenTelemetry Collector](./recipes/running-tracetest-without-a-trace-data-store-with-manual-instrumentation)
- [Sending traces with manual instrumentation directly to Tracetest from a Python app using OpenTelemetry Collector](./recipes/running-python-app-with-opentelemetry-collector-and-tracetest)
- [Sending traces to Jaeger from a Node.js app and fetching them from Jaeger with Tracetest](./recipes/running-tracetest-with-jaeger)
- [Sending traces to OpenSearch from a Node.js app and fetching them from OpenSearch with Tracetest](./recipes/running-tracetest-with-opensearch)
- [Sending traces to Tempo from a Node.js app and fetching them from Tempo with Tracetest](./recipes/running-tracetest-with-tempo)
Expand All @@ -15,5 +17,6 @@ These recipes will show you the best practices for using Tracetest.
- [Running Tracetest with AWS X-Ray (AWS Distro for OpenTelemetry & Pokeshop API)](./recipes/running-tracetest-with-aws-x-ray-pokeshop.md)
- [Running Tracetest on AWS Fargate with Terraform](./recipes/running-tracetest-with-aws-terraform.md)
- [Running Tracetest with AWS Step Functions, AWS X-Ray and Terraform](./recipes/running-tracetest-with-step-functions-terraform)
- [Running Tracetest with Testkube](./recipes/running-tracetest-with-testkube)

Stay tuned! More recipes are coming soon. 🚀
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Running a Python app with Opentelemetry manual instrumention
# Running a Python app with OpenTelemetry manual instrumention

:::note
[Check out the source code on GitHub here.](https://github.com/kubeshop/tracetest/tree/main/examples/quick-start-python)
[Check out the source code on GitHub here.](https://github.com/kubeshop/tracetest/tree/main/examples/quick-start-python)
:::

[Tracetest](https://tracetest.io/) is a testing tool based on [OpenTelemetry](https://opentelemetry.io/) that allows you to test your distributed application. It allows you to use your telemetry data generated by the OpenTelemetry tools to check and assert if your application has the desired behavior defined by your test definitions.
Expand All @@ -18,23 +19,26 @@ You will need [Docker](https://docs.docker.com/get-docker/) and [Docker Compose]
The project is built with Docker Compose. It contains two distinct `docker-compose.yaml` files.

### 1. Python app

The `docker-compose.yaml` file and `Dockerfile` in the root directory are for the Python app.

### 2. Tracetest

The `docker-compose.yaml` file, `collector.config.yaml`, `tracetest-provision.yaml`, and `tracetest-config.yaml` in the `tracetest` directory are for setting up Tracetest and the OpenTelemetry Collector.

The `tracetest` directory is self-contained and will run all the prerequisites for enabling OpenTelemetry traces and trace-based testing with Tracetest.

### Docker Compose Network

All `services` in the `docker-compose.yaml` are on the same network and will be reachable by hostname from within other services. E.g. `tracetest:21321` in the `collector.config.yaml` will map to the `tracetest` service, where the port `21321` is the port where Tracetest accepts traces.

## Python app

The Python app is a simple Flask app, contained in the `app.py` file.

The code below imports all the Flask, and OpenTelemetry libraries and configures both manual and automatic OpenTelemetry instrumentation.
The code below imports all the Flask, and OpenTelemetry libraries and configures both manual and automatic OpenTelemetry instrumentation.

```
```python
from flask import Flask, request
import json

Expand Down Expand Up @@ -73,7 +77,6 @@ def home():
return "App works."
```


The `Dockerfile` includes bootstrapping the needed OpenTelemetry packages. As you can see it does not have the `CMD` command. Instead, it's configured in the `docker-compose.yaml` below.

```Dockerfile
Expand Down Expand Up @@ -176,7 +179,6 @@ services:

Tracetest depends on both Postgres and the OpenTelemetry Collector. Both Tracetest and the OpenTelemetry Collector require config files to be loaded via a volume. The volumes are mapped from the root directory into the `tracetest` directory and the respective config files.


The `tracetest-config.yaml` file contains the basic setup of connecting Tracetest to the Postgres instance.

```yaml
Expand All @@ -187,19 +189,18 @@ postgres:
port: 5432
dbname: postgres
params: sslmode=disable

```
The `tracetest-provision.yaml` file provisions the trace data store and polling to store in the Postgres database. The data store is set to OTLP meaning the traces will be stored in Tracetest itself.
```yaml

```yaml
---
type: DataStore
spec:
name: OpenTelemetry Collector
type: otlp
isdefault: true
```
```

But how are traces sent to Tracetest?

Expand Down
15 changes: 10 additions & 5 deletions docs/sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,6 @@ const sidebars = {
},
],
},
{
type: "doc",
id: "configuration/opentelemetry-collector-configuration-file-reference",
label: "OpenTelemetry Collector Configuration File Reference",
},
{
type: "doc",
id: "configuration/server",
Expand All @@ -144,6 +139,11 @@ const sidebars = {
id: "configuration/analytics",
label: "Analytics",
},
{
type: "doc",
id: "configuration/opentelemetry-collector-configuration-file-reference",
label: "OpenTelemetry Collector Configuration File Reference",
},
],
},
{
Expand Down Expand Up @@ -386,6 +386,11 @@ const sidebars = {
id: "examples-tutorials/recipes/running-tracetest-without-a-trace-data-store-with-manual-instrumentation",
label: "Node.js with Manual Instrumentation and OpenTelemetry Collector",
},
{
type: "doc",
id: "examples-tutorials/recipes/running-python-app-with-opentelemetry-collector-and-tracetest",
label: "Python with Manual Instrumentation and OpenTelemetry Collector",
},
{
type: "doc",
id: "examples-tutorials/recipes/running-tracetest-with-jaeger",
Expand Down

0 comments on commit aab9683

Please sign in to comment.