{"id":18183638,"url":"https://github.com/yashsahsani/dynatrax","last_synced_at":"2026-04-16T04:02:23.595Z","repository":{"id":260782424,"uuid":"882328543","full_name":"YashSahsani/Dynatrax","owner":"YashSahsani","description":"Dynatrax enables comprehensive observability for Flask applications, integrating OpenTelemetry to provide real-time metrics, traces, and logs directly to Dynatrace.","archived":false,"fork":false,"pushed_at":"2024-11-04T02:35:00.000Z","size":15,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-13T14:41:32.994Z","etag":null,"topics":["alerting","dynatrace","dynatrace-oneagent","dynatrace-setup","dynatracemonitoring","flask","flask-application","monitoring-tool","opentelemetry","opentelemetry-collector","opentelemetry-exporter","opentelemetry-python","python3"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/YashSahsani.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-11-02T14:32:48.000Z","updated_at":"2024-11-04T02:35:04.000Z","dependencies_parsed_at":null,"dependency_job_id":"a7bcf4d6-6b5a-40d7-a174-5ed3b9e35540","html_url":"https://github.com/YashSahsani/Dynatrax","commit_stats":null,"previous_names":["yashsahsani/dynatrax"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YashSahsani%2FDynatrax","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YashSahsani%2FDynatrax/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YashSahsani%2FDynatrax/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YashSahsani%2FDynatrax/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/YashSahsani","download_url":"https://codeload.github.com/YashSahsani/Dynatrax/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247648911,"owners_count":20972942,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["alerting","dynatrace","dynatrace-oneagent","dynatrace-setup","dynatracemonitoring","flask","flask-application","monitoring-tool","opentelemetry","opentelemetry-collector","opentelemetry-exporter","opentelemetry-python","python3"],"created_at":"2024-11-02T20:03:41.854Z","updated_at":"2026-04-16T04:02:18.473Z","avatar_url":"https://github.com/YashSahsani.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Dynatrax\n\n**Dynatrax** is an observability solution that integrates OpenTelemetry with Dynatrace for a Python Flask application. It enables you to capture, track, and analyze traces, metrics, and logs in real-time, giving you deep insights into your application’s health and performance.\n\n## Table of Contents\n\n- [Introduction](#introduction)\n- [Features](#features)\n- [Setup and Installation](#setup-and-installation)\n  - [Prerequisites](#prerequisites)\n  - [Environment Variables](#environment-variables)\n- [Project Structure](#project-structure)\n- [Usage](#usage)\n  - [Running the Application](#running-the-application)\n  - [Generating Sample Traces and Metrics](#generating-sample-traces-and-metrics)\n- [OpenTelemetry Configuration](#opentelemetry-configuration)\n- [Troubleshooting](#troubleshooting)\n- [Contributing](#contributing)\n- [License](#license)\n\n---\n\n## Introduction\n\nDynatrax provides an easy way to instrument a Flask application using OpenTelemetry and Dynatrace. By automatically exporting traces, metrics, and logs, Dynatrax enables in-depth observability for debugging and performance monitoring.\n\n## Features\n\n- **Tracing**: Tracks and visualizes the flow of requests through your application, giving insights into request paths and latencies.\n- **Metrics**: Monitors and records key metrics to assess application health and performance.\n- **Logging**: Provides structured logging, sent directly to Dynatrace, to support diagnostics and troubleshooting.\n\n## Setup and Installation\n\nFollow these steps to set up Dynatrax in your environment.\n\n### Prerequisites\n\n- Python 3.7+\n- [Dynatrace account](https://www.dynatrace.com/), with access to create API tokens.\n- Recommended: A virtual environment to isolate dependencies.\n\n### Environment Variables\n\nDynatrax requires the following environment variables to communicate with Dynatrace:\n\n- `DT_API_URL`: The base URL for Dynatrace API (e.g., `https://your-dynatrace-domain/api/v2/otlp`)\n- `DT_API_TOKEN`: Your Dynatrace API token with the necessary scopes (ingest traces, metrics, logs).\n\n### Installation Steps\n\n1. **Clone the repository**:\n   ```bash\n   git clone \n   cd Dynatrax\n   ```\n2. **Setup virtualenv**:\n    ```bash\n    python3 -m venv .venv\n    source .venv\\bin\\activate\n    ```\n2. **Install dependencies**:\n    \n   \n    \n    ```bash\n    pip install -r requirements.txt\n    ```\n    \n3. **Set up environment variables**: Configure your environment variables by creating a `.env` file or exporting them directly in the terminal.\n    \n    `.env` example:\n    \n    \n    \n    ```bash\n    DT_API_URL=https://your-dynatrace-domain/api/v2/otlp\n    DT_API_TOKEN=your_dynatrace_api_token\n     ```\n    \n5. **Initialize OpenTelemetry components**:\n    \n    - Dynatrax uses OpenTelemetry SDKs for manual instrumentation of traces, metrics, and logs.\n    [here](https://docs.dynatrace.com/docs/extend-dynatrace/opentelemetry/walkthroughs/python/python-manual)\n    - Verify your `requirements.txt` includes necessary OpenTelemetry packages:\n        `opentelemetry-api opentelemetry-sdk opentelemetry-exporter-otlp-proto-http Flask`\n        \n\n## Project Structure\n\n\n```\n Dynatrax/ \n    ├──  opentelemetry_tracer.py\n    ├── app.py             # Main application file \n    ├── README.md          # Project documentation\n    ├── requirements.txt   # Python dependencies \n    └── .env               # Environment variables (not included in repository) \n```\n\n## Usage\n\n### Running the Application\n\nTo run Dynatrax, execute the following command:\n\n```\npython app.py\n```\n\nThe app should start on `http://localhost:5000`. You can visit this URL to generate sample traces and metrics.\n\n### Generating Sample Traces and Metrics\n\nDynatrax includes sample endpoints for testing:\n\n1. **`/` Endpoint**: The home route that triggers a simple trace.\n2. **`/greet/\u003cname\u003e` Endpoint**: Greets the user by name and captures a custom trace with the user’s name.\n\nExample:\n\n\n```bash\ncurl http://localhost:5000/greet/John\n```\n\nThis will generate a trace in Dynatrace showing the request path, response time, and any custom attributes.\n\n## OpenTelemetry Configuration\n\nOpenTelemetry settings are configured in `app.py`:\n\n- **Tracing**: The `TracerProvider` and `BatchSpanProcessor` are initialized, and traces are sent to Dynatrace.\n- **Metrics**: A `MeterProvider` is set up to capture basic metrics (e.g., request counts, durations).\n- **Logging**: `LoggerProvider` enables sending structured logs directly to Dynatrace.\n\n\n## Troubleshooting\n\n1. **No Data in Dynatrace**:\n    \n    - Ensure that `DT_API_URL` and `DT_API_TOKEN` are correctly set and accessible.\n    - Verify that your Dynatrace token has the necessary scopes: `metrics.ingest`, `logs.ingest`, `traces.ingest`.\n      \n2. **Connection Errors**:\n    - Check that you’re using the correct API URL format: `https://\u003cyour_dynatrace_url\u003e/api/v2/otlp`.\n    - Confirm network connectivity from your application to Dynatrace.\n    \n\n## **Execution Summary**:\n\n\n\n1) It creates a service \n\u003cimg width=\"1332\" alt=\"image\" src=\"https://github.com/user-attachments/assets/f62c8753-fe81-4f9f-b417-12d2aae45617\"\u003e\n2) Add Custom metrics\n\u003cimg width=\"1332\" alt=\"Screenshot 2024-11-03 at 9 28 25 PM\" src=\"https://github.com/user-attachments/assets/295981ce-8468-4845-86bc-3efa02152d79\"\u003e\n3) New Distributed Traces look\n\u003cimg width=\"1293\" alt=\"Screenshot 2024-11-03 at 9 25 59 PM\" src=\"https://github.com/user-attachments/assets/d35099a8-7405-4f01-b2f7-204746aaca35\"\u003e\n\u003cimg width=\"1332\" alt=\"Screenshot 2024-11-03 at 9 29 12 PM\" src=\"https://github.com/user-attachments/assets/a6e0530c-b109-478d-bea2-a2098b214630\"\u003e\n4) Classic Distributed Traces look\n\u003cimg width=\"1332\" alt=\"Screenshot 2024-11-03 at 9 31 09 PM\" src=\"https://github.com/user-attachments/assets/ff340ff1-1009-4b58-8c70-c6fed03edd21\"\u003e\n\u003cimg width=\"1332\" alt=\"Screenshot 2024-11-03 at 9 31 24 PM\" src=\"https://github.com/user-attachments/assets/8c3d364a-f55d-4bf8-b24c-1495f6b8dd72\"\u003e\n\u003cimg width=\"1332\" alt=\"Screenshot 2024-11-03 at 9 31 28 PM\" src=\"https://github.com/user-attachments/assets/3abdde24-1425-4779-90dd-9f773c8733fa\"\u003e\n\n\n\n\n\n## TODO:\n\n1) Send Logs to Dynatrace\n\n## Contributing:\n\nContributions are welcome! Please fork the repository and submit a pull request.\n\n## License:\n\nDynatrax is open-source and available under the MIT License. See `LICENSE` for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyashsahsani%2Fdynatrax","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyashsahsani%2Fdynatrax","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyashsahsani%2Fdynatrax/lists"}