Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,25 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import os
from os import environ
from typing import Union

_CONTENT_RECORDING_ENV_VAR = (
"OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT"
from opentelemetry.instrumentation._semconv import _StabilityMode
from opentelemetry.util.genai.environment_variables import (
OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT,
)
from opentelemetry.util.genai.types import ContentCapturingMode
from opentelemetry.util.genai.utils import get_content_capturing_mode


def is_content_recording_enabled():
return os.getenv(_CONTENT_RECORDING_ENV_VAR, "false").lower() == "true"
def is_content_recording_enabled(
mode: _StabilityMode,
) -> Union[bool, ContentCapturingMode]:
if mode == _StabilityMode.DEFAULT:
capture_content = environ.get(
OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT, "false"
)
return capture_content.lower() == "true"
if mode == _StabilityMode.GEN_AI_LATEST_EXPERIMENTAL:
return get_content_capturing_mode()
raise RuntimeError(f"{mode} mode not supported")
Loading