{"id":23640753,"url":"https://github.com/ivanildobarauna-dev/open-o11y-wrapper","last_synced_at":"2025-08-07T00:41:43.927Z","repository":{"id":269091105,"uuid":"906394833","full_name":"ivanildobarauna-dev/open-o11y-wrapper","owner":"ivanildobarauna-dev","description":"OpenTelemetry Wrapper to send traces, metrics and logs to my otel-proxy using OTLP Protocol","archived":false,"fork":false,"pushed_at":"2025-02-10T22:07:32.000Z","size":75,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-02-10T23:20:41.417Z","etag":null,"topics":["open-o11y"],"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/ivanildobarauna-dev.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-12-20T20:06:09.000Z","updated_at":"2025-02-10T22:06:39.000Z","dependencies_parsed_at":null,"dependency_job_id":"c760322b-e6ce-42b1-98cd-6ccf280f00f9","html_url":"https://github.com/ivanildobarauna-dev/open-o11y-wrapper","commit_stats":null,"previous_names":["ivanildobarauna-dev/otel-wrapper","ivanildobarauna-dev/open-o11y-wrapper"],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivanildobarauna-dev%2Fopen-o11y-wrapper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivanildobarauna-dev%2Fopen-o11y-wrapper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivanildobarauna-dev%2Fopen-o11y-wrapper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivanildobarauna-dev%2Fopen-o11y-wrapper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ivanildobarauna-dev","download_url":"https://codeload.github.com/ivanildobarauna-dev/open-o11y-wrapper/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239579052,"owners_count":19662541,"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":["open-o11y"],"created_at":"2024-12-28T09:51:18.871Z","updated_at":"2025-08-07T00:41:43.889Z","avatar_url":"https://github.com/ivanildobarauna-dev.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# OpenTelemetry Wrapper\n\n[![Python Tests](https://github.com/ivanildobarauna-dev/open-o11y-wrapper/actions/workflows/python-tests.yml/badge.svg)](https://github.com/ivanildobarauna-dev/open-o11y-wrapper/actions/workflows/python-tests.yml)\n\nA comprehensive Python wrapper for OpenTelemetry that simplifies sending traces, metrics, and logs using the OTLP protocol.\n\n## Features\n\n- **Unified API** for traces, metrics, and logs\n- **Simple configuration** with reasonable defaults\n- **Configurable endpoints** for each signal type (traces, metrics, logs)\n- **Distributed tracing** with context propagation helpers\n- **Multiple metric types** (counters, gauges, histograms)\n- **Error handling** with graceful fallbacks\n- **Singleton pattern** ensures consistent resources across your application\n\n## Installation\n\n```bash\npip install otel-wrapper\n```\n\nOr with Poetry:\n\n```bash\npoetry add otel-wrapper\n```\n\n## Quick Start\n\n```python\nfrom otel_wrapper.deps_injector import wrapper_builder\n\n# Initialize the wrapper with your application name\ntelemetry = wrapper_builder(\"my-application\")\n\n# Create a trace\nwith telemetry.traces().span_in_context(\"my-operation\") as (span, context):\n    # Add span attributes\n    span.set_attribute(\"operation.type\", \"example\")\n    \n    # Create a log\n    telemetry.logs().new_log(\n        msg=\"Operation in progress\", \n        tags={\"operation\": \"my-operation\"}, \n        level=20  # INFO level\n    )\n    \n    # Record a metric\n    telemetry.metrics().metric_increment(\n        name=\"operations.count\", \n        tags={\"operation\": \"my-operation\"}, \n        value=1.0\n    )\n```\n\n## Configuration\n\nThe wrapper can be configured using environment variables:\n\n- `OTEL_EXPORTER_OTLP_ENDPOINT`: Default endpoint for all signals\n- `OTEL_EXPORTER_OTLP_TRACES_ENDPOINT`: Endpoint for traces\n- `OTEL_EXPORTER_OTLP_METRICS_ENDPOINT`: Endpoint for metrics\n- `OTEL_EXPORTER_OTLP_LOGS_ENDPOINT`: Endpoint for logs\n- `OTEL_LOG_LEVEL`: Log level (DEBUG, INFO, WARNING, ERROR, CRITICAL)\n- `__SCOPE__`: Application environment (defaults to \"Production\")\n\n## API Reference\n\n### Traces\n\n```python\n# Create a simple span\nspan = telemetry.traces().new_span(\"my-span\")\nspan.set_attribute(\"attribute.name\", \"value\")\nspan.end()\n\n# Use span as a context manager\nwith telemetry.traces().span_in_context(\"my-span\") as (span, context):\n    # Do something with the span\n    pass\n\n# Context propagation\nheaders = {}\ntelemetry.traces().inject_context_into_headers(headers)\n\n# Extract context from headers\ncontext = telemetry.traces().extract_context_from_headers(headers)\n```\n\n### Metrics\n\n```python\n# Increment a counter\ntelemetry.metrics().metric_increment(\n    name=\"requests.count\", \n    tags={\"endpoint\": \"/api/users\"}, \n    value=1.0\n)\n\n# Record a gauge value\ntelemetry.metrics().record_gauge(\n    name=\"system.memory.usage\", \n    tags={\"host\": \"server-01\"}, \n    value=1024.5\n)\n\n# Record a histogram value\ntelemetry.metrics().record_histogram(\n    name=\"request.duration\", \n    tags={\"endpoint\": \"/api/users\"}, \n    value=0.156\n)\n```\n\n### Logs\n\n```python\n# Create a simple log\ntelemetry.logs().new_log(\n    msg=\"User logged in\", \n    tags={\"user_id\": \"123\"}, \n    level=20  # INFO level\n)\n\n# Get the logger directly\nlogger = telemetry.logs().get_logger()\nlogger.info(\"Message with structured data\", extra={\"key\": \"value\"})\n```\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n## License\n\nThis project is licensed under the MIT License - see the LICENSE file for details.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fivanildobarauna-dev%2Fopen-o11y-wrapper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fivanildobarauna-dev%2Fopen-o11y-wrapper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fivanildobarauna-dev%2Fopen-o11y-wrapper/lists"}