mirror of
https://github.com/deepset-ai/haystack.git
synced 2025-12-27 15:08:43 +00:00
* feat: add opentelemetry tracer * feat: implement auto enable for `OpenTelemetry` * docs: add release notes * style: fix linting * tests: more test coverage * refactor: fix old method call * docs: fix duplicate `the` Co-authored-by: Massimiliano Pippi <mpippi@gmail.com> --------- Co-authored-by: Massimiliano Pippi <mpippi@gmail.com>
40 lines
1.8 KiB
YAML
40 lines
1.8 KiB
YAML
---
|
|
features:
|
|
- |
|
|
Added out-of-the-box support for the OpenTelemetry Tracer. This allows you to instrument pipeline and component
|
|
runs using OpenTelemetry and send traces to your preferred backend.
|
|
|
|
To use the OpenTelemetry Tracer you need to have the `opentelemetry-sdk` package installed in your environment.
|
|
To instruct Haystack to use the OpenTelemetry Tracer, you have multiple options:
|
|
|
|
* Run your Haystack application using the `opentelemetry-instrument` command line tool as described in the
|
|
[OpenTelemetry documentation](https://opentelemetry.io/docs/languages/python/automatic/#configuring-the-agent).
|
|
This behavior can be disabled by setting the `HAYSTACK_AUTO_TRACE_ENABLED_ENV_VAR` environment variable to `false`.
|
|
* Configure the tracer manually in your code using the `opentelemetry` package:
|
|
```python
|
|
from opentelemetry import trace
|
|
from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter
|
|
from opentelemetry.sdk.trace import TracerProvider
|
|
from opentelemetry.sdk.trace.export import BatchSpanProcessor
|
|
|
|
# Service name is required for most backends
|
|
resource = Resource(attributes={
|
|
SERVICE_NAME: "haystack"
|
|
})
|
|
|
|
traceProvider = TracerProvider(resource=resource)
|
|
processor = BatchSpanProcessor(OTLPSpanExporter(endpoint="http://localhost:4318/v1/traces"))
|
|
traceProvider.add_span_processor(processor)
|
|
trace.set_tracer_provider(traceProvider)
|
|
|
|
# Auto-configuration
|
|
import haystack.tracing
|
|
haystack.tracing.auto_enable_tracing()
|
|
|
|
# Or explicitly
|
|
from haystack.tracing import OpenTelemetryTracer
|
|
|
|
tracer = traceProvider.get_tracer("my_application")
|
|
tracing.enable_tracing(OpenTelemetryTracer(tracer))
|
|
```
|