Skip to content

Commit 553ecbf

Browse files
committed
Adding OTel support for Python sample
Signed-off-by: Harry Kimpel <harry@kimpel.com>
1 parent d0894fe commit 553ecbf

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

python/samples/chat.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,28 @@
11
import asyncio
2+
import os
23

3-
from copilot import CopilotClient
4+
from copilot import CopilotClient, SubprocessConfig
45
from copilot.generated.session_events import (
56
AssistantMessageData,
67
AssistantReasoningData,
78
ToolExecutionStartData,
89
)
910
from copilot.session import PermissionHandler
1011

12+
nr_license_key = os.environ["NEW_RELIC_LICENSE_KEY"]
13+
os.environ["OTEL_EXPORTER_OTLP_ENDPOINT"] = "https://otlp.nr-data.net:4318"
14+
os.environ["OTEL_EXPORTER_OTLP_HEADERS"] = f"api-key={nr_license_key}"
15+
os.environ["OTEL_EXPORTER_OTLP_PROTOCOL"] = "http/protobuf"
16+
os.environ["OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT"] = "true"
17+
1118
BLUE = "\033[34m"
1219
RESET = "\033[0m"
1320

1421

1522
async def main():
16-
client = CopilotClient()
23+
client = CopilotClient(SubprocessConfig(
24+
telemetry={"exporter_type": "otlp-http"},
25+
))
1726
await client.start()
1827
session = await client.create_session(on_permission_request=PermissionHandler.approve_all)
1928

0 commit comments

Comments
 (0)