Skip to content
Merged
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 @@ -493,7 +493,12 @@ class GuardrailMeters:

class PromptCaching:
# will be moved under the AI SemConv. Not namespaced since also OpenAI supports this.
LLM_BEDROCK_PROMPT_CACHING = "gen_ai.prompt.caching"
# FR: canonical name uses an underscore (`gen_ai.prompt_caching`) to match the
# FortifyRoot backend metric contract / catalog and the span attribute
# `CacheSpanAttrs.CACHED`. Prometheus normalizes both forms to
# `gen_ai_prompt_caching`, but the OTel/contract name must match exactly for
# registry, discovery, and SDK/backend round-trips.
LLM_BEDROCK_PROMPT_CACHING = "gen_ai.prompt_caching"


def _create_metrics(meter: Meter):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# NOTE:
# This file has been modified by FortifyRoot.
# Original source: https://github.com/traceloop/openllmetry

import json

import pytest
Expand All @@ -6,6 +10,18 @@
from opentelemetry.instrumentation.bedrock.prompt_caching import CacheSpanAttrs


def test_prompt_caching_metric_name_is_canonical():
# The Bedrock prompt-caching counter must be emitted with the canonical
# FortifyRoot/backend contract name `gen_ai.prompt_caching` (underscore),
# matching the span attribute `CacheSpanAttrs.CACHED` and the backend metric
# catalog. Prometheus collapses `gen_ai.prompt.caching` and
# `gen_ai.prompt_caching` to the same series, but the OTel/contract name must
# match exactly for registry/discovery and SDK/backend round-trips.
assert PromptCaching.LLM_BEDROCK_PROMPT_CACHING == "gen_ai.prompt_caching"
assert CacheSpanAttrs.CACHED == "gen_ai.prompt_caching"
assert PromptCaching.LLM_BEDROCK_PROMPT_CACHING == CacheSpanAttrs.CACHED


def call(brt):
body = {
"anthropic_version": "bedrock-2023-05-31",
Expand Down
Loading