You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm writing an app with ruby-openai and it gives me a bit of a worry that I don't know how much I'm spending on OpenAI. I would like a pane on my Honeycomb.ai dashboard measuring how much data I'm sending and receiving. Adding alerting to my dashboard for unexpectedly high usage would give me peace of mind. And if latency of OpenAI's servers was also instrumented, so I could see that latency in traces, that would help me understand what performance I should expect as well.
OpenTelemetry seems like the natural way to instrument this. Here's a list of existing libraries. I'd love to add
c.use "OpenTelemetry::Instrumentation::Openai"
to my config/initializers/opentelemetry.rb and have my ruby-openai usage magically become available on my Honeycomb dashboard. Or of course it would work for whatever other provider people are using.
My suggested implementation would be to make the telemetry class a separate gem, and add a check whether the gem's class is defined in OpenAI::HTTP#json_post and related methods. If so, wrap the methods' functionality in a tracing block. But I'm open to alternatives. I haven't actually written a telemetry module before, so maybe thinking it's easy is hubris on my part.
Alternatively, I could add a similar wrapper in my own app and just use it for personal use. But this seems like something that would benefit the community and might as well be shared.
The text was updated successfully, but these errors were encountered:
I'm writing an app with
ruby-openai
and it gives me a bit of a worry that I don't know how much I'm spending on OpenAI. I would like a pane on my Honeycomb.ai dashboard measuring how much data I'm sending and receiving. Adding alerting to my dashboard for unexpectedly high usage would give me peace of mind. And if latency of OpenAI's servers was also instrumented, so I could see that latency in traces, that would help me understand what performance I should expect as well.OpenTelemetry seems like the natural way to instrument this. Here's a list of existing libraries. I'd love to add
to my
config/initializers/opentelemetry.rb
and have myruby-openai
usage magically become available on my Honeycomb dashboard. Or of course it would work for whatever other provider people are using.My suggested implementation would be to make the telemetry class a separate gem, and add a check whether the gem's class is defined in
OpenAI::HTTP#json_post
and related methods. If so, wrap the methods' functionality in a tracing block. But I'm open to alternatives. I haven't actually written a telemetry module before, so maybe thinking it's easy is hubris on my part.Alternatively, I could add a similar wrapper in my own app and just use it for personal use. But this seems like something that would benefit the community and might as well be shared.
The text was updated successfully, but these errors were encountered: