Skip to content

Commit e76d888

Browse files
argajaabmass
andcommitted
Update google genai instrumentation to latest semantic convention.
Co-authored-by: Aaron Abbott <[email protected]>
1 parent 4fb00c9 commit e76d888

File tree

6 files changed

+500
-103
lines changed

6 files changed

+500
-103
lines changed

instrumentation-genai/opentelemetry-instrumentation-google-genai/src/opentelemetry/instrumentation/google_genai/flags.py

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,25 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
import os
15+
from os import environ
16+
from typing import Union
1617

17-
_CONTENT_RECORDING_ENV_VAR = (
18-
"OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT"
18+
from opentelemetry.instrumentation._semconv import _StabilityMode
19+
from opentelemetry.util.genai.environment_variables import (
20+
OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT,
1921
)
22+
from opentelemetry.util.genai.types import ContentCapturingMode
23+
from opentelemetry.util.genai.utils import get_content_capturing_mode
2024

2125

22-
def is_content_recording_enabled():
23-
return os.getenv(_CONTENT_RECORDING_ENV_VAR, "false").lower() == "true"
26+
def is_content_recording_enabled(
27+
mode: _StabilityMode,
28+
) -> Union[bool, ContentCapturingMode]:
29+
if mode == _StabilityMode.DEFAULT:
30+
capture_content = environ.get(
31+
OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT, "false"
32+
)
33+
return capture_content.lower() == "true"
34+
if mode == _StabilityMode.GEN_AI_LATEST_EXPERIMENTAL:
35+
return get_content_capturing_mode()
36+
raise RuntimeError(f"{mode} mode not supported")

0 commit comments

Comments
 (0)