Skip to main content

OpenTelemetry openai instrumentation

Project description

opentelemetry-instrument-openai

It's OpenTelemetry instrumentation (python) for OpenAI's library.

Project site: https://github.com/cartermp/opentelemetry-instrument-openai-py

Supported APIs:

  • Chat
  • Embeddings
  • Moderation
  • Image (generation, edit, variation)
  • Audio (transcribe, translate)
  • Completion (GPT-3)
  • Edit (GPT-3)

How to use it

Simple! First, install this package.

Usage

With autoinstrumentation agent:

poetry add opentelemetry-instrument-openai
poetry run opentelemetry-bootstrap -a install
poetry run opentelemetry-instrument python your_app.py

If you prefer to do it in code, you can do that too:

import openai
from dotenv import load_dotenv
from opentelemetry.instrument.openai import OpenAIInstrumentor

OpenAIInstrumentor().instrument()

load_dotenv()
openai.api_key = os.getenv("OPENAI_API_KEY")

openai.ChatCompletion.create(
    model="gpt-3.5-turbo",
    messages=[{"role":"user", "content":"Tell me a joke about opentelemetry"}],
)

You can then run your app normally with your own opentelemetry initialization.

How to develop

Get poetry.

Now install and run tests:

poetry install
poetry run pytest

Now you can develop and run tests as you go!

How to run the example

Click the example folder and read the README.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Built Distribution

File details

Details for the file opentelemetry_instrument_openai-0.6.0.tar.gz.

File metadata

File hashes

Hashes for opentelemetry_instrument_openai-0.6.0.tar.gz
Algorithm Hash digest
SHA256 179d954b70506668250f443397ed4b41775a3046ba203a0c23a701c94931175c
MD5 4a1f59168f64cea360f22eeb9694d6d1
BLAKE2b-256 60f44d239d442cdf37d7adb66ede2e096bd19310654b8dab149e6d65d76dc963

See more details on using hashes here.

File details

Details for the file opentelemetry_instrument_openai-0.6.0-py3-none-any.whl.

File metadata

File hashes

Hashes for opentelemetry_instrument_openai-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9dc099dfcf706a04f3697c88bd4d8a5af2737b4d7aa617ecd991fdeea9652e3f
MD5 c396ef50d1a18e86369cffe5823485ae
BLAKE2b-256 ef9ddd3087f242ce1e2a6f33b03b4f5dbb5a2856dcf091566e72de6972c2192d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page