Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: improve docs and add python document #1393

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/instrumentations/golang/golang.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ sidebarTitle: "Go"

## Supported Versions

Odigos uses the official [opentelemetry-go-instrumentation](https://github.com/open-telemetry/opentelemetry-go-instrumentation) OpenTelemetry Auto Instrumentation using eBPF, thus it supports the same Node.js versions as this project.
Odigos uses the official [opentelemetry-go-instrumentation](https://github.com/open-telemetry/opentelemetry-go-instrumentation) OpenTelemetry Auto Instrumentation using eBPF, thus it supports the same golang versions as this project.

- Go runtime versions **1.17** and above are supported.

Expand Down
12 changes: 12 additions & 0 deletions docs/instrumentations/nodejs/enrichment.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,17 @@ function my_function() {

Make sure to replace `instrumentation-scope-name` and `instrumentation-scope-version` with the name and version of your instrumented file.

Important Notes:

1. **Always End a span**:
Ensure that every span is ended to appear in your trace. Defer the End method of the span to guarantee that the span is always ended, even with multiple return paths in the function.
tamirdavid1 marked this conversation as resolved.
Show resolved Hide resolved
2. **Propagate and use a valid context object**:
When calling tracer.Start, use a valid context object instead of context.Background(). This makes the new span a child of the active span, ensuring it appears correctly in the trace.
3. **Pass the context object downstream**:
When calling downstream functions, pass the context object returned from tracer.Start() to ensure any spans created within these functions are children of the current span. This maintains the hierarchical relationship between spans and provides a clear trace of the request flow.
tamirdavid1 marked this conversation as resolved.
Show resolved Hide resolved
4. **Assign meaningful names to spans**:
Use descriptive names for spans, (such as the function name) to clearly describe the operations they represent. This helps anyone examining the trace to easily understand the span's purpose and context.
5. **Avoid dynamic, high cardinality data in span names**:
Do not include dynamic data such as IDs in the span name, as this can cause performance issues and make the trace harder to read. Instead, use static, descriptive names for spans and record dynamic information in span attributes. This ensures better performance and readability of the trace.


96 changes: 96 additions & 0 deletions docs/instrumentations/python/enrichment.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@

---
title: "Enriching Python OpenTelemetry Data"
sidebarTitle: "Enrichment"
---

Odigos will automatically instrument your Python services and record semantic spans from popular modules.
Many users find the automatic instrumentation data sufficient for their needs. However, if there is anything specific to your application that you want to record, you can enrich the data by adding custom spans to your code.

This is sometimes referred to as "manual instrumentation"

## Required dependencies

Install the API from PyPI using pip:

```bash
pip install opentelemetry-api
```

## Creating Spans

To create a span, use the `tracer` object from the `opentelemetry.trace` module. The `tracer` object is a factory for creating spans.

```python
from opentelemetry import trace

tracer = trace.get_tracer(__name__)

def my_function():
with tracer.start_as_current_span("my_function") as span:
print("Hello world!")
```

Important Notes:

1. **Assign meaningful names to spans**:
Use descriptive names for spans, (such as the function name) to clearly describe the operations they represent. This helps anyone examining the trace to easily understand the span's purpose and context.
2. **Avoid dynamic, high cardinality data in span names**:
Do not include dynamic data such as IDs in the span name, as this can cause performance issues and make the trace harder to read. Instead, use static, descriptive names for spans and record dynamic information in span attributes. This ensures better performance and readability of the trace.



### Recording Span Attributes

Span attributes are key-value pairs that record additional information about an operation, which can be useful for debugging, performance analysis, or troubleshooting

Examples:

- User ID, organization ID, Account ID or other identifiers.
- Inputs - the relevant parameters or configuration that influenced the operation.
- Outputs - the result of the operation.
- Entities - the entities or resources that the operation interacted with.

Attribute names are lowercased strings in the form `my_application.my_attribute`, example: `my_service.user_id`.
Read more [here](https://opentelemetry.io/docs/specs/semconv/general/attribute-naming/)

To record attributes, use the `set_attribute` method on the span object.

``` python
def my_function(arg: str):
with tracer.start_as_current_span("my_function") as span:
span.set_attribute("argument_name", arg)
```

Important Notes:

1. **Be cautious when recording data**:
Avoid including PII (personally identifiable information) or any data you do not wish to expose in your traces.
2. **Attribute cost considerations**:
Each attribute affects performance and processing time. Record only what is necessary and avoid superfluous data.
3. **Use static names for attributes**:
Avoid dynamic content such as IDs in attribute keys. Use static names and properly namespace them (scope.attribute_name) to provide clear context for downstream consumers.
4. **Adhere to OpenTelemetry semantic conventions**:
Prefer using namespaces and attribute names from the OpenTelemetry semantic conventions to enhance data interoperability and make it easier for others to understand.


## Recording Errors

To easily identify and monitor errors in your traces, the Span object includes a status field that can be used to mark the span as an error. This helps in spotting errors in trace viewers, sampling, and setting up alerts.

If an operation you are tracing fails, you can mark the span's status as an error and record the error details within the span. Here's how you can do it:

- An exception has been raised to demonstrate an error that occurred in your code.

``` python

def my_function():
with tracer.start_as_current_span("my_function") as span:
try:
print("Hello world!")
raise Exception("Some Exception")
except Exception as e:
span.record_exception(e)
span.set_status(trace.Status(trace.StatusCode.ERROR, str(e)))

```
88 changes: 88 additions & 0 deletions docs/instrumentations/python/python.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
---
title: "Python Automatic Instrumentation"
sidebarTitle: "Python"
---

## Supported Versions

Odigos uses the official [opentelemetry-python-instrumentation](https://github.com/open-telemetry/opentelemetry-python-contrib/tree/main/instrumentation) OpenTelemetry Auto Instrumentation, thus it supports the same Python versions as this project.

- In the enterprise version, Odigos leverages eBPF to enhance performance in the Python instrumentation process.

- Python runtime versions 3.8 and above are supported.


## Traces

Odigos will automatically instrument your Python services to record and collect spans for distributed tracing, by utilizing the OpenTelemetry Python official auto Instrumentation Libraries.

## Instrumentation Libraries

The following Python modules will be auto instrumented by Odigos:

### Database Clients, ORMs, and Data Access Libraries
- [`aiopg`](https://pypi.org/project/aiopg/) versions `aiopg >= 0.13.0, < 2.0.0`
- [`dbapi`](https://opentelemetry-python-contrib.readthedocs.io/en/latest/instrumentation/dbapi/dbapi.html)
- [`mysql`](https://pypi.org/project/mysql-connector-python/) version `mysql-connector-python >= 8.0.0, < 9.0.0`
- [`mysqlclient`](https://pypi.org/project/mysqlclient/) version `mysqlclient < 3.0.0`
- [`psycopg`](https://pypi.org/project/psycopg/) versions `psycopg >= 3.1.0`
- [`psycopg2`](https://pypi.org/project/psycopg2/) versions `psycopg2 >= 2.7.3.1`
- [`pymemcache`](https://pypi.org/project/pymemcache/) versions `pymemcache >= 1.3.5, < 5.0.0`
- [`pymongo`](https://pypi.org/project/pymongo/) versions `pymongo >= 3.1, < 5.0.0`
- [`pymysql`](https://pypi.org/project/PyMySQL/) versions `pymysql < 2.0.0`
- [`redis`](https://pypi.org/project/redis/) versions `redis >= 2.6`
- [`sqlalchemy`](https://pypi.org/project/SQLAlchemy/)
- [`sqlite3`](https://docs.python.org/3/library/sqlite3.html)
- [`tortoiseorm`](https://pypi.org/project/tortoise-orm/) versions `tortoise-orm >= 0.17.0`, `pydantic >= 1.10.2`
- [`cassandra`](https://pypi.org/project/cassandra-driver/) versions `cassandra-driver >= 3.25.0, < 4.0.0`, `scylla-driver >= 3.25.0, < 4.0.0`
- [`elasticsearch`](https://pypi.org/project/elasticsearch/) versions `elasticsearch >= 6.0.0`
- [`asyncpg`](https://pypi.org/project/asyncpg/) versions `asyncpg >= 0.12.0`

### HTTP Frameworks
- [`asgi`](https://pypi.org/project/asgiref/) versions `asgiref >= 3.0.0, < 4.0.0`
- [`django`](https://pypi.org/project/Django/) versions `django >= 1.10.0`
- [`fastapi`](https://pypi.org/project/fastapi/) versions `fastapi >= 0.58.0, < 0.59.0`, `fastapi-slim >= 0.111.0, < 0.112.0`
- [`flask`](https://pypi.org/project/Flask/) versions `flask >= 1.0.0`
- [`pyramid`](https://pypi.org/project/pyramid/) versions `pyramid >= 1.7.0`
- [`starlette`](https://pypi.org/project/starlette/) versions `starlette >= 0.13.0, < 0.14.0`
- [`falcon`](https://pypi.org/project/falcon/) versions `falcon >= 1.4.1, < 3.1.2`
- [`tornado`](https://pypi.org/project/tornado/) versions `tornado >= 5.1.1`

### HTTP Clients
- [`aiohttp-client`](https://pypi.org/project/aiohttp/) versions `aiohttp >= 3.0.0, < 4.0.0`
- [`httpx`](https://pypi.org/project/httpx/) versions `httpx >= 0.18.0`
- [`requests`](https://pypi.org/project/requests/) versions `requests >= 2.0.0, < 3.0.0`
- [`urllib`](https://docs.python.org/3/library/urllib.html)
- [`urllib3`](https://pypi.org/project/urllib3/) versions `urllib3 >= 1.0.0, < 3.0.0`

### Messaging Systems Clients
- [`aio-pika`](https://pypi.org/project/aio-pika/) versions `aio_pika >= 7.2.0, < 10.0.0`
- [`celery`](https://pypi.org/project/celery/) versions `celery >= 4.0.0, < 6.0.0`
- [`confluent-kafka`](https://pypi.org/project/confluent-kafka/) versions `confluent-kafka >= 1.8.2, <= 2.4.0`
- [`kafka-python`](https://pypi.org/project/kafka-python/) versions `kafka-python >= 2.0.0`
- [`pika`](https://pypi.org/project/pika/) versions `pika >= 0.12.0`
- [`remoulade`](https://pypi.org/project/remoulade/) versions `remoulade >= 0.50.0`

### RPC (Remote Procedure Call)
- [`grpc`](https://pypi.org/project/grpcio/) versions `grpcio >= 1.27.0, < 2.0.0`

### Web Servers
- [`aiohttp-server`](https://pypi.org/project/aiohttp/) versions `aiohttp >= 3.0.0, < 4.0.0`
- [`wsgi`](https://docs.python.org/3/library/wsgiref.html)

### Cloud Services and SDKs
- [`boto`](https://pypi.org/project/boto/) versions `boto >= 2.0.0, < 3.0.0`
- [`boto3sqs`](https://pypi.org/project/boto3/) versions `boto3 >= 1.0.0, < 2.0.0`
- [`botocore`](https://pypi.org/project/botocore/) versions `botocore >= 1.0.0, < 2.0.0`

### Framework and Library Utilities
- [`jinja2`](https://pypi.org/project/Jinja2/) versions `jinja2 >= 2.7, < 4.0`

### Other
- [`asyncio`](https://pypi.org/project/asyncio/)

### Loggers

Automatic injection of trace context (trace id and span id) into log records for the following loggers:

- [`logging`](https://docs.python.org/3/library/logging.html)
9 changes: 8 additions & 1 deletion docs/mint.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,14 @@
"instrumentations/nodejs/nodejs",
"instrumentations/nodejs/enrichment"
]
}
},
{
"group": "Python",
"pages": [
"instrumentations/python/python",
"instrumentations/python/enrichment"
]
}
]
},
{
Expand Down
6 changes: 4 additions & 2 deletions docs/pipeline/actions/sampling/introduction.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
title: "Sampling Actions Introduction"
sidebarTitle: "Introduction"
---
> **Note:**
> This feature is in beta. It may be subject to changes and improvements based on user feedback.

<Warning>
This feature is in beta. It may be subject to changes and improvements based on user feedback.
</Warning>


Sampling Actions allow you to configure various types of sampling methods before exporting traces to your Odigos Destinations.
Expand Down
Loading