Snowlgobe Telemetry Instrumentation for OpenInference
Instrument your Snowglobe connected app with OpenInference and start sending traces to popular OpenInference compatible sinks like Arize or Arize Phoenix.
Installation
pip install snowglobe-telemetry-openinference
If using uv, set the --prerelease=allow flag
uv pip install --prerelease=allow snowglobe-telemetry-openinference
Add the OpenInferenceInstrumentor to your agent file
Reminder: Each agent wrapper file resides in the root directory of your project, and is named after the agent (e.g. My Agent Name becomes my_agent_name.py).
from snowglobe.client import CompletionRequest, CompletionFunctionOutputs
from openai import OpenAI
import os
os.env["OTEL_PYTHON_TRACER_PROVIDER"] = "sdk_tracer_provider"
### Add these two lines to your agent file and watch context rich traces come in!
from snowglobe.telemetry.openinference import OpenInferenceInstrumentor
OpenInferenceInstrumentor().instrument()
client = OpenAI(api_key=os.getenv("SNOWGLOBE_API_KEY"))
def completion_fn(request: CompletionRequest) -> CompletionFunctionOutputs:
"""
Process a scenario request from Snowglobe.
This function is called by the Snowglobe client to process requests. It should return a
CompletionFunctionOutputs object with the response content.
Example CompletionRequest:
CompletionRequest(
messages=[
SnowglobeMessage(role="user", content="Hello, how are you?", snowglobe_data=None),
]
)
Example CompletionFunctionOutputs:
CompletionFunctionOutputs(response="This is a string response from your application")
Args:
request (CompletionRequest): The request object containing the messages.
Returns:
CompletionFunctionOutputs: The response object with the generated content.
"""
# Process the request using the messages. Example:
messages = request.to_openai_messages()
response = client.chat.completions.create(
model="gpt-4o-mini",
messages=messages
)
return CompletionFunctionOutputs(response=response.choices[0].message.content)
Enhancing Snowglobe Connect SDK's Traces with OpenInference Integrations
You can add more rich context to the traces the Snowglobe Connect SDK captures by installing additional OpenInference instrumentors and registering the appropriate tracer provider in your agent wrapper file.
The below examples shows how to add OpenAI instrumentation for either Arize or Arize Phoenix in addition to Snowglobe's OpenInference instrumentation:
Arize
Install the Arize OpenTelemetry pacakge and the OpenAI specific instrumentor.
pip install openinference-instrumentation-openai arize-otel
Then register the tracer provider and use the OpenAI instrumentator in your agent file:
import os
from openai import OpenAI
from snowglobe.client import CompletionRequest, CompletionFunctionOutputs
from arize.otel import register
# Setup OTel via our convenience function
tracer_provider = register(
space_id = "your-space-id", # in app space settings page
api_key = "your-api-key", # in app space settings page
project_name = "your-project-name", # name this to whatever you would like
)
# Import the OpenAI instrumentor from OpenInference
from openinference.instrumentation.openai import OpenAIInstrumentor
# Instrument OpenAI
OpenAIInstrumentor().instrument(tracer_provider=tracer_provider)
# Import the OpenInference instrumentor from Snowglobe
from snowglobe.telemetry.openinference import OpenInferenceInstrumentor
# Instrument the Snowglobe client
OpenInferenceInstrumentor().instrument(tracer_provider=tracer_provider)
def completion_fn(request: CompletionRequest) -> CompletionFunctionOutputs:
messages = request.to_openai_messages()
response = client.chat.completions.create(
model="gpt-4o-mini",
messages=messages
)
return CompletionFunctionOutputs(response=response.choices[0].message.content)
Arize Phoenix
Install the Arize Phoenix OpenTelemetry pacakge and the OpenAI specific instrumentor.
pip install openinference-instrumentation-openai arize-phoenix-otel
Then register the tracer provider and use the OpenAI instrumentator in your agent file:
import os
from openai import OpenAI
from snowglobe.client import CompletionRequest, CompletionFunctionOutputs
from phoenix.otel import register
os.environ["PHOENIX_COLLECTOR_ENDPOINT"] = "http://localhost:6006"
# configure the Phoenix tracer
tracer_provider = register(
project_name="my-llm-app", # Default is 'default'
)
# Import the OpenAI instrumentor from OpenInference
from openinference.instrumentation.openai import OpenAIInstrumentor
# Instrument OpenAI
OpenAIInstrumentor().instrument(tracer_provider=tracer_provider)
# Import the OpenInference instrumentor from Snowglobe
from snowglobe.telemetry.openinference import OpenInferenceInstrumentor
# Instrument the Snowglobe client
OpenInferenceInstrumentor().instrument(tracer_provider=tracer_provider)
def completion_fn(request: CompletionRequest) -> CompletionFunctionOutputs:
messages = request.to_openai_messages()
response = client.chat.completions.create(
model="gpt-4o-mini",
messages=messages
)
return CompletionFunctionOutputs(response=response.choices[0].message.content)
Metadata
Release files for snowglobe-telemetry-openinference 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| snowglobe_telemetry_openinference-0.0.1.tar.gz | 10.2 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| snowglobe_telemetry_openinference-0.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 18.5 kB
Release files / snowglobe_telemetry_openinference-0.0.1.tar.gz
| Download URL | snowglobe_telemetry_openinference-0.0.1.tar.gz |
|---|---|
| Size | 10.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
291246e9a488a7e6ede77b11db7438414f8201acd008ad9b1ad342f0e4b43a27
|
|
BLAKE2b-256 checksum How to use checksums |
1a6921c2886e81aa54a1a33e4fcf75a72324bfff184e526c939dc60b598f0df2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.13
|
Release files / snowglobe_telemetry_openinference-0.0.1-py3-none-any.whl
| Download URL | snowglobe_telemetry_openinference-0.0.1-py3-none-any.whl |
|---|---|
| Size | 8.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9b439de916542f53c3ce6fe5ac8a936daf372f0206bc58a149a1ab315729e914
|
|
BLAKE2b-256 checksum How to use checksums |
f589a558ff989d88ef380df6b61f878210b7a484dbeb58e94009943f85255505
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.13
|
Security for snowglobe-telemetry-openinference 0.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.