-
Notifications
You must be signed in to change notification settings - Fork 87
adding SigNoz OpenTelemetry demo #145
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
Open
gkarthi-signoz
wants to merge
1
commit into
pipecat-ai:main
Choose a base branch
from
gkarthi-signoz:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| FROM dailyco/pipecat-base:latest | ||
|
|
||
| # Enable bytecode compilation | ||
| ENV UV_COMPILE_BYTECODE=1 | ||
|
|
||
| # Copy from the cache instead of linking since it's a mounted volume | ||
| ENV UV_LINK_MODE=copy | ||
|
|
||
| # Install the project's dependencies using the lockfile and settings | ||
| RUN --mount=type=cache,target=/root/.cache/uv \ | ||
| --mount=type=bind,source=uv.lock,target=uv.lock \ | ||
| --mount=type=bind,source=pyproject.toml,target=pyproject.toml \ | ||
| uv sync --locked --no-install-project --no-dev | ||
|
|
||
| # Copy the application code | ||
| COPY ./bot.py bot.py |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| # PipeCat Monitoring with SigNoz | ||
|
|
||
| This demo shows [SigNoz](https://signoz.io/) observability integration with Pipecat via OpenTelemetry, allowing you to visualize traces, logs, and metrics from your Pipecat application usage. | ||
|
|
||
| ## Setup Instructions | ||
|
|
||
| ### Step 1: Clone this demo voice agent project and setup dependencies | ||
|
|
||
| ```bash | ||
| git clone https://github.com/pipecat-ai/pipecat-examples.git | ||
| cd pipecat-examples/open-telemetry/signoz | ||
| uv sync | ||
| ``` | ||
| ### Step 2: Setup Credentials | ||
|
|
||
| Copy .env.example to .env and filling in the required keys: | ||
|
|
||
| - `DEEPGRAM_API_KEY` | ||
| - `OPENAI_API_KEY` | ||
| - `CARTESIA_API_KEY` | ||
|
|
||
|
|
||
| ### Step 3: Add Automatic Instrumentation | ||
|
|
||
| ```bash | ||
| uv pip install opentelemetry-distro opentelemetry-exporter-otlp | ||
| uv run opentelemetry-bootstrap -a requirements | uv pip install --requirement - | ||
| ``` | ||
|
|
||
| ### Step 4: Run your application with auto-instrumentation | ||
|
|
||
|
|
||
| ```bash | ||
| OTEL_RESOURCE_ATTRIBUTES="service.name=<service_name>" \ | ||
| OTEL_EXPORTER_OTLP_ENDPOINT="https://ingest.<region>.signoz.cloud:443" \ | ||
| OTEL_EXPORTER_OTLP_HEADERS="signoz-ingestion-key=<your_ingestion_key>" \ | ||
| OTEL_EXPORTER_OTLP_PROTOCOL=grpc \ | ||
| OTEL_TRACES_EXPORTER=otlp \ | ||
| OTEL_METRICS_EXPORTER=otlp \ | ||
| OTEL_LOGS_EXPORTER=otlp \ | ||
| OTEL_PYTHON_LOG_CORRELATION=true \ | ||
| OTEL_PYTHON_LOGGING_AUTO_INSTRUMENTATION_ENABLED=true \ | ||
| <your_run_command with opentelemetry-instrument> | ||
| ``` | ||
|
|
||
| - `<service_name>` is the name of your service | ||
| - Set the `<region>` to match your SigNoz Cloud [region](https://signoz.io/docs/ingestion/signoz-cloud/overview/#endpoint) | ||
| - Replace `<your_ingestion_key>` with your SigNoz [ingestion key](https://signoz.io/docs/ingestion/signoz-cloud/keys/) | ||
| - Replace `<your_run_command>` with the actual command you would use to run your application. In this case we would use: `uv run opentelemetry-instrument python bot.py` | ||
|
|
||
|
|
||
| > Note: Using self-hosted SigNoz? Most steps are identical. To adapt this guide, update the endpoint and | ||
| remove the ingestion key header as shown in [Cloud → Self-Hosted](https://signoz.io/docs/ingestion/cloud-vs-self-hosted/#cloud-to-self-hosted). | ||
|
|
||
| Open http://localhost:7860 in your browser and click `Connect` to start talking to your bot. | ||
|
|
||
| You will now be able to see traces, logs, and metrics from your Pipecat usage in your SigNoz platform. | ||
|
|
||
| ## References | ||
|
|
||
| - [SigNoz PipeCat Documentation](https://signoz.io/docs/pipecat-monitoring/) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,156 @@ | ||
| # | ||
| # Copyright (c) 2024–2025, Daily | ||
| # | ||
| # SPDX-License-Identifier: BSD 2-Clause License | ||
| # | ||
|
|
||
| """Pipecat Quickstart Example. | ||
|
|
||
| The example runs a simple voice AI bot that you can connect to using your | ||
| browser and speak with it. You can also deploy this bot to Pipecat Cloud. | ||
|
|
||
| Required AI services: | ||
| - Deepgram (Speech-to-Text) | ||
| - OpenAI (LLM) | ||
| - Cartesia (Text-to-Speech) | ||
|
|
||
| Run the bot using:: | ||
|
|
||
| uv run bot.py | ||
| """ | ||
|
|
||
| import os | ||
|
|
||
| from dotenv import load_dotenv | ||
| from loguru import logger | ||
|
|
||
| print("🚀 Starting Pipecat bot...") | ||
| print("⏳ Loading models and imports (20 seconds, first run only)\n") | ||
|
|
||
| logger.info("Loading Local Smart Turn Analyzer V3...") | ||
| from pipecat.audio.turn.smart_turn.local_smart_turn_v3 import LocalSmartTurnAnalyzerV3 | ||
|
|
||
| logger.info("✅ Local Smart Turn Analyzer V3 loaded") | ||
| logger.info("Loading Silero VAD model...") | ||
| from pipecat.audio.vad.silero import SileroVADAnalyzer | ||
|
|
||
| logger.info("✅ Silero VAD model loaded") | ||
|
|
||
| from pipecat.audio.vad.vad_analyzer import VADParams | ||
| from pipecat.frames.frames import LLMRunFrame | ||
|
|
||
| logger.info("Loading pipeline components...") | ||
| from pipecat.pipeline.pipeline import Pipeline | ||
| from pipecat.pipeline.runner import PipelineRunner | ||
| from pipecat.pipeline.task import PipelineParams, PipelineTask | ||
| from pipecat.processors.aggregators.llm_context import LLMContext | ||
| from pipecat.processors.aggregators.llm_response_universal import LLMContextAggregatorPair | ||
| from pipecat.processors.frameworks.rtvi import RTVIConfig, RTVIObserver, RTVIProcessor | ||
| from pipecat.runner.types import RunnerArguments | ||
| from pipecat.runner.utils import create_transport | ||
| from pipecat.services.cartesia.tts import CartesiaTTSService | ||
| from pipecat.services.deepgram.stt import DeepgramSTTService | ||
| from pipecat.services.openai.llm import OpenAILLMService | ||
| from pipecat.transports.base_transport import BaseTransport, TransportParams | ||
| from pipecat.transports.daily.transport import DailyParams | ||
|
|
||
|
|
||
|
|
||
|
|
||
| logger.info("✅ All components loaded successfully!") | ||
|
|
||
| load_dotenv(override=True) | ||
|
|
||
|
|
||
| async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): | ||
| logger.info(f"Starting bot") | ||
|
|
||
| stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) | ||
|
|
||
| tts = CartesiaTTSService( | ||
| api_key=os.getenv("CARTESIA_API_KEY"), | ||
| voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady | ||
| ) | ||
|
|
||
| llm = OpenAILLMService(api_key=os.getenv("OPENAI_API_KEY")) | ||
|
|
||
| messages = [ | ||
| { | ||
| "role": "system", | ||
| "content": "You are a friendly AI assistant. Respond naturally and keep your answers conversational.", | ||
| }, | ||
| ] | ||
|
|
||
| context = LLMContext(messages) | ||
| context_aggregator = LLMContextAggregatorPair(context) | ||
|
|
||
| rtvi = RTVIProcessor(config=RTVIConfig(config=[])) | ||
|
|
||
| pipeline = Pipeline( | ||
| [ | ||
| transport.input(), # Transport user input | ||
| rtvi, # RTVI processor | ||
| stt, | ||
| context_aggregator.user(), # User responses | ||
| llm, # LLM | ||
| tts, # TTS | ||
| transport.output(), # Transport bot output | ||
| context_aggregator.assistant(), # Assistant spoken responses | ||
| ] | ||
| ) | ||
|
|
||
| task = PipelineTask( | ||
| pipeline, | ||
| params=PipelineParams( | ||
| enable_metrics=True, | ||
| enable_usage_metrics=True, | ||
| ), | ||
| enable_tracing=True, # Enable tracing for this task | ||
| enable_turn_tracking=True, | ||
| observers=[RTVIObserver(rtvi)], | ||
| ) | ||
|
|
||
| @transport.event_handler("on_client_connected") | ||
| async def on_client_connected(transport, client): | ||
| logger.info(f"Client connected") | ||
| # Kick off the conversation. | ||
| messages.append({"role": "system", "content": "Say hello and briefly introduce yourself."}) | ||
| await task.queue_frames([LLMRunFrame()]) | ||
|
|
||
| @transport.event_handler("on_client_disconnected") | ||
| async def on_client_disconnected(transport, client): | ||
| logger.info(f"Client disconnected") | ||
| await task.cancel() | ||
|
|
||
| runner = PipelineRunner(handle_sigint=runner_args.handle_sigint) | ||
|
|
||
| await runner.run(task) | ||
|
|
||
|
|
||
| async def bot(runner_args: RunnerArguments): | ||
| """Main bot entry point for the bot starter.""" | ||
|
|
||
| transport_params = { | ||
| "daily": lambda: DailyParams( | ||
| audio_in_enabled=True, | ||
| audio_out_enabled=True, | ||
| vad_analyzer=SileroVADAnalyzer(params=VADParams(stop_secs=0.2)), | ||
| turn_analyzer=LocalSmartTurnAnalyzerV3(), | ||
| ), | ||
| "webrtc": lambda: TransportParams( | ||
| audio_in_enabled=True, | ||
| audio_out_enabled=True, | ||
| vad_analyzer=SileroVADAnalyzer(params=VADParams(stop_secs=0.2)), | ||
| turn_analyzer=LocalSmartTurnAnalyzerV3(), | ||
| ), | ||
| } | ||
|
|
||
| transport = await create_transport(runner_args, transport_params) | ||
|
|
||
| await run_bot(transport, runner_args) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| from pipecat.runner.run import main | ||
|
|
||
| main() | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| DEEPGRAM_API_KEY=your_deepgram_api_key | ||
| OPENAI_API_KEY=your_openai_api_key | ||
| CARTESIA_API_KEY=your_cartesia_api_key | ||
|
|
||
| # Optional: Connect via Daily WebRTC locally | ||
| DAILY_API_KEY=your_daily_api_key |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| agent_name = "quickstart" | ||
| image = "your_username/quickstart:0.1" | ||
| secret_set = "quickstart-secrets" | ||
| agent_profile = "agent-1x" | ||
|
|
||
| # RECOMMENDED: Set an image pull secret: | ||
| # https://docs.pipecat.ai/deployment/pipecat-cloud/fundamentals/secrets#image-pull-secrets | ||
| # image_credentials = "your_image_pull_secret" | ||
|
|
||
| [scaling] | ||
| min_agents = 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| [project] | ||
| name = "pipecat-quickstart" | ||
| version = "0.1.0" | ||
| description = "Quickstart example for building voice AI bots with Pipecat" | ||
| requires-python = ">=3.10" | ||
| dependencies = [ | ||
| "pipecat-ai[webrtc,daily,silero,deepgram,openai,cartesia,local-smart-turn-v3,runner]", | ||
| "pipecat-ai-cli" | ||
| ] | ||
|
|
||
| [dependency-groups] | ||
| dev = [ | ||
| "pyright>=1.1.404,<2", | ||
| "ruff>=0.12.11,<1", | ||
| ] | ||
|
|
||
| [tool.ruff] | ||
| line-length = 100 | ||
| [tool.ruff.lint] | ||
| select = ["I"] |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where do you set up your OTel exporter? Other examples use:
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The instructions posted are for OpenTelemetry's Python No-Code auto-instrumentation. Which allows for OpenTelemetry instrumentation, just based off env variables setup. This is why "setup_tracing" is not required as using opentelemetry-instrument when running the agent automatically sets up the tracer provider allowing for no-code setup(not having to manually set the tracer provider in code):
OTEL_RESOURCE_ATTRIBUTES="service.name=<service_name>" \ OTEL_EXPORTER_OTLP_ENDPOINT="https://ingest.<region>.signoz.cloud:443" \ OTEL_EXPORTER_OTLP_HEADERS="signoz-ingestion-key=<your_ingestion_key>" \ OTEL_EXPORTER_OTLP_PROTOCOL=grpc \ OTEL_TRACES_EXPORTER=otlp \ OTEL_METRICS_EXPORTER=otlp \ OTEL_LOGS_EXPORTER=otlp \ OTEL_PYTHON_LOG_CORRELATION=true \ OTEL_PYTHON_LOGGING_AUTO_INSTRUMENTATION_ENABLED=true \ uv run opentelemetry-instrument python bot.pythis will automatically setup any tracer providers so when pipecat exports traces you will automatically get them in the set OTEL backend like this:

This is shown in the README.
Thanks!