diff --git a/daprdocs/content/en/developing-applications/dapr-agents/dapr-agents-introduction.md b/daprdocs/content/en/developing-applications/dapr-agents/dapr-agents-introduction.md index 17cc7dcf7f1..0e860f4985b 100644 --- a/daprdocs/content/en/developing-applications/dapr-agents/dapr-agents-introduction.md +++ b/daprdocs/content/en/developing-applications/dapr-agents/dapr-agents-introduction.md @@ -77,6 +77,7 @@ Dapr Agents inherits Dapr's enterprise-grade operational capabilities, providing ### Built-in Operational Features - **[Observability]({{% ref observability-concept.md %}})** - Distributed tracing, metrics collection, and logging for agent interactions and workflow execution +- **[Logging for Dapr Agents]({{% ref "operations/observability/logging/dapr-agents.md" %}})** - Setup of logging and OpenTelemetry integration - **[Security]({{% ref security-concept.md %}})** - mTLS encryption, access control, and secrets management for secure agent communication - **[Resiliency]({{% ref resiliency-concept.md %}})** - Automatic retries, circuit breakers, and timeout policies for fault-tolerant agent operations - **[Infrastructure Abstraction]({{% ref components-concept.md %}})** - Dapr components abstract LLM providers, memory stores, storage and messaging backends, enabling seamless transitions between different environments diff --git a/daprdocs/content/en/operations/observability/logging/dapr-agents.md b/daprdocs/content/en/operations/observability/logging/dapr-agents.md new file mode 100644 index 00000000000..b7652c8bd1f --- /dev/null +++ b/daprdocs/content/en/operations/observability/logging/dapr-agents.md @@ -0,0 +1,54 @@ +--- +type: docs +title: "How-To: Set up logging for Dapr Agents" +linkTitle: "Dapr Agents" +weight: 2000 +description: "How to set up logging for Dapr Agents" +--- + +## Prerequisites + +You'll need to make install the required packages: + +```sh +openinference-instrumentation>=0.1.42 +openinference-semantic-conventions>=0.1.25 +opentelemetry-api>=1.39.0 +opentelemetry-exporter-otlp>=1.39.0 +opentelemetry-exporter-zipkin-json>=1.39.0 +opentelemetry-instrumentation-requests>=0.60b0 +opentelemetry-instrumentation-grpc>=0.60b0 +opentelemetry-proto>=1.39.0 +``` + +## Setup + +Dapr Agents has bindings for using OpenTelemetry for instrumentation. This means you can use a common Python logger to set the required log level (`DEBUG`, `INFO`, `WARNING` and `ERROR`): + +```python +import logging + +logging.basicConfig(level=logging.WARNING) +``` + +This log level will propagate to all third party libraries. + +### OpenTelemetry integration + +Dapr Agents support OpenTelemetry by setting the appropriate provider and processor: + +```python +from opentelemetry import _logs +from opentelemetry.sdk._logs import LoggerProvider +from opentelemetry.sdk._logs.export import BatchLogRecordProcessor, ConsoleLogRecordExporter +from dapr_agents.observability import DaprAgentsInstrumentor + +logger_provider = LoggerProvider() +log_processor = BatchLogRecordProcessor(ConsoleLogRecordExporter()) +logger_provider.add_log_record_processor(log_processor) +_logs.set_logger_provider(logger_provider) +instrumentor = DaprAgentsInstrumentor() +instrumentor.instrument(logger_provider=logger_provider, skip_dep_check=True) +``` + +Please refer to the current release level for the [Python SDK of OpenTelemetry](https://opentelemetry.io/docs/languages/python/) as the logs API is currently in `development` state. \ No newline at end of file diff --git a/daprdocs/content/en/operations/observability/logging/fluentd.md b/daprdocs/content/en/operations/observability/logging/fluentd.md index c678cda1e27..28ce2b13d47 100644 --- a/daprdocs/content/en/operations/observability/logging/fluentd.md +++ b/daprdocs/content/en/operations/observability/logging/fluentd.md @@ -2,7 +2,7 @@ type: docs title: "How-To: Set up Fluentd, Elastic search and Kibana in Kubernetes" linkTitle: "FluentD" -weight: 2000 +weight: 3000 description: "How to install Fluentd, Elastic Search, and Kibana to search logs in Kubernetes" --- diff --git a/daprdocs/content/en/operations/observability/logging/newrelic.md b/daprdocs/content/en/operations/observability/logging/newrelic.md index 9261d09ab44..3069ed24040 100644 --- a/daprdocs/content/en/operations/observability/logging/newrelic.md +++ b/daprdocs/content/en/operations/observability/logging/newrelic.md @@ -2,7 +2,7 @@ type: docs title: "How-To: Set-up New Relic for Dapr logging" linkTitle: "New Relic" -weight: 3000 +weight: 4000 description: "Set-up New Relic for Dapr logging" ---