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
- ``OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT=span_only`` configures OpenAI instrumentation to capture prompt and completion contents on *span* attributes.
- ``OTEL_INSTRUMENTATION_GENAI_COMPLETION_HOOK`` (commented out) - uncomment along with ``OTEL_INSTRUMENTATION_GENAI_UPLOAD_BASE_PATH`` to upload prompts and completions to an ``fsspec``-compatible destination instead of recording them inline. Also uncomment the ``opentelemetry-util-genai[upload]`` line in `requirements.txt <requirements.txt>`_ and reinstall.
16
17
17
18
Setup
18
19
-----
@@ -41,3 +42,18 @@ Run the example like this:
41
42
42
43
You should see a poem generated by OpenAI while traces and logs export to your
43
44
configured observability tool.
45
+
46
+
Custom completion hook
47
+
----------------------
48
+
49
+
`custom_hook.py <custom_hook.py>`_ is a variant of ``main.py`` that passes a
50
+
custom ``CompletionHook`` implementation programmatically via
51
+
``OpenAIInstrumentor().instrument(completion_hook=...)``. The example hook
52
+
prints prompts and completions to stdout; real hooks typically forward content
53
+
to external storage and record reference URIs on the span/log_record.
- ``OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT=span_only`` configures OpenAI instrumentation to capture prompt and completion contents on *span* attributes.
16
16
- ``OTEL_LOGS_EXPORTER=otlp`` to specify exporter type.
- ``OTEL_INSTRUMENTATION_GENAI_COMPLETION_HOOK`` (commented out) - uncomment along with ``OTEL_INSTRUMENTATION_GENAI_UPLOAD_BASE_PATH`` to upload prompts and completions to an ``fsspec``-compatible destination instead of recording them inline. Also uncomment the ``opentelemetry-util-genai[upload]`` line in `requirements.txt <requirements.txt>`_ and reinstall.
0 commit comments