Skip to content

Same agent Smaller bill. The tools and infrastructure to get more work from your AI. Fewer tokens. Less compute. Lower cost.

[Fix]: Typo with semantic version class name (#686)

Fabio Zapata4fa48cd3c892
diff --git a/sdk/python/pyproject.toml b/sdk/python/pyproject.toml
index 7fd7ffcf..491a59a8 100644
--- a/sdk/python/pyproject.toml
+++ b/sdk/python/pyproject.toml
@@ -1,6 +1,6 @@
[tool.poetry]
name = "openlit"
-version = "1.33.19"
+version = "1.33.20"
description = "OpenTelemetry-native Auto instrumentation library for monitoring LLM Applications and GPUs, facilitating the integration of observability into your GenAI-driven projects"
authors = ["OpenLIT"]
license = "Apache-2.0"
diff --git a/sdk/python/src/openlit/__helpers.py b/sdk/python/src/openlit/__helpers.py
index 539aa1bd..b8851d60 100644
--- a/sdk/python/src/openlit/__helpers.py
+++ b/sdk/python/src/openlit/__helpers.py
@@ -12,7 +12,7 @@ import requests
from opentelemetry.sdk.resources import SERVICE_NAME, TELEMETRY_SDK_NAME, DEPLOYMENT_ENVIRONMENT
from opentelemetry.trace import Status, StatusCode
from opentelemetry._events import Event
-from openlit.semcov import SemanticConvetion
+from openlit.semcov import SemanticConvention
# Set up logging
logger = logging.getLogger(__name__)
@@ -176,12 +176,12 @@ def create_metrics_attributes(
TELEMETRY_SDK_NAME: 'openlit',
SERVICE_NAME: service_name,
DEPLOYMENT_ENVIRONMENT: deployment_environment,
- SemanticConvetion.GEN_AI_OPERATION: operation,
- SemanticConvetion.GEN_AI_SYSTEM: system,
- SemanticConvetion.GEN_AI_REQUEST_MODEL: request_model,
- SemanticConvetion.SERVER_ADDRESS: server_address,
- SemanticConvetion.SERVER_PORT: server_port,
- SemanticConvetion.GEN_AI_RESPONSE_MODEL: response_model
+ SemanticConvention.GEN_AI_OPERATION: operation,
+ SemanticConvention.GEN_AI_SYSTEM: system,
+ SemanticConvention.GEN_AI_REQUEST_MODEL: request_model,
+ SemanticConvention.SERVER_ADDRESS: server_address,
+ SemanticConvention.SERVER_PORT: server_port,
+ SemanticConvention.GEN_AI_RESPONSE_MODEL: response_model
}
def set_server_address_and_port(client_instance: Any,
diff --git a/sdk/python/src/openlit/__init__.py b/sdk/python/src/openlit/__init__.py
index 65cbdd67..3360516c 100644
--- a/sdk/python/src/openlit/__init__.py
+++ b/sdk/python/src/openlit/__init__.py
@@ -18,7 +18,7 @@ import requests
from opentelemetry import trace as t
from opentelemetry.trace import SpanKind, Status, StatusCode, Span
from opentelemetry.sdk.resources import SERVICE_NAME, DEPLOYMENT_ENVIRONMENT
-from openlit.semcov import SemanticConvetion
+from openlit.semcov import SemanticConvention
from openlit.otel.tracing import setup_tracing
from openlit.otel.metrics import setup_meter
from openlit.otel.events import setup_events
@@ -573,7 +573,7 @@ def trace(wrapped):
try:
response = wrapped(*args, **kwargs)
span.set_attribute(
- SemanticConvetion.GEN_AI_CONTENT_COMPLETION, response or ""
+ SemanticConvention.GEN_AI_CONTENT_COMPLETION, response or ""
)
span.set_status(Status(StatusCode.OK))
except Exception as e:
@@ -632,7 +632,7 @@ class TracedSpan:
result: The result to be set as an attribute on the span.
"""
- self._span.set_attribute(SemanticConvetion.GEN_AI_CONTENT_COMPLETION, result)
+ self._span.set_attribute(SemanticConvention.GEN_AI_CONTENT_COMPLETION, result)
def set_metadata(self, metadata: Dict):
"""
diff --git a/sdk/python/src/openlit/evals/utils.py b/sdk/python/src/openlit/evals/utils.py
index 3cbd6d51..d0895176 100644
--- a/sdk/python/src/openlit/evals/utils.py
+++ b/sdk/python/src/openlit/evals/utils.py
@@ -10,7 +10,7 @@ from opentelemetry.metrics import get_meter
from opentelemetry.sdk.resources import TELEMETRY_SDK_NAME
from anthropic import Anthropic
from openai import OpenAI
-from openlit.semcov import SemanticConvetion
+from openlit.semcov import SemanticConvention
# Initialize logger for logging potential issues and operations
logger = logging.getLogger(__name__)
@@ -238,7 +238,7 @@ def eval_metrics():
)
guard_requests = meter.create_counter(
- name=SemanticConvetion.EVAL_REQUESTS,
+ name=SemanticConvention.EVAL_REQUESTS,
description="Counter for evaluation requests",
unit="1"
)
@@ -262,14 +262,14 @@ def eval_metric_attributes(verdict, score, validator, classification, explanatio
return {
TELEMETRY_SDK_NAME:
"openlit",
- SemanticConvetion.EVAL_VERDICT:
+ SemanticConvention.EVAL_VERDICT:
verdict,
- SemanticConvetion.EVAL_SCORE:
+ SemanticConvention.EVAL_SCORE:
score,
- SemanticConvetion.EVAL_VALIDATOR:
+ SemanticConvention.EVAL_VALIDATOR:
validator,
- SemanticConvetion.EVAL_CLASSIFICATION:
+ SemanticConvention.EVAL_CLASSIFICATION:
classification,
- SemanticConvetion.EVAL_EXPLANATION:
+ SemanticConvention.EVAL_EXPLANATION:
explanation,
}
diff --git a/sdk/python/src/openlit/guard/utils.py b/sdk/python/src/openlit/guard/utils.py
index 0335099f..d8c1295f 100644
--- a/sdk/python/src/openlit/guard/utils.py
+++ b/sdk/python/src/openlit/guard/utils.py
@@ -11,7 +11,7 @@ from opentelemetry.metrics import get_meter
from opentelemetry.sdk.resources import TELEMETRY_SDK_NAME
from anthropic import Anthropic
from openai import OpenAI
-from openlit.semcov import SemanticConvetion
+from openlit.semcov import SemanticConvention
# Initialize logger for logging potential issues and operations
logger = logging.getLogger(__name__)
@@ -202,7 +202,7 @@ def guard_metrics():
)
guard_requests = meter.create_counter(
- name=SemanticConvetion.GUARD_REQUESTS,
+ name=SemanticConvention.GUARD_REQUESTS,
description="Counter for Guard requests",
unit="1"
)
@@ -224,9 +224,9 @@ def guard_metric_attributes(verdict, score, validator, classification, explanati
"""
return {
TELEMETRY_SDK_NAME: "openlit",
- SemanticConvetion.GUARD_VERDICT: verdict,
- SemanticConvetion.GUARD_SCORE: score,
- SemanticConvetion.GUARD_VALIDATOR: validator,
- SemanticConvetion.GUARD_CLASSIFICATION: classification,
- SemanticConvetion.GUARD_EXPLANATION: explanation,
+ SemanticConvention.GUARD_VERDICT: verdict,
+ SemanticConvention.GUARD_SCORE: score,
+ SemanticConvention.GUARD_VALIDATOR: validator,
+ SemanticConvention.GUARD_CLASSIFICATION: classification,
+ SemanticConvention.GUARD_EXPLANATION: explanation,
}
diff --git a/sdk/python/src/openlit/instrumentation/ag2/ag2.py b/sdk/python/src/openlit/instrumentation/ag2/ag2.py
index 1dd305a0..29dbff6c 100644
--- a/sdk/python/src/openlit/instrumentation/ag2/ag2.py
+++ b/sdk/python/src/openlit/instrumentation/ag2/ag2.py
@@ -11,7 +11,7 @@ from openlit.__helpers import (
get_chat_model_cost,
otel_event,
)
-from openlit.semcov import SemanticConvetion
+from openlit.semcov import SemanticConvention
# Initialize logger for logging potential issues and operations
logger = logging.getLogger(__name__)
@@ -29,17 +29,17 @@ def set_span_attributes(span, version, operation_name, environment,
# Set Span attributes (OTel Semconv)
span.set_attribute(TELEMETRY_SDK_NAME, 'openlit')
- span.set_attribute(SemanticConvetion.GEN_AI_OPERATION, operation_name)
- span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM, SemanticConvetion.GEN_AI_SYSTEM_AG2)
- span.set_attribute(SemanticConvetion.GEN_AI_AGENT_NAME, AGENT_NAME)
- span.set_attribute(SemanticConvetion.SERVER_ADDRESS, server_address)
- span.set_attribute(SemanticConvetion.SERVER_PORT, server_port)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL, request_model)
+ span.set_attribute(SemanticConvention.GEN_AI_OPERATION, operation_name)
+ span.set_attribute(SemanticConvention.GEN_AI_SYSTEM, SemanticConvention.GEN_AI_SYSTEM_AG2)
+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_NAME, AGENT_NAME)
+ span.set_attribute(SemanticConvention.SERVER_ADDRESS, server_address)
+ span.set_attribute(SemanticConvention.SERVER_PORT, server_port)
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL, request_model)
# Set Span attributes (Extras)
span.set_attribute(DEPLOYMENT_ENVIRONMENT, environment)
span.set_attribute(SERVICE_NAME, application_name)
- span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION, version)
+ span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION, version)
def calculate_tokens_and_cost(response, request_model, pricing_info):
"""
@@ -64,13 +64,13 @@ def emit_events(response, event_provider, capture_message_content):
"""
for chat in response.chat_history:
event_type = (
- SemanticConvetion.GEN_AI_CHOICE if chat['role'] == 'user'
- else SemanticConvetion.GEN_AI_USER_MESSAGE
+ SemanticConvention.GEN_AI_CHOICE if chat['role'] == 'user'
+ else SemanticConvention.GEN_AI_USER_MESSAGE
)
choice_event = otel_event(
name=event_type,
attributes={
- SemanticConvetion.GEN_AI_SYSTEM: SemanticConvetion.GEN_AI_SYSTEM_AG2
+ SemanticConvention.GEN_AI_SYSTEM: SemanticConvention.GEN_AI_SYSTEM_AG2
},
body={
'index': response.chat_history.index(chat),
@@ -97,7 +97,7 @@ def conversable_agent(version, environment, application_name,
SYSTEM_MESSAGE = kwargs.get('system_message', '')
MODEL_AND_NAME_SET = True
- span_name = f'{SemanticConvetion.GEN_AI_OPERATION_TYPE_CREATE_AGENT} {AGENT_NAME}'
+ span_name = f'{SemanticConvention.GEN_AI_OPERATION_TYPE_CREATE_AGENT} {AGENT_NAME}'
with tracer.start_as_current_span(span_name, kind=SpanKind.CLIENT) as span:
try:
@@ -105,11 +105,11 @@ def conversable_agent(version, environment, application_name,
response = wrapped(*args, **kwargs)
end_time = time.time()
- set_span_attributes(span, version, SemanticConvetion.GEN_AI_OPERATION_TYPE_CREATE_AGENT,
+ set_span_attributes(span, version, SemanticConvention.GEN_AI_OPERATION_TYPE_CREATE_AGENT,
environment, application_name, server_address, server_port, REQUEST_MODEL)
- span.set_attribute(SemanticConvetion.GEN_AI_AGENT_DESCRIPTION, SYSTEM_MESSAGE)
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_MODEL, REQUEST_MODEL)
- span.set_attribute(SemanticConvetion.GEN_AI_SERVER_TTFT, end_time - start_time)
+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_DESCRIPTION, SYSTEM_MESSAGE)
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL, REQUEST_MODEL)
+ span.set_attribute(SemanticConvention.GEN_AI_SERVER_TTFT, end_time - start_time)
span.set_status(Status(StatusCode.OK))
@@ -130,7 +130,7 @@ def agent_run(version, environment, application_name,
def wrapper(wrapped, instance, args, kwargs):
server_address, server_port = '127.0.0.1', 80
- span_name = f'{SemanticConvetion.GEN_AI_OPERATION_TYPE_EXECUTE_AGENT_TASK} {AGENT_NAME}'
+ span_name = f'{SemanticConvention.GEN_AI_OPERATION_TYPE_EXECUTE_AGENT_TASK} {AGENT_NAME}'
with tracer.start_as_current_span(span_name, kind=SpanKind.CLIENT) as span:
try:
@@ -141,14 +141,14 @@ def agent_run(version, environment, application_name,
input_tokens, output_tokens, cost = calculate_tokens_and_cost(response, REQUEST_MODEL, pricing_info)
response_model = list(response.cost.get('usage_including_cached_inference', {}).keys())[1]
- set_span_attributes(span, version, SemanticConvetion.GEN_AI_OPERATION_TYPE_EXECUTE_AGENT_TASK,
+ set_span_attributes(span, version, SemanticConvention.GEN_AI_OPERATION_TYPE_EXECUTE_AGENT_TASK,
environment, application_name, server_address, server_port, REQUEST_MODEL)
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_MODEL, response_model)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_INPUT_TOKENS, input_tokens)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_OUTPUT_TOKENS, output_tokens)
- span.set_attribute(SemanticConvetion.GEN_AI_CLIENT_TOKEN_USAGE, input_tokens + output_tokens)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST, cost)
- span.set_attribute(SemanticConvetion.GEN_AI_SERVER_TTFT, end_time - start_time)
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL, response_model)
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS, input_tokens)
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS, output_tokens)
+ span.set_attribute(SemanticConvention.GEN_AI_CLIENT_TOKEN_USAGE, input_tokens + output_tokens)
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST, cost)
+ span.set_attribute(SemanticConvention.GEN_AI_SERVER_TTFT, end_time - start_time)
emit_events(response, event_provider, capture_message_content)
span.set_status(Status(StatusCode.OK))
diff --git a/sdk/python/src/openlit/instrumentation/ai21/ai21.py b/sdk/python/src/openlit/instrumentation/ai21/ai21.py
index d6ecf756..5d8305b1 100644
--- a/sdk/python/src/openlit/instrumentation/ai21/ai21.py
+++ b/sdk/python/src/openlit/instrumentation/ai21/ai21.py
@@ -16,7 +16,7 @@ from openlit.instrumentation.ai21.utils import (
process_chat_rag_response
)
-from openlit.semcov import SemanticConvetion
+from openlit.semcov import SemanticConvention
# Initialize logger for logging potential issues and operations
logger = logging.getLogger(__name__)
@@ -113,7 +113,7 @@ def chat(version, environment, application_name,
server_address, server_port = set_server_address_and_port(instance, 'api.ai21.com', 443)
request_model = kwargs.get('model', 'jamba-1.5-mini')
- span_name = f'{SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT} {request_model}'
+ span_name = f'{SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT} {request_model}'
# pylint: disable=no-else-return
if streaming:
@@ -163,7 +163,7 @@ def chat_rag(version, environment, application_name,
server_address, server_port = set_server_address_and_port(instance, 'api.ai21.com', 443)
request_model = kwargs.get('model', 'jamba-1.5-mini')
- span_name = f'{SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT} {request_model}'
+ span_name = f'{SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT} {request_model}'
with tracer.start_as_current_span(span_name, kind= SpanKind.CLIENT) as span:
start_time = time.time()
diff --git a/sdk/python/src/openlit/instrumentation/ai21/async_ai21.py b/sdk/python/src/openlit/instrumentation/ai21/async_ai21.py
index b04b798a..3ecd94c1 100644
--- a/sdk/python/src/openlit/instrumentation/ai21/async_ai21.py
+++ b/sdk/python/src/openlit/instrumentation/ai21/async_ai21.py
@@ -16,7 +16,7 @@ from openlit.instrumentation.ai21.utils import (
process_chat_rag_response
)
-from openlit.semcov import SemanticConvetion
+from openlit.semcov import SemanticConvention
# Initialize logger for logging potential issues and operations
logger = logging.getLogger(__name__)
@@ -113,7 +113,7 @@ def async_chat(version, environment, application_name,
server_address, server_port = set_server_address_and_port(instance, 'api.ai21.com', 443)
request_model = kwargs.get('model', 'jamba-1.5-mini')
- span_name = f'{SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT} {request_model}'
+ span_name = f'{SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT} {request_model}'
# pylint: disable=no-else-return
if streaming:
@@ -163,7 +163,7 @@ def async_chat_rag(version, environment, application_name,
server_address, server_port = set_server_address_and_port(instance, 'api.ai21.com', 443)
request_model = kwargs.get('model', 'jamba-1.5-mini')
- span_name = f'{SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT} {request_model}'
+ span_name = f'{SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT} {request_model}'
with tracer.start_as_current_span(span_name, kind= SpanKind.CLIENT) as span:
start_time = time.time()
diff --git a/sdk/python/src/openlit/instrumentation/ai21/utils.py b/sdk/python/src/openlit/instrumentation/ai21/utils.py
index 04ed51d4..d72cfc0c 100644
--- a/sdk/python/src/openlit/instrumentation/ai21/utils.py
+++ b/sdk/python/src/openlit/instrumentation/ai21/utils.py
@@ -19,7 +19,7 @@ from openlit.__helpers import (
otel_event,
concatenate_all_contents
)
-from openlit.semcov import SemanticConvetion
+from openlit.semcov import SemanticConvention
def setup_common_span_attributes(span, request_model, kwargs, tokens,
server_port, server_address, environment,
@@ -30,32 +30,32 @@ def setup_common_span_attributes(span, request_model, kwargs, tokens,
# Base attributes from SDK and operation settings.
span.set_attribute(TELEMETRY_SDK_NAME, 'openlit')
- span.set_attribute(SemanticConvetion.GEN_AI_OPERATION, SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT)
- span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM, SemanticConvetion.GEN_AI_SYSTEM_AI21)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL, request_model)
- span.set_attribute(SemanticConvetion.SERVER_PORT, server_port)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_SEED, kwargs.get('seed', ''))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_FREQUENCY_PENALTY, kwargs.get('frequency_penalty', 0.0))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MAX_TOKENS, kwargs.get('max_tokens', -1))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_PRESENCE_PENALTY, kwargs.get('presence_penalty', 0.0))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_STOP_SEQUENCES, kwargs.get('stop', []))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TEMPERATURE, kwargs.get('temperature', 0.4))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TOP_P, kwargs.get('top_p', 1.0))
+ span.set_attribute(SemanticConvention.GEN_AI_OPERATION, SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT)
+ span.set_attribute(SemanticConvention.GEN_AI_SYSTEM, SemanticConvention.GEN_AI_SYSTEM_AI21)
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL, request_model)
+ span.set_attribute(SemanticConvention.SERVER_PORT, server_port)
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_SEED, kwargs.get('seed', ''))
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_FREQUENCY_PENALTY, kwargs.get('frequency_penalty', 0.0))
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS, kwargs.get('max_tokens', -1))
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_PRESENCE_PENALTY, kwargs.get('presence_penalty', 0.0))
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_STOP_SEQUENCES, kwargs.get('stop', []))
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TEMPERATURE, kwargs.get('temperature', 0.4))
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TOP_P, kwargs.get('top_p', 1.0))
# Add token-related attributes if available.
if 'finish_reason' in tokens:
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_FINISH_REASON, [tokens['finish_reason']])
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON, [tokens['finish_reason']])
if 'response_id' in tokens:
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_ID, tokens['response_id'])
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_ID, tokens['response_id'])
if 'input_tokens' in tokens:
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_INPUT_TOKENS, tokens['input_tokens'])
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS, tokens['input_tokens'])
if 'output_tokens' in tokens:
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_OUTPUT_TOKENS, tokens['output_tokens'])
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS, tokens['output_tokens'])
if 'total_tokens' in tokens:
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_TOTAL_TOKENS, tokens['total_tokens'])
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS, tokens['total_tokens'])
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_MODEL, request_model)
- span.set_attribute(SemanticConvetion.SERVER_ADDRESS, server_address)
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL, request_model)
+ span.set_attribute(SemanticConvention.SERVER_ADDRESS, server_address)
# Environment and service identifiers.
span.set_attribute(DEPLOYMENT_ENVIRONMENT, environment)
span.set_attribute(SERVICE_NAME, application_name)
@@ -73,8 +73,8 @@ def record_common_metrics(metrics, application_name, environment, request_model,
attributes = create_metrics_attributes(
service_name=application_name,
deployment_environment=environment,
- operation=SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT,
- system=SemanticConvetion.GEN_AI_SYSTEM_AI21,
+ operation=SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
+ system=SemanticConvention.GEN_AI_SYSTEM_AI21,
request_model=request_model,
server_address=server_address,
server_port=server_port,
@@ -121,15 +121,15 @@ def emit_common_events(event_provider, choices, finish_reason, llmresponse, form
}
})
event = otel_event(
- name=SemanticConvetion.GEN_AI_CHOICE,
- attributes={SemanticConvetion.GEN_AI_SYSTEM: SemanticConvetion.GEN_AI_SYSTEM_AI21},
+ name=SemanticConvention.GEN_AI_CHOICE,
+ attributes={SemanticConvention.GEN_AI_SYSTEM: SemanticConvention.GEN_AI_SYSTEM_AI21},
body=choice_event_body
)
event_provider.emit(event)
else:
event = otel_event(
- name=SemanticConvetion.GEN_AI_CHOICE,
- attributes={SemanticConvetion.GEN_AI_SYSTEM: SemanticConvetion.GEN_AI_SYSTEM_AI21},
+ name=SemanticConvention.GEN_AI_CHOICE,
+ attributes={SemanticConvention.GEN_AI_SYSTEM: SemanticConvention.GEN_AI_SYSTEM_AI21},
body=choice_event_body
)
event_provider.emit(event)
@@ -144,8 +144,8 @@ def emit_common_events(event_provider, choices, finish_reason, llmresponse, form
}
}
event = otel_event(
- name=SemanticConvetion.GEN_AI_CHOICE,
- attributes={SemanticConvetion.GEN_AI_SYSTEM: SemanticConvetion.GEN_AI_SYSTEM_AI21},
+ name=SemanticConvention.GEN_AI_CHOICE,
+ attributes={SemanticConvention.GEN_AI_SYSTEM: SemanticConvention.GEN_AI_SYSTEM_AI21},
body=choice_event_body
)
event_provider.emit(event)
@@ -175,8 +175,8 @@ def emit_common_events(event_provider, choices, finish_reason, llmresponse, form
if tool_calls:
event_body['id'] = tool_calls[0].get('id', '')
event = otel_event(
- name=getattr(SemanticConvetion, f'GEN_AI_{role.upper()}_MESSAGE'),
- attributes={SemanticConvetion.GEN_AI_SYSTEM: SemanticConvetion.GEN_AI_SYSTEM_AI21},
+ name=getattr(SemanticConvention, f'GEN_AI_{role.upper()}_MESSAGE'),
+ attributes={SemanticConvention.GEN_AI_SYSTEM: SemanticConvention.GEN_AI_SYSTEM_AI21},
body=event_body
)
event_provider.emit(event)
@@ -233,13 +233,13 @@ def common_chat_logic(scope, pricing_info, environment, application_name, metric
'total_tokens': scope._input_tokens + scope._output_tokens,
}
extra_attrs = {
- SemanticConvetion.GEN_AI_REQUEST_IS_STREAM: is_stream,
- SemanticConvetion.GEN_AI_CLIENT_TOKEN_USAGE: scope._input_tokens + scope._output_tokens,
- SemanticConvetion.GEN_AI_USAGE_COST: cost,
- SemanticConvetion.GEN_AI_SERVER_TBT: scope._tbt,
- SemanticConvetion.GEN_AI_SERVER_TTFT: scope._ttft,
- SemanticConvetion.GEN_AI_SDK_VERSION: version,
- SemanticConvetion.GEN_AI_OUTPUT_TYPE: 'text' if isinstance(scope._llmresponse, str) else 'json'
+ SemanticConvention.GEN_AI_REQUEST_IS_STREAM: is_stream,
+ SemanticConvention.GEN_AI_CLIENT_TOKEN_USAGE: scope._input_tokens + scope._output_tokens,
+ SemanticConvention.GEN_AI_USAGE_COST: cost,
+ SemanticConvention.GEN_AI_SERVER_TBT: scope._tbt,
+ SemanticConvention.GEN_AI_SERVER_TTFT: scope._ttft,
+ SemanticConvention.GEN_AI_SDK_VERSION: version,
+ SemanticConvention.GEN_AI_OUTPUT_TYPE: 'text' if isinstance(scope._llmresponse, str) else 'json'
}
# Set span attributes.
setup_common_span_attributes(scope._span, request_model, scope._kwargs, tokens,
@@ -249,12 +249,12 @@ def common_chat_logic(scope, pricing_info, environment, application_name, metric
# Optionally add events capturing the prompt and completion.
if capture_message_content:
scope._span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
- attributes={SemanticConvetion.GEN_AI_CONTENT_PROMPT: prompt},
+ name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
+ attributes={SemanticConvention.GEN_AI_CONTENT_PROMPT: prompt},
)
scope._span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_COMPLETION_EVENT,
- attributes={SemanticConvetion.GEN_AI_CONTENT_COMPLETION: scope._llmresponse},
+ name=SemanticConvention.GEN_AI_CONTENT_COMPLETION_EVENT,
+ attributes={SemanticConvention.GEN_AI_CONTENT_COMPLETION: scope._llmresponse},
)
# Emit events for each choice and message role.
@@ -336,15 +336,15 @@ def process_chat_rag_response(response, request_model, pricing_info, server_port
# Create tokens dict and RAG-specific extra attributes.
tokens = {'response_id': response_dict.get('id'), 'input_tokens': input_tokens}
extra_attrs = {
- SemanticConvetion.GEN_AI_REQUEST_IS_STREAM: False,
- SemanticConvetion.GEN_AI_SERVER_TTFT: end_time - start_time,
- SemanticConvetion.GEN_AI_SDK_VERSION: version,
- SemanticConvetion.GEN_AI_RAG_MAX_SEGMENTS: kwargs.get('max_segments', -1),
- SemanticConvetion.GEN_AI_RAG_STRATEGY: kwargs.get('retrieval_strategy', 'segments'),
- SemanticConvetion.GEN_AI_RAG_SIMILARITY_THRESHOLD: kwargs.get('retrieval_similarity_threshold', -1),
- SemanticConvetion.GEN_AI_RAG_MAX_NEIGHBORS: kwargs.get('max_neighbors', -1),
- SemanticConvetion.GEN_AI_RAG_FILE_IDS: str(kwargs.get('file_ids', '')),
- SemanticConvetion.GEN_AI_RAG_DOCUMENTS_PATH: kwargs.get('path', '')
+ SemanticConvention.GEN_AI_REQUEST_IS_STREAM: False,
+ SemanticConvention.GEN_AI_SERVER_TTFT: end_time - start_time,
+ SemanticConvention.GEN_AI_SDK_VERSION: version,
+ SemanticConvention.GEN_AI_RAG_MAX_SEGMENTS: kwargs.get('max_segments', -1),
+ SemanticConvention.GEN_AI_RAG_STRATEGY: kwargs.get('retrieval_strategy', 'segments'),
+ SemanticConvention.GEN_AI_RAG_SIMILARITY_THRESHOLD: kwargs.get('retrieval_similarity_threshold', -1),
+ SemanticConvention.GEN_AI_RAG_MAX_NEIGHBORS: kwargs.get('max_neighbors', -1),
+ SemanticConvention.GEN_AI_RAG_FILE_IDS: str(kwargs.get('file_ids', '')),
+ SemanticConvention.GEN_AI_RAG_DOCUMENTS_PATH: kwargs.get('path', '')
}
# Set common span attributes.
setup_common_span_attributes(span, request_model, kwargs, tokens,
@@ -354,8 +354,8 @@ def process_chat_rag_response(response, request_model, pricing_info, server_port
# Record the prompt event if requested.
if capture_message_content:
span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
- attributes={SemanticConvetion.GEN_AI_CONTENT_PROMPT: prompt},
+ name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
+ attributes={SemanticConvention.GEN_AI_CONTENT_PROMPT: prompt},
)
output_tokens = 0
@@ -368,13 +368,13 @@ def process_chat_rag_response(response, request_model, pricing_info, server_port
aggregated_completion.append(content)
output_tokens += general_tokens(content)
if kwargs.get('tools'):
- span.set_attribute(SemanticConvetion.GEN_AI_TOOL_CALLS,
+ span.set_attribute(SemanticConvention.GEN_AI_TOOL_CALLS,
str(choices[i].get('message', {}).get('tool_calls')))
# Set output type based on actual content type.
if isinstance(content, str):
- span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE, 'text')
+ span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE, 'text')
elif content is not None:
- span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE, 'json')
+ span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE, 'json')
# Concatenate completion responses.
llmresponse = ''.join(aggregated_completion)
@@ -382,16 +382,16 @@ def process_chat_rag_response(response, request_model, pricing_info, server_port
tokens['total_tokens'] = input_tokens + output_tokens
cost = get_chat_model_cost(request_model, pricing_info, input_tokens, output_tokens)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST, cost)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_OUTPUT_TOKENS, output_tokens)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_TOTAL_TOKENS, input_tokens + output_tokens)
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST, cost)
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS, output_tokens)
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS, input_tokens + output_tokens)
span.set_status(Status(StatusCode.OK))
# Emit a single aggregated completion event.
if capture_message_content:
span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_COMPLETION_EVENT,
- attributes={SemanticConvetion.GEN_AI_CONTENT_COMPLETION: llmresponse},
+ name=SemanticConvention.GEN_AI_CONTENT_COMPLETION_EVENT,
+ attributes={SemanticConvention.GEN_AI_CONTENT_COMPLETION: llmresponse},
)
# Emit the rest of the events (choice and role-based events) as before.
n = kwargs.get('n', 1)
diff --git a/sdk/python/src/openlit/instrumentation/anthropic/anthropic.py b/sdk/python/src/openlit/instrumentation/anthropic/anthropic.py
index 0d1eb91f..d3460f91 100644
--- a/sdk/python/src/openlit/instrumentation/anthropic/anthropic.py
+++ b/sdk/python/src/openlit/instrumentation/anthropic/anthropic.py
@@ -14,7 +14,7 @@ from openlit.instrumentation.anthropic.utils import (
process_chat_response,
process_streaming_chat_response,
)
-from openlit.semcov import SemanticConvetion
+from openlit.semcov import SemanticConvention
# Initialize logger for logging potential issues and operations
logger = logging.getLogger(__name__)
@@ -113,7 +113,7 @@ def messages(version, environment, application_name, tracer, event_provider,
server_address, server_port = set_server_address_and_port(instance, 'api.anthropic.com', 443)
request_model = kwargs.get('model', 'claude-3-5-sonnet-latest')
- span_name = f'{SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT} {request_model}'
+ span_name = f'{SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT} {request_model}'
# pylint: disable=no-else-return
if streaming:
diff --git a/sdk/python/src/openlit/instrumentation/anthropic/async_anthropic.py b/sdk/python/src/openlit/instrumentation/anthropic/async_anthropic.py
index 2dc074b5..5bbb6a5f 100644
--- a/sdk/python/src/openlit/instrumentation/anthropic/async_anthropic.py
+++ b/sdk/python/src/openlit/instrumentation/anthropic/async_anthropic.py
@@ -14,7 +14,7 @@ from openlit.instrumentation.anthropic.utils import (
process_chat_response,
process_streaming_chat_response,
)
-from openlit.semcov import SemanticConvetion
+from openlit.semcov import SemanticConvention
# Initialize logger for logging potential issues and operations
logger = logging.getLogger(__name__)
@@ -113,7 +113,7 @@ def async_messages(version, environment, application_name, tracer, event_provide
server_address, server_port = set_server_address_and_port(instance, 'api.anthropic.com', 443)
request_model = kwargs.get('model', 'claude-3-5-sonnet-latest')
- span_name = f'{SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT} {request_model}'
+ span_name = f'{SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT} {request_model}'
# pylint: disable=no-else-return
if streaming:
diff --git a/sdk/python/src/openlit/instrumentation/anthropic/utils.py b/sdk/python/src/openlit/instrumentation/anthropic/utils.py
index cfa11c3a..1c2b4e86 100644
--- a/sdk/python/src/openlit/instrumentation/anthropic/utils.py
+++ b/sdk/python/src/openlit/instrumentation/anthropic/utils.py
@@ -16,7 +16,7 @@ from openlit.__helpers import (
otel_event,
concatenate_all_contents
)
-from openlit.semcov import SemanticConvetion
+from openlit.semcov import SemanticConvention
def process_chunk(self, chunk):
"""
@@ -75,47 +75,47 @@ def common_chat_logic(scope, pricing_info, environment, application_name, metric
# Set Span attributes (OTel Semconv)
scope._span.set_attribute(TELEMETRY_SDK_NAME, 'openlit')
- scope._span.set_attribute(SemanticConvetion.GEN_AI_OPERATION, SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT)
- scope._span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM, SemanticConvetion.GEN_AI_SYSTEM_ANTHROPIC)
- scope._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL, request_model)
- scope._span.set_attribute(SemanticConvetion.SERVER_PORT, scope._server_port)
- scope._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MAX_TOKENS, scope._kwargs.get('max_tokens', -1))
- scope._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_STOP_SEQUENCES, scope._kwargs.get('stop_sequences', []))
- scope._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TEMPERATURE, scope._kwargs.get('temperature', 1.0))
- scope._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TOP_K, scope._kwargs.get('top_k', 1.0))
- scope._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TOP_P, scope._kwargs.get('top_p', 1.0))
- scope._span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_FINISH_REASON, [scope._finish_reason])
- scope._span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_ID, scope._response_id)
- scope._span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_MODEL, scope._response_model)
- scope._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_INPUT_TOKENS, scope._input_tokens)
- scope._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_OUTPUT_TOKENS, scope._output_tokens)
- scope._span.set_attribute(SemanticConvetion.SERVER_ADDRESS, scope._server_address)
-
- scope._span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
+ scope._span.set_attribute(SemanticConvention.GEN_AI_OPERATION, SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT)
+ scope._span.set_attribute(SemanticConvention.GEN_AI_SYSTEM, SemanticConvention.GEN_AI_SYSTEM_ANTHROPIC)
+ scope._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL, request_model)
+ scope._span.set_attribute(SemanticConvention.SERVER_PORT, scope._server_port)
+ scope._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS, scope._kwargs.get('max_tokens', -1))
+ scope._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_STOP_SEQUENCES, scope._kwargs.get('stop_sequences', []))
+ scope._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TEMPERATURE, scope._kwargs.get('temperature', 1.0))
+ scope._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TOP_K, scope._kwargs.get('top_k', 1.0))
+ scope._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TOP_P, scope._kwargs.get('top_p', 1.0))
+ scope._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON, [scope._finish_reason])
+ scope._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_ID, scope._response_id)
+ scope._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL, scope._response_model)
+ scope._span.set_attribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS, scope._input_tokens)
+ scope._span.set_attribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS, scope._output_tokens)
+ scope._span.set_attribute(SemanticConvention.SERVER_ADDRESS, scope._server_address)
+
+ scope._span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
'text' if isinstance(scope._llmresponse, str) else 'json')
scope._span.set_attribute(DEPLOYMENT_ENVIRONMENT, environment)
scope._span.set_attribute(SERVICE_NAME, application_name)
- scope._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IS_STREAM, is_stream)
- scope._span.set_attribute(SemanticConvetion.GEN_AI_CLIENT_TOKEN_USAGE, scope._input_tokens + scope._output_tokens)
- scope._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST, cost)
- scope._span.set_attribute(SemanticConvetion.GEN_AI_SERVER_TBT, scope._tbt)
- scope._span.set_attribute(SemanticConvetion.GEN_AI_SERVER_TTFT, scope._ttft)
- scope._span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION, version)
+ scope._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM, is_stream)
+ scope._span.set_attribute(SemanticConvention.GEN_AI_CLIENT_TOKEN_USAGE, scope._input_tokens + scope._output_tokens)
+ scope._span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST, cost)
+ scope._span.set_attribute(SemanticConvention.GEN_AI_SERVER_TBT, scope._tbt)
+ scope._span.set_attribute(SemanticConvention.GEN_AI_SERVER_TTFT, scope._ttft)
+ scope._span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION, version)
# To be removed one the change to log events (from span events) is complete
prompt = concatenate_all_contents(formatted_messages)
if capture_message_content:
scope._span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_PROMPT: prompt,
+ SemanticConvention.GEN_AI_CONTENT_PROMPT: prompt,
},
)
scope._span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_COMPLETION_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_COMPLETION_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_COMPLETION: scope._llmresponse,
+ SemanticConvention.GEN_AI_CONTENT_COMPLETION: scope._llmresponse,
},
)
@@ -144,9 +144,9 @@ def common_chat_logic(scope, pricing_info, environment, application_name, metric
for role in ['user', 'system', 'assistant', 'tool']:
if formatted_messages.get(role, {}).get('content', ''):
event = otel_event(
- name=getattr(SemanticConvetion, f'GEN_AI_{role.upper()}_MESSAGE'),
+ name=getattr(SemanticConvention, f'GEN_AI_{role.upper()}_MESSAGE'),
attributes={
- SemanticConvetion.GEN_AI_SYSTEM: SemanticConvetion.GEN_AI_SYSTEM_ANTHROPIC
+ SemanticConvention.GEN_AI_SYSTEM: SemanticConvention.GEN_AI_SYSTEM_ANTHROPIC
},
body = {
# pylint: disable=line-too-long
@@ -171,9 +171,9 @@ def common_chat_logic(scope, pricing_info, environment, application_name, metric
event_provider.emit(event)
choice_event = otel_event(
- name=SemanticConvetion.GEN_AI_CHOICE,
+ name=SemanticConvention.GEN_AI_CHOICE,
attributes={
- SemanticConvetion.GEN_AI_SYSTEM: SemanticConvetion.GEN_AI_SYSTEM_ANTHROPIC
+ SemanticConvention.GEN_AI_SYSTEM: SemanticConvention.GEN_AI_SYSTEM_ANTHROPIC
},
body=choice_event_body
)
@@ -185,8 +185,8 @@ def common_chat_logic(scope, pricing_info, environment, application_name, metric
metrics_attributes = create_metrics_attributes(
service_name=application_name,
deployment_environment=environment,
- operation=SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT,
- system=SemanticConvetion.GEN_AI_SYSTEM_ANTHROPIC,
+ operation=SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
+ system=SemanticConvention.GEN_AI_SYSTEM_ANTHROPIC,
request_model=request_model,
server_address=scope._server_address,
server_port=scope._server_port,
diff --git a/sdk/python/src/openlit/instrumentation/assemblyai/assemblyai.py b/sdk/python/src/openlit/instrumentation/assemblyai/assemblyai.py
index e3409f7a..5c3e6cbb 100644
--- a/sdk/python/src/openlit/instrumentation/assemblyai/assemblyai.py
+++ b/sdk/python/src/openlit/instrumentation/assemblyai/assemblyai.py
@@ -13,7 +13,7 @@ from openlit.__helpers import (
set_server_address_and_port,
otel_event
)
-from openlit.semcov import SemanticConvetion
+from openlit.semcov import SemanticConvention
# Initialize logger for logging potential issues and operations
logger = logging.getLogger(__name__)
@@ -33,7 +33,7 @@ def transcribe(version, environment, application_name,
server_address, server_port = set_server_address_and_port(instance, 'api.assemblyai.com', 443)
request_model = kwargs.get('speech_model', 'best')
- span_name = f'{SemanticConvetion.GEN_AI_OPERATION_TYPE_AUDIO} {request_model}'
+ span_name = f'{SemanticConvention.GEN_AI_OPERATION_TYPE_AUDIO} {request_model}'
with tracer.start_as_current_span(span_name, kind= SpanKind.CLIENT) as span:
start_time = time.time()
@@ -47,19 +47,19 @@ def transcribe(version, environment, application_name,
# Set Span attributes (OTel Semconv)
span.set_attribute(TELEMETRY_SDK_NAME, 'openlit')
- span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
- SemanticConvetion.GEN_AI_OPERATION_TYPE_AUDIO)
- span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
- SemanticConvetion.GEN_AI_SYSTEM_ASSEMBLYAI)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_AUDIO)
+ span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
+ SemanticConvention.GEN_AI_SYSTEM_ASSEMBLYAI)
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
request_model)
- span.set_attribute(SemanticConvetion.SERVER_ADDRESS,
+ span.set_attribute(SemanticConvention.SERVER_ADDRESS,
server_address)
- span.set_attribute(SemanticConvetion.SERVER_PORT,
+ span.set_attribute(SemanticConvention.SERVER_PORT,
server_port)
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL,
request_model)
- span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
+ span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
'text')
# Set Span attributes (Extras)
@@ -67,32 +67,32 @@ def transcribe(version, environment, application_name,
environment)
span.set_attribute(SERVICE_NAME,
application_name)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_AUDIO_DURATION,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_AUDIO_DURATION,
response.audio_duration)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST,
cost)
- span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
+ span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION,
version)
# To be removed one the change to log events (from span events) is complete
if capture_message_content:
span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_PROMPT: response.audio_url,
+ SemanticConvention.GEN_AI_CONTENT_PROMPT: response.audio_url,
},
)
span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_COMPLETION_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_COMPLETION_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_COMPLETION: response.text,
+ SemanticConvention.GEN_AI_CONTENT_COMPLETION: response.text,
},
)
input_event = otel_event(
- name=SemanticConvetion.GEN_AI_USER_MESSAGE,
+ name=SemanticConvention.GEN_AI_USER_MESSAGE,
attributes={
- SemanticConvetion.GEN_AI_SYSTEM: SemanticConvetion.GEN_AI_SYSTEM_ASSEMBLYAI
+ SemanticConvention.GEN_AI_SYSTEM: SemanticConvention.GEN_AI_SYSTEM_ASSEMBLYAI
},
body={
**({'content': response.audio_url} if capture_message_content else {}),
@@ -102,9 +102,9 @@ def transcribe(version, environment, application_name,
event_provider.emit(input_event)
output_event = otel_event(
- name=SemanticConvetion.GEN_AI_CHOICE,
+ name=SemanticConvention.GEN_AI_CHOICE,
attributes={
- SemanticConvetion.GEN_AI_SYSTEM: SemanticConvetion.GEN_AI_SYSTEM_ASSEMBLYAI
+ SemanticConvention.GEN_AI_SYSTEM: SemanticConvention.GEN_AI_SYSTEM_ASSEMBLYAI
},
body={
'finish_reason': 'stop',
@@ -123,8 +123,8 @@ def transcribe(version, environment, application_name,
attributes = create_metrics_attributes(
service_name=application_name,
deployment_environment=environment,
- operation=SemanticConvetion.GEN_AI_OPERATION_TYPE_AUDIO,
- system=SemanticConvetion.GEN_AI_SYSTEM_ASSEMBLYAI,
+ operation=SemanticConvention.GEN_AI_OPERATION_TYPE_AUDIO,
+ system=SemanticConvention.GEN_AI_SYSTEM_ASSEMBLYAI,
request_model=request_model,
server_address=server_address,
server_port=server_port,
diff --git a/sdk/python/src/openlit/instrumentation/astra/astra.py b/sdk/python/src/openlit/instrumentation/astra/astra.py
index 60036aca..5a0cbd74 100644
--- a/sdk/python/src/openlit/instrumentation/astra/astra.py
+++ b/sdk/python/src/openlit/instrumentation/astra/astra.py
@@ -8,7 +8,7 @@ from openlit.instrumentation.astra.utils import (
DB_OPERATION_MAP,
process_db_operations
)
-from openlit.semcov import SemanticConvetion
+from openlit.semcov import SemanticConvention
def general_wrap(gen_ai_endpoint, version, environment, application_name,
tracer, pricing_info, capture_message_content, metrics, disable_metrics):
@@ -22,8 +22,8 @@ def general_wrap(gen_ai_endpoint, version, environment, application_name,
"""
db_operation = DB_OPERATION_MAP.get(gen_ai_endpoint, "UNKNOWN")
- if db_operation == SemanticConvetion.DB_OPERATION_REPLACE and kwargs.get('upsert'):
- db_operation = SemanticConvetion.DB_OPERATION_UPSERT
+ if db_operation == SemanticConvention.DB_OPERATION_REPLACE and kwargs.get('upsert'):
+ db_operation = SemanticConvention.DB_OPERATION_UPSERT
span_name = f"{db_operation} {instance.name}"
diff --git a/sdk/python/src/openlit/instrumentation/astra/async_astra.py b/sdk/python/src/openlit/instrumentation/astra/async_astra.py
index 8e4fa366..019cb1bf 100644
--- a/sdk/python/src/openlit/instrumentation/astra/async_astra.py
+++ b/sdk/python/src/openlit/instrumentation/astra/async_astra.py
@@ -8,7 +8,7 @@ from openlit.instrumentation.astra.utils import (
DB_OPERATION_MAP,
process_db_operations
)
-from openlit.semcov import SemanticConvetion
+from openlit.semcov import SemanticConvention
def async_general_wrap(gen_ai_endpoint, version, environment, application_name,
tracer, pricing_info, capture_message_content, metrics, disable_metrics):
@@ -22,8 +22,8 @@ def async_general_wrap(gen_ai_endpoint, version, environment, application_name,
"""
db_operation = DB_OPERATION_MAP.get(gen_ai_endpoint, "UNKNOWN")
- if db_operation == SemanticConvetion.DB_OPERATION_REPLACE and kwargs.get('upsert'):
- db_operation = SemanticConvetion.DB_OPERATION_UPSERT
+ if db_operation == SemanticConvention.DB_OPERATION_REPLACE and kwargs.get('upsert'):
+ db_operation = SemanticConvention.DB_OPERATION_UPSERT
span_name = f"{db_operation} {instance.name}"
diff --git a/sdk/python/src/openlit/instrumentation/astra/utils.py b/sdk/python/src/openlit/instrumentation/astra/utils.py
index d76d4465..bd217cff 100644
--- a/sdk/python/src/openlit/instrumentation/astra/utils.py
+++ b/sdk/python/src/openlit/instrumentation/astra/utils.py
@@ -7,7 +7,7 @@ import logging
from opentelemetry.trace import Status, StatusCode
from opentelemetry.sdk.resources import SERVICE_NAME, TELEMETRY_SDK_NAME, DEPLOYMENT_ENVIRONMENT
from openlit.__helpers import handle_exception
-from openlit.semcov import SemanticConvetion
+from openlit.semcov import SemanticConvention
# Initialize logger for logging potential issues and operations
logger = logging.getLogger(__name__)
@@ -17,15 +17,15 @@ def object_count(obj):
return len(obj) if isinstance(obj, list) else 1
DB_OPERATION_MAP = {
- 'astra.create_collection': SemanticConvetion.DB_OPERATION_CREATE_COLLECTION,
- 'astra.drop_collection': SemanticConvetion.DB_OPERATION_DELETE_COLLECTION,
- 'astra.insert': SemanticConvetion.DB_OPERATION_INSERT,
- 'astra.update': SemanticConvetion.DB_OPERATION_UPDATE,
- 'astra.find': SemanticConvetion.DB_OPERATION_SELECT,
- 'astra.find_one_and_update': SemanticConvetion.DB_OPERATION_REPLACE,
- 'astra.replace_one': SemanticConvetion.DB_OPERATION_REPLACE,
- 'astra.delete': SemanticConvetion.DB_OPERATION_DELETE,
- 'astra.find_one_and_delete': SemanticConvetion.DB_OPERATION_FIND_AND_DELETE
+ 'astra.create_collection': SemanticConvention.DB_OPERATION_CREATE_COLLECTION,
+ 'astra.drop_collection': SemanticConvention.DB_OPERATION_DELETE_COLLECTION,
+ 'astra.insert': SemanticConvention.DB_OPERATION_INSERT,
+ 'astra.update': SemanticConvention.DB_OPERATION_UPDATE,
+ 'astra.find': SemanticConvention.DB_OPERATION_SELECT,
+ 'astra.find_one_and_update': SemanticConvention.DB_OPERATION_REPLACE,
+ 'astra.replace_one': SemanticConvention.DB_OPERATION_REPLACE,
+ 'astra.delete': SemanticConvention.DB_OPERATION_DELETE,
+ 'astra.find_one_and_delete': SemanticConvention.DB_OPERATION_FIND_AND_DELETE
}
def process_db_operations(response, span, start_time, gen_ai_endpoint,
@@ -40,41 +40,41 @@ def process_db_operations(response, span, start_time, gen_ai_endpoint,
try:
span.set_attribute(TELEMETRY_SDK_NAME, 'openlit')
- span.set_attribute(SemanticConvetion.GEN_AI_OPERATION, SemanticConvetion.GEN_AI_OPERATION_TYPE_VECTORDB)
- span.set_attribute(SemanticConvetion.DB_SYSTEM_NAME, SemanticConvetion.DB_SYSTEM_ASTRA)
- span.set_attribute(SemanticConvetion.DB_CLIENT_OPERATION_DURATION, end_time - start_time)
- span.set_attribute(SemanticConvetion.SERVER_ADDRESS, server_address)
- span.set_attribute(SemanticConvetion.SERVER_PORT, server_port)
+ span.set_attribute(SemanticConvention.GEN_AI_OPERATION, SemanticConvention.GEN_AI_OPERATION_TYPE_VECTORDB)
+ span.set_attribute(SemanticConvention.DB_SYSTEM_NAME, SemanticConvention.DB_SYSTEM_ASTRA)
+ span.set_attribute(SemanticConvention.DB_CLIENT_OPERATION_DURATION, end_time - start_time)
+ span.set_attribute(SemanticConvention.SERVER_ADDRESS, server_address)
+ span.set_attribute(SemanticConvention.SERVER_PORT, server_port)
span.set_attribute(DEPLOYMENT_ENVIRONMENT, environment)
span.set_attribute(SERVICE_NAME, application_name)
- span.set_attribute(SemanticConvetion.DB_OPERATION_NAME, db_operation)
- span.set_attribute(SemanticConvetion.DB_COLLECTION_NAME, collection_name)
- span.set_attribute(SemanticConvetion.DB_SDK_VERSION, version)
+ span.set_attribute(SemanticConvention.DB_OPERATION_NAME, db_operation)
+ span.set_attribute(SemanticConvention.DB_COLLECTION_NAME, collection_name)
+ span.set_attribute(SemanticConvention.DB_SDK_VERSION, version)
- if db_operation == SemanticConvetion.DB_OPERATION_CREATE_COLLECTION:
- span.set_attribute(SemanticConvetion.DB_NAMESPACE, response.keyspace)
- span.set_attribute(SemanticConvetion.DB_COLLECTION_NAME, response.name)
- span.set_attribute(SemanticConvetion.DB_INDEX_DIMENSION, kwargs.get('dimension', ''))
- span.set_attribute(SemanticConvetion.DB_INDEX_METRIC, str(kwargs.get('metric', '')))
+ if db_operation == SemanticConvention.DB_OPERATION_CREATE_COLLECTION:
+ span.set_attribute(SemanticConvention.DB_NAMESPACE, response.keyspace)
+ span.set_attribute(SemanticConvention.DB_COLLECTION_NAME, response.name)
+ span.set_attribute(SemanticConvention.DB_INDEX_DIMENSION, kwargs.get('dimension', ''))
+ span.set_attribute(SemanticConvention.DB_INDEX_METRIC, str(kwargs.get('metric', '')))
- if db_operation == SemanticConvetion.DB_OPERATION_INSERT:
- span.set_attribute(SemanticConvetion.DB_DOCUMENTS_COUNT, object_count(args[0]))
- span.set_attribute(SemanticConvetion.DB_QUERY_TEXT, str(args[0] or kwargs.get('documents', {})))
+ if db_operation == SemanticConvention.DB_OPERATION_INSERT:
+ span.set_attribute(SemanticConvention.DB_DOCUMENTS_COUNT, object_count(args[0]))
+ span.set_attribute(SemanticConvention.DB_QUERY_TEXT, str(args[0] or kwargs.get('documents', {})))
- elif db_operation == SemanticConvetion.DB_OPERATION_UPDATE:
- span.set_attribute(SemanticConvetion.DB_RESPONSE_RETURNED_ROWS, response.update_info.get('nModified', 0))
- span.set_attribute(SemanticConvetion.DB_QUERY_TEXT, str(args[1] or kwargs.get('update', {})))
+ elif db_operation == SemanticConvention.DB_OPERATION_UPDATE:
+ span.set_attribute(SemanticConvention.DB_RESPONSE_RETURNED_ROWS, response.update_info.get('nModified', 0))
+ span.set_attribute(SemanticConvention.DB_QUERY_TEXT, str(args[1] or kwargs.get('update', {})))
- elif db_operation == SemanticConvetion.DB_OPERATION_DELETE:
- span.set_attribute(SemanticConvetion.DB_RESPONSE_RETURNED_ROWS, response.deleted_count)
- span.set_attribute(SemanticConvetion.DB_QUERY_TEXT, str(args[0] or kwargs.get('filter', {})))
+ elif db_operation == SemanticConvention.DB_OPERATION_DELETE:
+ span.set_attribute(SemanticConvention.DB_RESPONSE_RETURNED_ROWS, response.deleted_count)
+ span.set_attribute(SemanticConvention.DB_QUERY_TEXT, str(args[0] or kwargs.get('filter', {})))
elif db_operation in [
- SemanticConvetion.DB_OPERATION_SELECT,
- SemanticConvetion.DB_OPERATION_FIND_AND_DELETE,
- SemanticConvetion.DB_OPERATION_REPLACE
+ SemanticConvention.DB_OPERATION_SELECT,
+ SemanticConvention.DB_OPERATION_FIND_AND_DELETE,
+ SemanticConvention.DB_OPERATION_REPLACE
]:
- span.set_attribute(SemanticConvetion.DB_QUERY_TEXT, str(args or kwargs.get('filter', {})))
+ span.set_attribute(SemanticConvention.DB_QUERY_TEXT, str(args or kwargs.get('filter', {})))
span.set_status(Status(StatusCode.OK))
@@ -82,10 +82,10 @@ def process_db_operations(response, span, start_time, gen_ai_endpoint,
attributes = {
TELEMETRY_SDK_NAME: 'openlit',
SERVICE_NAME: application_name,
- SemanticConvetion.DB_SYSTEM_NAME: SemanticConvetion.DB_SYSTEM_ASTRA,
+ SemanticConvention.DB_SYSTEM_NAME: SemanticConvention.DB_SYSTEM_ASTRA,
DEPLOYMENT_ENVIRONMENT: environment,
- SemanticConvetion.GEN_AI_OPERATION: SemanticConvetion.GEN_AI_OPERATION_TYPE_VECTORDB,
- SemanticConvetion.DB_OPERATION_NAME: db_operation
+ SemanticConvention.GEN_AI_OPERATION: SemanticConvention.GEN_AI_OPERATION_TYPE_VECTORDB,
+ SemanticConvention.DB_OPERATION_NAME: db_operation
}
metrics['db_requests'].add(1, attributes)
diff --git a/sdk/python/src/openlit/instrumentation/azure_ai_inference/async_azure_ai_inference.py b/sdk/python/src/openlit/instrumentation/azure_ai_inference/async_azure_ai_inference.py
index c72bd7e5..d860e522 100644
--- a/sdk/python/src/openlit/instrumentation/azure_ai_inference/async_azure_ai_inference.py
+++ b/sdk/python/src/openlit/instrumentation/azure_ai_inference/async_azure_ai_inference.py
@@ -14,7 +14,7 @@ from openlit.instrumentation.azure_ai_inference.utils import (
process_chat_response,
process_streaming_chat_response,
)
-from openlit.semcov import SemanticConvetion
+from openlit.semcov import SemanticConvention
# Initialize logger for logging potential issues and operations
logger = logging.getLogger(__name__)
@@ -108,7 +108,7 @@ def async_complete(version, environment, application_name,
server_address, server_port = set_server_address_and_port(instance, 'models.github.ai', 443)
request_model = kwargs.get('model', 'gpt-4o')
- span_name = f'{SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT} {request_model}'
+ span_name = f'{SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT} {request_model}'
# pylint: disable=no-else-return
if streaming:
diff --git a/sdk/python/src/openlit/instrumentation/azure_ai_inference/azure_ai_inference.py b/sdk/python/src/openlit/instrumentation/azure_ai_inference/azure_ai_inference.py
index f415af09..1e5cf519 100644
--- a/sdk/python/src/openlit/instrumentation/azure_ai_inference/azure_ai_inference.py
+++ b/sdk/python/src/openlit/instrumentation/azure_ai_inference/azure_ai_inference.py
@@ -14,7 +14,7 @@ from openlit.instrumentation.azure_ai_inference.utils import (
process_chat_response,
process_streaming_chat_response,
)
-from openlit.semcov import SemanticConvetion
+from openlit.semcov import SemanticConvention
# Initialize logger for logging potential issues and operations
logger = logging.getLogger(__name__)
@@ -108,7 +108,7 @@ def complete(version, environment, application_name,
server_address, server_port = set_server_address_and_port(instance, 'models.github.ai', 443)
request_model = kwargs.get('model', 'gpt-4o')
- span_name = f'{SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT} {request_model}'
+ span_name = f'{SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT} {request_model}'
# pylint: disable=no-else-return
if streaming:
diff --git a/sdk/python/src/openlit/instrumentation/azure_ai_inference/utils.py b/sdk/python/src/openlit/instrumentation/azure_ai_inference/utils.py
index 229768e9..f45fb62d 100644
--- a/sdk/python/src/openlit/instrumentation/azure_ai_inference/utils.py
+++ b/sdk/python/src/openlit/instrumentation/azure_ai_inference/utils.py
@@ -16,7 +16,7 @@ from openlit.__helpers import (
otel_event,
concatenate_all_contents
)
-from openlit.semcov import SemanticConvetion
+from openlit.semcov import SemanticConvention
def process_chunk(self, chunk):
"""
@@ -66,51 +66,51 @@ def common_chat_logic(scope, pricing_info, environment, application_name, metric
# Set Span attributes (OTel Semconv)
scope._span.set_attribute(TELEMETRY_SDK_NAME, 'openlit')
- scope._span.set_attribute(SemanticConvetion.GEN_AI_OPERATION, SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT)
- scope._span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM, SemanticConvetion.GEN_AI_SYSTEM_AZURE_AI_INFERENCE)
- scope._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL, request_model)
- scope._span.set_attribute(SemanticConvetion.SERVER_PORT, scope._server_port)
- scope._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MAX_TOKENS, scope._kwargs.get('max_tokens', -1))
- scope._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_STOP_SEQUENCES, scope._kwargs.get('stop', []))
- scope._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TEMPERATURE, scope._kwargs.get('temperature', 1.0))
- scope._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TOP_K, scope._kwargs.get('top_k', 1.0))
- scope._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TOP_P, scope._kwargs.get('top_p', 1.0))
- scope._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_FREQUENCY_PENALTY,
+ scope._span.set_attribute(SemanticConvention.GEN_AI_OPERATION, SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT)
+ scope._span.set_attribute(SemanticConvention.GEN_AI_SYSTEM, SemanticConvention.GEN_AI_SYSTEM_AZURE_AI_INFERENCE)
+ scope._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL, request_model)
+ scope._span.set_attribute(SemanticConvention.SERVER_PORT, scope._server_port)
+ scope._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS, scope._kwargs.get('max_tokens', -1))
+ scope._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_STOP_SEQUENCES, scope._kwargs.get('stop', []))
+ scope._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TEMPERATURE, scope._kwargs.get('temperature', 1.0))
+ scope._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TOP_K, scope._kwargs.get('top_k', 1.0))
+ scope._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TOP_P, scope._kwargs.get('top_p', 1.0))
+ scope._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_FREQUENCY_PENALTY,
scope._kwargs.get('frequency_penalty', 0.0))
- scope._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_PRESENCE_PENALTY,
+ scope._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_PRESENCE_PENALTY,
scope._kwargs.get('presence_penalty', 0.0))
- scope._span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_FINISH_REASON, [scope._finish_reason])
- scope._span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_ID, scope._response_id)
- scope._span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_MODEL, scope._response_model)
- scope._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_INPUT_TOKENS, scope._input_tokens)
- scope._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_OUTPUT_TOKENS, scope._output_tokens)
- scope._span.set_attribute(SemanticConvetion.SERVER_ADDRESS, scope._server_address)
-
- scope._span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
+ scope._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON, [scope._finish_reason])
+ scope._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_ID, scope._response_id)
+ scope._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL, scope._response_model)
+ scope._span.set_attribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS, scope._input_tokens)
+ scope._span.set_attribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS, scope._output_tokens)
+ scope._span.set_attribute(SemanticConvention.SERVER_ADDRESS, scope._server_address)
+
+ scope._span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
'text' if isinstance(scope._llmresponse, str) else 'json')
scope._span.set_attribute(DEPLOYMENT_ENVIRONMENT, environment)
scope._span.set_attribute(SERVICE_NAME, application_name)
- scope._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IS_STREAM, is_stream)
- scope._span.set_attribute(SemanticConvetion.GEN_AI_CLIENT_TOKEN_USAGE, scope._input_tokens + scope._output_tokens)
- scope._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST, cost)
- scope._span.set_attribute(SemanticConvetion.GEN_AI_SERVER_TBT, scope._tbt)
- scope._span.set_attribute(SemanticConvetion.GEN_AI_SERVER_TTFT, scope._ttft)
- scope._span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION, version)
+ scope._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM, is_stream)
+ scope._span.set_attribute(SemanticConvention.GEN_AI_CLIENT_TOKEN_USAGE, scope._input_tokens + scope._output_tokens)
+ scope._span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST, cost)
+ scope._span.set_attribute(SemanticConvention.GEN_AI_SERVER_TBT, scope._tbt)
+ scope._span.set_attribute(SemanticConvention.GEN_AI_SERVER_TTFT, scope._ttft)
+ scope._span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION, version)
# To be removed one the change to log events (from span events) is complete
prompt = concatenate_all_contents(formatted_messages)
if capture_message_content:
scope._span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_PROMPT: prompt,
+ SemanticConvention.GEN_AI_CONTENT_PROMPT: prompt,
},
)
scope._span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_COMPLETION_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_COMPLETION_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_COMPLETION: scope._llmresponse,
+ SemanticConvention.GEN_AI_CONTENT_COMPLETION: scope._llmresponse,
},
)
@@ -127,9 +127,9 @@ def common_chat_logic(scope, pricing_info, environment, application_name, metric
for role in ['user', 'system', 'assistant', 'tool']:
if formatted_messages.get(role, {}).get('content', ''):
event = otel_event(
- name=getattr(SemanticConvetion, f'GEN_AI_{role.upper()}_MESSAGE'),
+ name=getattr(SemanticConvention, f'GEN_AI_{role.upper()}_MESSAGE'),
attributes={
- SemanticConvetion.GEN_AI_SYSTEM: SemanticConvetion.GEN_AI_SYSTEM_AZURE_AI_INFERENCE
+ SemanticConvention.GEN_AI_SYSTEM: SemanticConvention.GEN_AI_SYSTEM_AZURE_AI_INFERENCE
},
body = {
# pylint: disable=line-too-long
@@ -154,9 +154,9 @@ def common_chat_logic(scope, pricing_info, environment, application_name, metric
event_provider.emit(event)
choice_event = otel_event(
- name=SemanticConvetion.GEN_AI_CHOICE,
+ name=SemanticConvention.GEN_AI_CHOICE,
attributes={
- SemanticConvetion.GEN_AI_SYSTEM: SemanticConvetion.GEN_AI_SYSTEM_AZURE_AI_INFERENCE
+ SemanticConvention.GEN_AI_SYSTEM: SemanticConvention.GEN_AI_SYSTEM_AZURE_AI_INFERENCE
},
body=choice_event_body
)
@@ -168,8 +168,8 @@ def common_chat_logic(scope, pricing_info, environment, application_name, metric
metrics_attributes = create_metrics_attributes(
service_name=application_name,
deployment_environment=environment,
- operation=SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT,
- system=SemanticConvetion.GEN_AI_SYSTEM_AZURE_AI_INFERENCE,
+ operation=SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
+ system=SemanticConvention.GEN_AI_SYSTEM_AZURE_AI_INFERENCE,
request_model=request_model,
server_address=scope._server_address,
server_port=scope._server_port,
diff --git a/sdk/python/src/openlit/instrumentation/bedrock/bedrock.py b/sdk/python/src/openlit/instrumentation/bedrock/bedrock.py
index 1c7ebed2..d1804cf9 100644
--- a/sdk/python/src/openlit/instrumentation/bedrock/bedrock.py
+++ b/sdk/python/src/openlit/instrumentation/bedrock/bedrock.py
@@ -11,7 +11,7 @@ from openlit.__helpers import (
from openlit.instrumentation.bedrock.utils import (
process_chat_response,
)
-from openlit.semcov import SemanticConvetion
+from openlit.semcov import SemanticConvention
# Initialize logger for logging potential issues and operations
logger = logging.getLogger(__name__)
@@ -36,7 +36,7 @@ def converse(version, environment, application_name, tracer, event_provider,
server_address, server_port = set_server_address_and_port(instance, 'aws.amazon.com', 443)
request_model = method_kwargs.get('modelId', 'amazon.titan-text-express-v1')
- span_name = f'{SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT} {request_model}'
+ span_name = f'{SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT} {request_model}'
with tracer.start_as_current_span(span_name, kind=SpanKind.CLIENT) as span:
start_time = time.time()
diff --git a/sdk/python/src/openlit/instrumentation/bedrock/utils.py b/sdk/python/src/openlit/instrumentation/bedrock/utils.py
index ef655448..949fa7bc 100644
--- a/sdk/python/src/openlit/instrumentation/bedrock/utils.py
+++ b/sdk/python/src/openlit/instrumentation/bedrock/utils.py
@@ -16,7 +16,7 @@ from openlit.__helpers import (
otel_event,
concatenate_all_contents
)
-from openlit.semcov import SemanticConvetion
+from openlit.semcov import SemanticConvention
def process_chunk(self, chunk):
"""
@@ -76,20 +76,20 @@ def common_chat_logic(scope, pricing_info, environment, application_name, metric
# Set Span attributes (OTel Semconv)
scope._span.set_attribute(TELEMETRY_SDK_NAME, 'openlit')
- scope._span.set_attribute(SemanticConvetion.GEN_AI_OPERATION, SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT)
- scope._span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM, SemanticConvetion.GEN_AI_SYSTEM_AWS_BEDROCK)
- scope._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL, request_model)
- scope._span.set_attribute(SemanticConvetion.SERVER_PORT, scope._server_port)
+ scope._span.set_attribute(SemanticConvention.GEN_AI_OPERATION, SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT)
+ scope._span.set_attribute(SemanticConvention.GEN_AI_SYSTEM, SemanticConvention.GEN_AI_SYSTEM_AWS_BEDROCK)
+ scope._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL, request_model)
+ scope._span.set_attribute(SemanticConvention.SERVER_PORT, scope._server_port)
# List of attributes and their config keys
attributes = [
- (SemanticConvetion.GEN_AI_REQUEST_FREQUENCY_PENALTY, 'frequencyPenalty'),
- (SemanticConvetion.GEN_AI_REQUEST_MAX_TOKENS, 'maxTokens'),
- (SemanticConvetion.GEN_AI_REQUEST_PRESENCE_PENALTY, 'presencePenalty'),
- (SemanticConvetion.GEN_AI_REQUEST_STOP_SEQUENCES, 'stopSequences'),
- (SemanticConvetion.GEN_AI_REQUEST_TEMPERATURE, 'temperature'),
- (SemanticConvetion.GEN_AI_REQUEST_TOP_P, 'topP'),
- (SemanticConvetion.GEN_AI_REQUEST_TOP_K, 'topK'),
+ (SemanticConvention.GEN_AI_REQUEST_FREQUENCY_PENALTY, 'frequencyPenalty'),
+ (SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS, 'maxTokens'),
+ (SemanticConvention.GEN_AI_REQUEST_PRESENCE_PENALTY, 'presencePenalty'),
+ (SemanticConvention.GEN_AI_REQUEST_STOP_SEQUENCES, 'stopSequences'),
+ (SemanticConvention.GEN_AI_REQUEST_TEMPERATURE, 'temperature'),
+ (SemanticConvention.GEN_AI_REQUEST_TOP_P, 'topP'),
+ (SemanticConvention.GEN_AI_REQUEST_TOP_K, 'topK'),
]
# Set each attribute if the corresponding value exists and is not None
@@ -98,38 +98,38 @@ def common_chat_logic(scope, pricing_info, environment, application_name, metric
if value is not None:
scope._span.set_attribute(attribute, value)
- scope._span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_FINISH_REASON, [scope._finish_reason])
- scope._span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_ID, scope._response_id)
- scope._span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_MODEL, scope._response_model)
- scope._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_INPUT_TOKENS, scope._input_tokens)
- scope._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_OUTPUT_TOKENS, scope._output_tokens)
- scope._span.set_attribute(SemanticConvetion.SERVER_ADDRESS, scope._server_address)
+ scope._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON, [scope._finish_reason])
+ scope._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_ID, scope._response_id)
+ scope._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL, scope._response_model)
+ scope._span.set_attribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS, scope._input_tokens)
+ scope._span.set_attribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS, scope._output_tokens)
+ scope._span.set_attribute(SemanticConvention.SERVER_ADDRESS, scope._server_address)
- scope._span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
+ scope._span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
'text' if isinstance(scope._llmresponse, str) else 'json')
scope._span.set_attribute(DEPLOYMENT_ENVIRONMENT, environment)
scope._span.set_attribute(SERVICE_NAME, application_name)
- scope._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IS_STREAM, is_stream)
- scope._span.set_attribute(SemanticConvetion.GEN_AI_CLIENT_TOKEN_USAGE, scope._input_tokens + scope._output_tokens)
- scope._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST, cost)
- scope._span.set_attribute(SemanticConvetion.GEN_AI_SERVER_TBT, scope._tbt)
- scope._span.set_attribute(SemanticConvetion.GEN_AI_SERVER_TTFT, scope._ttft)
- scope._span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION, version)
+ scope._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM, is_stream)
+ scope._span.set_attribute(SemanticConvention.GEN_AI_CLIENT_TOKEN_USAGE, scope._input_tokens + scope._output_tokens)
+ scope._span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST, cost)
+ scope._span.set_attribute(SemanticConvention.GEN_AI_SERVER_TBT, scope._tbt)
+ scope._span.set_attribute(SemanticConvention.GEN_AI_SERVER_TTFT, scope._ttft)
+ scope._span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION, version)
# To be removed one the change to log events (from span events) is complete
prompt = concatenate_all_contents(formatted_messages)
if capture_message_content:
scope._span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_PROMPT: prompt,
+ SemanticConvention.GEN_AI_CONTENT_PROMPT: prompt,
},
)
scope._span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_COMPLETION_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_COMPLETION_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_COMPLETION: scope._llmresponse,
+ SemanticConvention.GEN_AI_CONTENT_COMPLETION: scope._llmresponse,
},
)
@@ -146,9 +146,9 @@ def common_chat_logic(scope, pricing_info, environment, application_name, metric
for role in ['user', 'system', 'assistant', 'tool']:
if formatted_messages.get(role, {}).get('content', ''):
event = otel_event(
- name=getattr(SemanticConvetion, f'GEN_AI_{role.upper()}_MESSAGE'),
+ name=getattr(SemanticConvention, f'GEN_AI_{role.upper()}_MESSAGE'),
attributes={
- SemanticConvetion.GEN_AI_SYSTEM: SemanticConvetion.GEN_AI_SYSTEM_AWS_BEDROCK
+ SemanticConvention.GEN_AI_SYSTEM: SemanticConvention.GEN_AI_SYSTEM_AWS_BEDROCK
},
body = {
# pylint: disable=line-too-long
@@ -173,9 +173,9 @@ def common_chat_logic(scope, pricing_info, environment, application_name, metric
event_provider.emit(event)
choice_event = otel_event(
- name=SemanticConvetion.GEN_AI_CHOICE,
+ name=SemanticConvention.GEN_AI_CHOICE,
attributes={
- SemanticConvetion.GEN_AI_SYSTEM: SemanticConvetion.GEN_AI_SYSTEM_AWS_BEDROCK
+ SemanticConvention.GEN_AI_SYSTEM: SemanticConvention.GEN_AI_SYSTEM_AWS_BEDROCK
},
body=choice_event_body
)
@@ -187,8 +187,8 @@ def common_chat_logic(scope, pricing_info, environment, application_name, metric
metrics_attributes = create_metrics_attributes(
service_name=application_name,
deployment_environment=environment,
- operation=SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT,
- system=SemanticConvetion.GEN_AI_SYSTEM_AWS_BEDROCK,
+ operation=SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
+ system=SemanticConvention.GEN_AI_SYSTEM_AWS_BEDROCK,
request_model=request_model,
server_address=scope._server_address,
server_port=scope._server_port,
diff --git a/sdk/python/src/openlit/instrumentation/chroma/chroma.py b/sdk/python/src/openlit/instrumentation/chroma/chroma.py
index dc55431c..7472d924 100644
--- a/sdk/python/src/openlit/instrumentation/chroma/chroma.py
+++ b/sdk/python/src/openlit/instrumentation/chroma/chroma.py
@@ -7,7 +7,7 @@ import logging
from opentelemetry.trace import SpanKind, Status, StatusCode
from opentelemetry.sdk.resources import SERVICE_NAME, TELEMETRY_SDK_NAME, DEPLOYMENT_ENVIRONMENT
from openlit.__helpers import handle_exception
-from openlit.semcov import SemanticConvetion
+from openlit.semcov import SemanticConvention
# Initialize logger for logging potential issues and operations
logger = logging.getLogger(__name__)
@@ -71,101 +71,101 @@ def general_wrap(gen_ai_endpoint, version, environment, application_name,
try:
span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
- span.set_attribute(SemanticConvetion.GEN_AI_ENDPOINT,
+ span.set_attribute(SemanticConvention.GEN_AI_ENDPOINT,
gen_ai_endpoint)
span.set_attribute(DEPLOYMENT_ENVIRONMENT,
environment)
span.set_attribute(SERVICE_NAME,
application_name)
- span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
- SemanticConvetion.GEN_AI_OPERATION_TYPE_VECTORDB)
- span.set_attribute(SemanticConvetion.DB_SYSTEM_NAME,
- SemanticConvetion.DB_SYSTEM_CHROMA)
- span.set_attribute(SemanticConvetion.DB_COLLECTION_NAME,
+ span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_VECTORDB)
+ span.set_attribute(SemanticConvention.DB_SYSTEM_NAME,
+ SemanticConvention.DB_SYSTEM_CHROMA)
+ span.set_attribute(SemanticConvention.DB_COLLECTION_NAME,
instance.name)
if gen_ai_endpoint == "chroma.add":
- db_operation = SemanticConvetion.DB_OPERATION_ADD
- span.set_attribute(SemanticConvetion.DB_OPERATION_NAME,
- SemanticConvetion.DB_OPERATION_ADD)
- span.set_attribute(SemanticConvetion.DB_ID_COUNT,
+ db_operation = SemanticConvention.DB_OPERATION_ADD
+ span.set_attribute(SemanticConvention.DB_OPERATION_NAME,
+ SemanticConvention.DB_OPERATION_ADD)
+ span.set_attribute(SemanticConvention.DB_ID_COUNT,
object_count(kwargs.get("ids", [])))
- span.set_attribute(SemanticConvetion.DB_VECTOR_COUNT,
+ span.set_attribute(SemanticConvention.DB_VECTOR_COUNT,
object_count(kwargs.get("embeddings", [])))
- span.set_attribute(SemanticConvetion.DB_VECTOR_COUNT,
+ span.set_attribute(SemanticConvention.DB_VECTOR_COUNT,
object_count(kwargs.get("metadatas", [])))
- span.set_attribute(SemanticConvetion.DB_DOCUMENTS_COUNT,
+ span.set_attribute(SemanticConvention.DB_DOCUMENTS_COUNT,
object_count(kwargs.get("documents", [])))
elif gen_ai_endpoint == "chroma.get":
- db_operation = SemanticConvetion.DB_OPERATION_GET
- span.set_attribute(SemanticConvetion.DB_OPERATION_NAME,
- SemanticConvetion.DB_OPERATION_GET)
- span.set_attribute(SemanticConvetion.DB_ID_COUNT,
+ db_operation = SemanticConvention.DB_OPERATION_GET
+ span.set_attribute(SemanticConvention.DB_OPERATION_NAME,
+ SemanticConvention.DB_OPERATION_GET)
+ span.set_attribute(SemanticConvention.DB_ID_COUNT,
object_count(kwargs.get("ids", [])))
- span.set_attribute(SemanticConvetion.DB_QUERY_LIMIT,
+ span.set_attribute(SemanticConvention.DB_QUERY_LIMIT,
kwargs.get("limit", ""))
- span.set_attribute(SemanticConvetion.DB_OFFSET,
+ span.set_attribute(SemanticConvention.DB_OFFSET,
kwargs.get("offset", ""))
- span.set_attribute(SemanticConvetion.DB_WHERE_DOCUMENT,
+ span.set_attribute(SemanticConvention.DB_WHERE_DOCUMENT,
str(kwargs.get("where_document", "")))
elif gen_ai_endpoint == "chroma.query":
- db_operation = SemanticConvetion.DB_OPERATION_QUERY
- span.set_attribute(SemanticConvetion.DB_OPERATION_NAME,
- SemanticConvetion.DB_OPERATION_QUERY)
- span.set_attribute(SemanticConvetion.DB_STATEMENT,
+ db_operation = SemanticConvention.DB_OPERATION_QUERY
+ span.set_attribute(SemanticConvention.DB_OPERATION_NAME,
+ SemanticConvention.DB_OPERATION_QUERY)
+ span.set_attribute(SemanticConvention.DB_STATEMENT,
str(kwargs.get("query_texts", "")))
- span.set_attribute(SemanticConvetion.DB_N_RESULTS,
+ span.set_attribute(SemanticConvention.DB_N_RESULTS,
kwargs.get("n_results", ""))
- span.set_attribute(SemanticConvetion.DB_FILTER,
+ span.set_attribute(SemanticConvention.DB_FILTER,
str(kwargs.get("where", "")))
- span.set_attribute(SemanticConvetion.DB_WHERE_DOCUMENT,
+ span.set_attribute(SemanticConvention.DB_WHERE_DOCUMENT,
str(kwargs.get("where_document", "")))
elif gen_ai_endpoint == "chroma.update":
- db_operation = SemanticConvetion.DB_OPERATION_UPDATE
- span.set_attribute(SemanticConvetion.DB_OPERATION_NAME,
- SemanticConvetion.DB_OPERATION_UPDATE)
- span.set_attribute(SemanticConvetion.DB_VECTOR_COUNT,
+ db_operation = SemanticConvention.DB_OPERATION_UPDATE
+ span.set_attribute(SemanticConvention.DB_OPERATION_NAME,
+ SemanticConvention.DB_OPERATION_UPDATE)
+ span.set_attribute(SemanticConvention.DB_VECTOR_COUNT,
object_count(kwargs.get("embeddings", [])))
- span.set_attribute(SemanticConvetion.DB_VECTOR_COUNT,
+ span.set_attribute(SemanticConvention.DB_VECTOR_COUNT,
object_count(kwargs.get("metadatas", [])))
- span.set_attribute(SemanticConvetion.DB_ID_COUNT,
+ span.set_attribute(SemanticConvention.DB_ID_COUNT,
object_count(kwargs.get("ids", [])))
- span.set_attribute(SemanticConvetion.DB_DOCUMENTS_COUNT,
+ span.set_attribute(SemanticConvention.DB_DOCUMENTS_COUNT,
object_count(kwargs.get("documents", [])))
elif gen_ai_endpoint == "chroma.upsert":
- db_operation = SemanticConvetion.DB_OPERATION_UPSERT
- span.set_attribute(SemanticConvetion.DB_OPERATION_NAME,
- SemanticConvetion.DB_OPERATION_UPSERT)
- span.set_attribute(SemanticConvetion.DB_VECTOR_COUNT,
+ db_operation = SemanticConvention.DB_OPERATION_UPSERT
+ span.set_attribute(SemanticConvention.DB_OPERATION_NAME,
+ SemanticConvention.DB_OPERATION_UPSERT)
+ span.set_attribute(SemanticConvention.DB_VECTOR_COUNT,
object_count(kwargs.get("embeddings", [])))
- span.set_attribute(SemanticConvetion.DB_VECTOR_COUNT,
+ span.set_attribute(SemanticConvention.DB_VECTOR_COUNT,
object_count(kwargs.get("metadatas", [])))
- span.set_attribute(SemanticConvetion.DB_ID_COUNT,
+ span.set_attribute(SemanticConvention.DB_ID_COUNT,
object_count(kwargs.get("ids", [])))
- span.set_attribute(SemanticConvetion.DB_DOCUMENTS_COUNT,
+ span.set_attribute(SemanticConvention.DB_DOCUMENTS_COUNT,
object_count(kwargs.get("documents", [])))
elif gen_ai_endpoint == "chroma.delete":
- db_operation = SemanticConvetion.DB_OPERATION_DELETE
- span.set_attribute(SemanticConvetion.DB_OPERATION_NAME,
- SemanticConvetion.DB_OPERATION_DELETE)
- span.set_attribute(SemanticConvetion.DB_ID_COUNT,
+ db_operation = SemanticConvention.DB_OPERATION_DELETE
+ span.set_attribute(SemanticConvention.DB_OPERATION_NAME,
+ SemanticConvention.DB_OPERATION_DELETE)
+ span.set_attribute(SemanticConvention.DB_ID_COUNT,
object_count(kwargs.get("ids", [])))
- span.set_attribute(SemanticConvetion.DB_FILTER,
+ span.set_attribute(SemanticConvention.DB_FILTER,
str(kwargs.get("where", "")))
- span.set_attribute(SemanticConvetion.DB_DELETE_ALL,
+ span.set_attribute(SemanticConvention.DB_DELETE_ALL,
kwargs.get("delete_all", False))
- span.set_attribute(SemanticConvetion.DB_WHERE_DOCUMENT,
+ span.set_attribute(SemanticConvention.DB_WHERE_DOCUMENT,
str(kwargs.get("where_document", "")))
elif gen_ai_endpoint == "chroma.peek":
- db_operation = SemanticConvetion.DB_OPERATION_PEEK
- span.set_attribute(SemanticConvetion.DB_OPERATION_NAME,
- SemanticConvetion.DB_OPERATION_PEEK)
+ db_operation = SemanticConvention.DB_OPERATION_PEEK
+ span.set_attribute(SemanticConvention.DB_OPERATION_NAME,
+ SemanticConvention.DB_OPERATION_PEEK)
span.set_status(Status(StatusCode.OK))
@@ -175,13 +175,13 @@ def general_wrap(gen_ai_endpoint, version, environment, application_name,
"openlit",
SERVICE_NAME:
application_name,
- SemanticConvetion.DB_SYSTEM_NAME:
- SemanticConvetion.DB_SYSTEM_CHROMA,
+ SemanticConvention.DB_SYSTEM_NAME:
+ SemanticConvention.DB_SYSTEM_CHROMA,
DEPLOYMENT_ENVIRONMENT:
environment,
- SemanticConvetion.GEN_AI_OPERATION:
- SemanticConvetion.GEN_AI_OPERATION_TYPE_VECTORDB,
- SemanticConvetion.DB_OPERATION_NAME:
+ SemanticConvention.GEN_AI_OPERATION:
+ SemanticConvention.GEN_AI_OPERATION_TYPE_VECTORDB,
+ SemanticConvention.DB_OPERATION_NAME:
db_operation
}
diff --git a/sdk/python/src/openlit/instrumentation/cohere/async_cohere.py b/sdk/python/src/openlit/instrumentation/cohere/async_cohere.py
index 0049d75f..b4d14189 100644
--- a/sdk/python/src/openlit/instrumentation/cohere/async_cohere.py
+++ b/sdk/python/src/openlit/instrumentation/cohere/async_cohere.py
@@ -16,7 +16,7 @@ from openlit.__helpers import (
create_metrics_attributes,
set_server_address_and_port
)
-from openlit.semcov import SemanticConvetion
+from openlit.semcov import SemanticConvention
# Initialize logger for logging potential issues and operations
logger = logging.getLogger(__name__)
@@ -58,7 +58,7 @@ def async_embed(version, environment, application_name, tracer,
server_address, server_port = set_server_address_and_port(instance, "api.cohere.com", 443)
request_model = kwargs.get("model", "mbed-english-v3.0")
- span_name = f"{SemanticConvetion.GEN_AI_OPERATION_TYPE_EMBEDDING} {request_model}"
+ span_name = f"{SemanticConvention.GEN_AI_OPERATION_TYPE_EMBEDDING} {request_model}"
with tracer.start_as_current_span(span_name, kind= SpanKind.CLIENT) as span:
start_time = time.time()
@@ -74,23 +74,23 @@ def async_embed(version, environment, application_name, tracer,
# Set Span attributes (OTel Semconv)
span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
- span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
- SemanticConvetion.GEN_AI_OPERATION_TYPE_EMBEDDING)
- span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
- SemanticConvetion.GEN_AI_SYSTEM_COHERE)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_EMBEDDING)
+ span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
+ SemanticConvention.GEN_AI_SYSTEM_COHERE)
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
request_model)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_ENCODING_FORMATS,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_ENCODING_FORMATS,
kwargs.get('embedding_types', ['float']))
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL,
request_model)
- span.set_attribute(SemanticConvetion.SERVER_ADDRESS,
+ span.set_attribute(SemanticConvention.SERVER_ADDRESS,
server_address)
- span.set_attribute(SemanticConvetion.SERVER_PORT,
+ span.set_attribute(SemanticConvention.SERVER_PORT,
server_port)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_INPUT_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS,
input_tokens)
- span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
+ span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
response_dict.get('response_type'))
# Set Span attributes (Extras)
@@ -98,18 +98,18 @@ def async_embed(version, environment, application_name, tracer,
environment)
span.set_attribute(SERVICE_NAME,
application_name)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_TOTAL_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS,
input_tokens)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST,
cost)
- span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
+ span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION,
version)
if capture_message_content:
span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_PROMPT: str(kwargs.get("texts", "")),
+ SemanticConvention.GEN_AI_CONTENT_PROMPT: str(kwargs.get("texts", "")),
},
)
@@ -119,8 +119,8 @@ def async_embed(version, environment, application_name, tracer,
attributes = create_metrics_attributes(
service_name=application_name,
deployment_environment=environment,
- operation=SemanticConvetion.GEN_AI_OPERATION_TYPE_EMBEDDING,
- system=SemanticConvetion.GEN_AI_SYSTEM_COHERE,
+ operation=SemanticConvention.GEN_AI_OPERATION_TYPE_EMBEDDING,
+ system=SemanticConvention.GEN_AI_SYSTEM_COHERE,
request_model=request_model,
server_address=server_address,
server_port=server_port,
@@ -185,7 +185,7 @@ def async_chat(version, environment, application_name, tracer,
server_address, server_port = set_server_address_and_port(instance, "api.cohere.com", 443)
request_model = kwargs.get("model", "command-r-plus-08-2024")
- span_name = f"{SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT} {request_model}"
+ span_name = f"{SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT} {request_model}"
with tracer.start_as_current_span(span_name, kind=SpanKind.CLIENT) as span:
start_time = time.time()
@@ -224,45 +224,45 @@ def async_chat(version, environment, application_name, tracer,
# Set base span attribues (OTel Semconv)
span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
- span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
- SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT)
- span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
- SemanticConvetion.GEN_AI_SYSTEM_COHERE)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT)
+ span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
+ SemanticConvention.GEN_AI_SYSTEM_COHERE)
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
request_model)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_SEED,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_SEED,
kwargs.get("seed", ""))
- span.set_attribute(SemanticConvetion.SERVER_PORT,
+ span.set_attribute(SemanticConvention.SERVER_PORT,
server_port)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_FREQUENCY_PENALTY,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_FREQUENCY_PENALTY,
kwargs.get("frequency_penalty", 0.0))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MAX_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS,
kwargs.get("max_tokens", -1))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_PRESENCE_PENALTY,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_PRESENCE_PENALTY,
kwargs.get("presence_penalty", 0.0))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_STOP_SEQUENCES,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_STOP_SEQUENCES,
kwargs.get("stop_sequences", []))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TEMPERATURE,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TEMPERATURE,
kwargs.get("temperature", 0.3))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TOP_K,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TOP_K,
kwargs.get("k", 1.0))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TOP_P,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TOP_P,
kwargs.get("p", 1.0))
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_ID,
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_ID,
response_dict.get("id"))
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL,
request_model)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_INPUT_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS,
input_tokens)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_OUTPUT_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS,
output_tokens)
- span.set_attribute(SemanticConvetion.SERVER_ADDRESS,
+ span.set_attribute(SemanticConvention.SERVER_ADDRESS,
server_address)
if isinstance(llm_response, str):
- span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
+ span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
"text")
else:
- span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
+ span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
"json")
# Set base span attribues (Extras)
@@ -270,28 +270,28 @@ def async_chat(version, environment, application_name, tracer,
environment)
span.set_attribute(SERVICE_NAME,
application_name)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IS_STREAM,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM,
False)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_TOTAL_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS,
input_tokens + output_tokens)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST,
cost)
- span.set_attribute(SemanticConvetion.GEN_AI_SERVER_TTFT,
+ span.set_attribute(SemanticConvention.GEN_AI_SERVER_TTFT,
end_time - start_time)
- span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
+ span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION,
version)
if capture_message_content:
span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_PROMPT: prompt,
+ SemanticConvention.GEN_AI_CONTENT_PROMPT: prompt,
},
)
span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_COMPLETION_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_COMPLETION_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_COMPLETION: llm_response,
+ SemanticConvention.GEN_AI_CONTENT_COMPLETION: llm_response,
},
)
@@ -301,8 +301,8 @@ def async_chat(version, environment, application_name, tracer,
attributes = create_metrics_attributes(
service_name=application_name,
deployment_environment=environment,
- operation=SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT,
- system=SemanticConvetion.GEN_AI_SYSTEM_COHERE,
+ operation=SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
+ system=SemanticConvention.GEN_AI_SYSTEM_COHERE,
request_model=request_model,
server_address=server_address,
server_port=server_port,
@@ -486,48 +486,48 @@ def async_chat_stream(version, environment, application_name,
# Set Span attributes (OTel Semconv)
self._span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
- self._span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
- SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT)
- self._span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
- SemanticConvetion.GEN_AI_SYSTEM_COHERE)
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
+ self._span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT)
+ self._span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
+ SemanticConvention.GEN_AI_SYSTEM_COHERE)
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
request_model)
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_SEED,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_SEED,
self._kwargs.get("seed", ""))
- self._span.set_attribute(SemanticConvetion.SERVER_PORT,
+ self._span.set_attribute(SemanticConvention.SERVER_PORT,
self._server_port)
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_FREQUENCY_PENALTY,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_FREQUENCY_PENALTY,
self._kwargs.get("frequency_penalty", 0.0))
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MAX_TOKENS,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS,
self._kwargs.get("max_tokens", -1))
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_PRESENCE_PENALTY,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_PRESENCE_PENALTY,
self._kwargs.get("presence_penalty", 0.0))
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_STOP_SEQUENCES,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_STOP_SEQUENCES,
self._kwargs.get("stop_sequences", []))
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TEMPERATURE,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TEMPERATURE,
self._kwargs.get("temperature", 0.3))
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TOP_K,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TOP_K,
self._kwargs.get("k", 1.0))
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TOP_P,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TOP_P,
self._kwargs.get("p", 1.0))
- self._span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_FINISH_REASON,
+ self._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON,
[self._finish_reason])
- self._span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_ID,
+ self._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_ID,
self._response_id)
- self._span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_MODEL,
+ self._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL,
request_model)
- self._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_INPUT_TOKENS,
+ self._span.set_attribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS,
self._input_tokens)
- self._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_OUTPUT_TOKENS,
+ self._span.set_attribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS,
self._output_tokens)
- self._span.set_attribute(SemanticConvetion.SERVER_ADDRESS,
+ self._span.set_attribute(SemanticConvention.SERVER_ADDRESS,
self._server_address)
if isinstance(self._llmresponse, str):
- self._span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
+ self._span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
"text")
else:
- self._span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
+ self._span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
"json")
# Set Span attributes (Extra)
@@ -535,29 +535,29 @@ def async_chat_stream(version, environment, application_name,
environment)
self._span.set_attribute(SERVICE_NAME,
application_name)
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IS_STREAM,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM,
True)
- self._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_TOTAL_TOKENS,
+ self._span.set_attribute(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS,
self._input_tokens + self._output_tokens)
- self._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
+ self._span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST,
cost)
- self._span.set_attribute(SemanticConvetion.GEN_AI_SERVER_TBT,
+ self._span.set_attribute(SemanticConvention.GEN_AI_SERVER_TBT,
self._tbt)
- self._span.set_attribute(SemanticConvetion.GEN_AI_SERVER_TTFT,
+ self._span.set_attribute(SemanticConvention.GEN_AI_SERVER_TTFT,
self._ttft)
- self._span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
+ self._span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION,
version)
if capture_message_content:
self._span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_PROMPT: prompt,
+ SemanticConvention.GEN_AI_CONTENT_PROMPT: prompt,
},
)
self._span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_COMPLETION_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_COMPLETION_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_COMPLETION: self._llmresponse,
+ SemanticConvention.GEN_AI_CONTENT_COMPLETION: self._llmresponse,
},
)
self._span.set_status(Status(StatusCode.OK))
@@ -566,8 +566,8 @@ def async_chat_stream(version, environment, application_name,
attributes = create_metrics_attributes(
service_name=application_name,
deployment_environment=environment,
- operation=SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT,
- system=SemanticConvetion.GEN_AI_SYSTEM_COHERE,
+ operation=SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
+ system=SemanticConvention.GEN_AI_SYSTEM_COHERE,
request_model=request_model,
server_address=self._server_address,
server_port=self._server_port,
@@ -601,7 +601,7 @@ def async_chat_stream(version, environment, application_name,
server_address, server_port = set_server_address_and_port(instance, "api.cohere.com", 443)
request_model = kwargs.get("model", "command-r-plus")
- span_name = f"{SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT} {request_model}"
+ span_name = f"{SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT} {request_model}"
awaited_wrapped = await wrapped(*args, **kwargs)
span = tracer.start_span(span_name, kind=SpanKind.CLIENT)
diff --git a/sdk/python/src/openlit/instrumentation/cohere/cohere.py b/sdk/python/src/openlit/instrumentation/cohere/cohere.py
index a9db0dd5..fc98ea85 100644
--- a/sdk/python/src/openlit/instrumentation/cohere/cohere.py
+++ b/sdk/python/src/openlit/instrumentation/cohere/cohere.py
@@ -16,7 +16,7 @@ from openlit.__helpers import (
create_metrics_attributes,
set_server_address_and_port
)
-from openlit.semcov import SemanticConvetion
+from openlit.semcov import SemanticConvention
# Initialize logger for logging potential issues and operations
logger = logging.getLogger(__name__)
@@ -58,7 +58,7 @@ def embed(version, environment, application_name, tracer,
server_address, server_port = set_server_address_and_port(instance, "api.cohere.com", 443)
request_model = kwargs.get("model", "mbed-english-v3.0")
- span_name = f"{SemanticConvetion.GEN_AI_OPERATION_TYPE_EMBEDDING} {request_model}"
+ span_name = f"{SemanticConvention.GEN_AI_OPERATION_TYPE_EMBEDDING} {request_model}"
with tracer.start_as_current_span(span_name, kind= SpanKind.CLIENT) as span:
start_time = time.time()
@@ -74,23 +74,23 @@ def embed(version, environment, application_name, tracer,
# Set Span attributes (OTel Semconv)
span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
- span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
- SemanticConvetion.GEN_AI_OPERATION_TYPE_EMBEDDING)
- span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
- SemanticConvetion.GEN_AI_SYSTEM_COHERE)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_EMBEDDING)
+ span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
+ SemanticConvention.GEN_AI_SYSTEM_COHERE)
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
request_model)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_ENCODING_FORMATS,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_ENCODING_FORMATS,
kwargs.get('embedding_types', ['float']))
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL,
request_model)
- span.set_attribute(SemanticConvetion.SERVER_ADDRESS,
+ span.set_attribute(SemanticConvention.SERVER_ADDRESS,
server_address)
- span.set_attribute(SemanticConvetion.SERVER_PORT,
+ span.set_attribute(SemanticConvention.SERVER_PORT,
server_port)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_INPUT_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS,
input_tokens)
- span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
+ span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
response_dict.get('response_type'))
# Set Span attributes (Extras)
@@ -98,18 +98,18 @@ def embed(version, environment, application_name, tracer,
environment)
span.set_attribute(SERVICE_NAME,
application_name)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_TOTAL_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS,
input_tokens)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST,
cost)
- span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
+ span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION,
version)
if capture_message_content:
span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_PROMPT: str(kwargs.get("texts", "")),
+ SemanticConvention.GEN_AI_CONTENT_PROMPT: str(kwargs.get("texts", "")),
},
)
@@ -119,8 +119,8 @@ def embed(version, environment, application_name, tracer,
attributes = create_metrics_attributes(
service_name=application_name,
deployment_environment=environment,
- operation=SemanticConvetion.GEN_AI_OPERATION_TYPE_EMBEDDING,
- system=SemanticConvetion.GEN_AI_SYSTEM_COHERE,
+ operation=SemanticConvention.GEN_AI_OPERATION_TYPE_EMBEDDING,
+ system=SemanticConvention.GEN_AI_SYSTEM_COHERE,
request_model=request_model,
server_address=server_address,
server_port=server_port,
@@ -185,7 +185,7 @@ def chat(version, environment, application_name, tracer,
server_address, server_port = set_server_address_and_port(instance, "api.cohere.com", 443)
request_model = kwargs.get("model", "command-r-plus-08-2024")
- span_name = f"{SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT} {request_model}"
+ span_name = f"{SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT} {request_model}"
with tracer.start_as_current_span(span_name, kind=SpanKind.CLIENT) as span:
start_time = time.time()
@@ -224,45 +224,45 @@ def chat(version, environment, application_name, tracer,
# Set base span attribues (OTel Semconv)
span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
- span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
- SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT)
- span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
- SemanticConvetion.GEN_AI_SYSTEM_COHERE)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT)
+ span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
+ SemanticConvention.GEN_AI_SYSTEM_COHERE)
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
request_model)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_SEED,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_SEED,
kwargs.get("seed", ""))
- span.set_attribute(SemanticConvetion.SERVER_PORT,
+ span.set_attribute(SemanticConvention.SERVER_PORT,
server_port)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_FREQUENCY_PENALTY,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_FREQUENCY_PENALTY,
kwargs.get("frequency_penalty", 0.0))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MAX_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS,
kwargs.get("max_tokens", -1))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_PRESENCE_PENALTY,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_PRESENCE_PENALTY,
kwargs.get("presence_penalty", 0.0))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_STOP_SEQUENCES,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_STOP_SEQUENCES,
kwargs.get("stop_sequences", []))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TEMPERATURE,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TEMPERATURE,
kwargs.get("temperature", 0.3))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TOP_K,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TOP_K,
kwargs.get("k", 1.0))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TOP_P,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TOP_P,
kwargs.get("p", 1.0))
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_ID,
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_ID,
response_dict.get("id"))
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL,
request_model)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_INPUT_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS,
input_tokens)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_OUTPUT_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS,
output_tokens)
- span.set_attribute(SemanticConvetion.SERVER_ADDRESS,
+ span.set_attribute(SemanticConvention.SERVER_ADDRESS,
server_address)
if isinstance(llm_response, str):
- span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
+ span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
"text")
else:
- span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
+ span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
"json")
# Set base span attribues (Extras)
@@ -270,28 +270,28 @@ def chat(version, environment, application_name, tracer,
environment)
span.set_attribute(SERVICE_NAME,
application_name)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IS_STREAM,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM,
False)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_TOTAL_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS,
input_tokens + output_tokens)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST,
cost)
- span.set_attribute(SemanticConvetion.GEN_AI_SERVER_TTFT,
+ span.set_attribute(SemanticConvention.GEN_AI_SERVER_TTFT,
end_time - start_time)
- span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
+ span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION,
version)
if capture_message_content:
span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_PROMPT: prompt,
+ SemanticConvention.GEN_AI_CONTENT_PROMPT: prompt,
},
)
span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_COMPLETION_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_COMPLETION_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_COMPLETION: llm_response,
+ SemanticConvention.GEN_AI_CONTENT_COMPLETION: llm_response,
},
)
@@ -301,8 +301,8 @@ def chat(version, environment, application_name, tracer,
attributes = create_metrics_attributes(
service_name=application_name,
deployment_environment=environment,
- operation=SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT,
- system=SemanticConvetion.GEN_AI_SYSTEM_COHERE,
+ operation=SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
+ system=SemanticConvention.GEN_AI_SYSTEM_COHERE,
request_model=request_model,
server_address=server_address,
server_port=server_port,
@@ -486,48 +486,48 @@ def chat_stream(version, environment, application_name,
# Set Span attributes (OTel Semconv)
self._span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
- self._span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
- SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT)
- self._span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
- SemanticConvetion.GEN_AI_SYSTEM_COHERE)
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
+ self._span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT)
+ self._span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
+ SemanticConvention.GEN_AI_SYSTEM_COHERE)
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
request_model)
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_SEED,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_SEED,
self._kwargs.get("seed", ""))
- self._span.set_attribute(SemanticConvetion.SERVER_PORT,
+ self._span.set_attribute(SemanticConvention.SERVER_PORT,
self._server_port)
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_FREQUENCY_PENALTY,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_FREQUENCY_PENALTY,
self._kwargs.get("frequency_penalty", 0.0))
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MAX_TOKENS,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS,
self._kwargs.get("max_tokens", -1))
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_PRESENCE_PENALTY,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_PRESENCE_PENALTY,
self._kwargs.get("presence_penalty", 0.0))
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_STOP_SEQUENCES,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_STOP_SEQUENCES,
self._kwargs.get("stop_sequences", []))
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TEMPERATURE,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TEMPERATURE,
self._kwargs.get("temperature", 0.3))
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TOP_K,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TOP_K,
self._kwargs.get("k", 1.0))
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TOP_P,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TOP_P,
self._kwargs.get("p", 1.0))
- self._span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_FINISH_REASON,
+ self._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON,
[self._finish_reason])
- self._span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_ID,
+ self._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_ID,
self._response_id)
- self._span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_MODEL,
+ self._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL,
request_model)
- self._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_INPUT_TOKENS,
+ self._span.set_attribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS,
self._input_tokens)
- self._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_OUTPUT_TOKENS,
+ self._span.set_attribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS,
self._output_tokens)
- self._span.set_attribute(SemanticConvetion.SERVER_ADDRESS,
+ self._span.set_attribute(SemanticConvention.SERVER_ADDRESS,
self._server_address)
if isinstance(self._llmresponse, str):
- self._span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
+ self._span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
"text")
else:
- self._span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
+ self._span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
"json")
# Set Span attributes (Extra)
@@ -535,29 +535,29 @@ def chat_stream(version, environment, application_name,
environment)
self._span.set_attribute(SERVICE_NAME,
application_name)
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IS_STREAM,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM,
True)
- self._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_TOTAL_TOKENS,
+ self._span.set_attribute(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS,
self._input_tokens + self._output_tokens)
- self._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
+ self._span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST,
cost)
- self._span.set_attribute(SemanticConvetion.GEN_AI_SERVER_TBT,
+ self._span.set_attribute(SemanticConvention.GEN_AI_SERVER_TBT,
self._tbt)
- self._span.set_attribute(SemanticConvetion.GEN_AI_SERVER_TTFT,
+ self._span.set_attribute(SemanticConvention.GEN_AI_SERVER_TTFT,
self._ttft)
- self._span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
+ self._span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION,
version)
if capture_message_content:
self._span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_PROMPT: prompt,
+ SemanticConvention.GEN_AI_CONTENT_PROMPT: prompt,
},
)
self._span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_COMPLETION_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_COMPLETION_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_COMPLETION: self._llmresponse,
+ SemanticConvention.GEN_AI_CONTENT_COMPLETION: self._llmresponse,
},
)
self._span.set_status(Status(StatusCode.OK))
@@ -566,8 +566,8 @@ def chat_stream(version, environment, application_name,
attributes = create_metrics_attributes(
service_name=application_name,
deployment_environment=environment,
- operation=SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT,
- system=SemanticConvetion.GEN_AI_SYSTEM_COHERE,
+ operation=SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
+ system=SemanticConvention.GEN_AI_SYSTEM_COHERE,
request_model=request_model,
server_address=self._server_address,
server_port=self._server_port,
@@ -601,7 +601,7 @@ def chat_stream(version, environment, application_name,
server_address, server_port = set_server_address_and_port(instance, "api.cohere.com", 443)
request_model = kwargs.get("model", "command-r-plus")
- span_name = f"{SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT} {request_model}"
+ span_name = f"{SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT} {request_model}"
awaited_wrapped = wrapped(*args, **kwargs)
span = tracer.start_span(span_name, kind=SpanKind.CLIENT)
diff --git a/sdk/python/src/openlit/instrumentation/controlflow/controlflow.py b/sdk/python/src/openlit/instrumentation/controlflow/controlflow.py
index 232ca2e8..5c8be8a9 100644
--- a/sdk/python/src/openlit/instrumentation/controlflow/controlflow.py
+++ b/sdk/python/src/openlit/instrumentation/controlflow/controlflow.py
@@ -7,7 +7,7 @@ import logging
from opentelemetry.trace import SpanKind, Status, StatusCode
from opentelemetry.sdk.resources import SERVICE_NAME, TELEMETRY_SDK_NAME, DEPLOYMENT_ENVIRONMENT
from openlit.__helpers import handle_exception
-from openlit.semcov import SemanticConvetion
+from openlit.semcov import SemanticConvention
# Initialize logger for logging potential issues and operations
logger = logging.getLogger(__name__)
@@ -60,42 +60,42 @@ def wrap_controlflow(gen_ai_endpoint, version, environment, application_name,
try:
span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
- span.set_attribute(SemanticConvetion.GEN_AI_ENDPOINT,
+ span.set_attribute(SemanticConvention.GEN_AI_ENDPOINT,
gen_ai_endpoint)
- span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
- SemanticConvetion.GEN_AI_SYSTEM_CONTROLFLOW)
+ span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
+ SemanticConvention.GEN_AI_SYSTEM_CONTROLFLOW)
span.set_attribute(DEPLOYMENT_ENVIRONMENT,
environment)
span.set_attribute(SERVICE_NAME,
application_name)
- span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
- SemanticConvetion.GEN_AI_OPERATION_TYPE_AGENT)
+ span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_AGENT)
if gen_ai_endpoint == "controlflow.create_agent":
- span.set_attribute(SemanticConvetion.GEN_AI_AGENT_ROLE,
+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_ROLE,
instance.name)
- span.set_attribute(SemanticConvetion.GEN_AI_AGENT_INSTRUCTIONS,
+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_INSTRUCTIONS,
kwargs.get("instructions", ""))
- span.set_attribute(SemanticConvetion.GEN_AI_AGENT_TOOLS,
+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_TOOLS,
str(kwargs.get("tools", "")))
try:
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
instance.model.model_name)
except:
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
kwargs.get("model", "openai/gpt-4o-mini"))
elif gen_ai_endpoint == "controlflow.create_task":
if kwargs.get("objective","") == "":
- span.set_attribute(SemanticConvetion.GEN_AI_AGENT_GOAL,
+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_GOAL,
str(args[0]))
else:
- span.set_attribute(SemanticConvetion.GEN_AI_AGENT_GOAL,
+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_GOAL,
kwargs.get("objective",""))
- span.set_attribute(SemanticConvetion.GEN_AI_AGENT_INSTRUCTIONS,
+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_INSTRUCTIONS,
kwargs.get("instructions", ""))
- span.set_attribute(SemanticConvetion.GEN_AI_AGENT_CONTEXT,
+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_CONTEXT,
str(kwargs.get("context", "")))
span.set_status(Status(StatusCode.OK))
diff --git a/sdk/python/src/openlit/instrumentation/crawl4ai/async_crawl4ai.py b/sdk/python/src/openlit/instrumentation/crawl4ai/async_crawl4ai.py
index 890e7693..bd067745 100644
--- a/sdk/python/src/openlit/instrumentation/crawl4ai/async_crawl4ai.py
+++ b/sdk/python/src/openlit/instrumentation/crawl4ai/async_crawl4ai.py
@@ -9,7 +9,7 @@ from opentelemetry.sdk.resources import SERVICE_NAME, TELEMETRY_SDK_NAME, DEPLOY
from openlit.__helpers import (
handle_exception,
)
-from openlit.semcov import SemanticConvetion
+from openlit.semcov import SemanticConvention
# Initialize logger for logging potential issues and operations
logger = logging.getLogger(__name__)
@@ -56,38 +56,38 @@ def async_wrap_crawl(gen_ai_endpoint, version, environment, application_name,
try:
# Set base span attribues
span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
- span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
- SemanticConvetion.GEN_AI_SYSTEM_CRAWL4AI)
- span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
- SemanticConvetion.GEN_AI_OPERATION_TYPE_AGENT)
- span.set_attribute(SemanticConvetion.GEN_AI_ENDPOINT,
+ span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
+ SemanticConvention.GEN_AI_SYSTEM_CRAWL4AI)
+ span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_AGENT)
+ span.set_attribute(SemanticConvention.GEN_AI_ENDPOINT,
gen_ai_endpoint)
span.set_attribute(SERVICE_NAME,
application_name)
span.set_attribute(DEPLOYMENT_ENVIRONMENT,
environment)
- span.set_attribute(SemanticConvetion.GEN_AI_AGENT_TYPE,
- SemanticConvetion.GEN_AI_AGENT_TYPE_BROWSER)
- span.set_attribute(SemanticConvetion.GEN_AI_AGENT_ENABLE_CACHE, not kwargs.get("disable_cache", False))
+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_TYPE,
+ SemanticConvention.GEN_AI_AGENT_TYPE_BROWSER)
+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_ENABLE_CACHE, not kwargs.get("disable_cache", False))
url = kwargs.get("url") if "url" in kwargs else str(args[0]) if args else None
if url is not None:
- span.set_attribute(SemanticConvetion.GEN_AI_AGENT_BROWSE_URL, url)
+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_BROWSE_URL, url)
extraction_strategy = kwargs.get("extraction_strategy", "NoExtractionStrategy")
extraction_name = extraction_strategy.name if hasattr(extraction_strategy, 'name') else extraction_strategy
- span.set_attribute(SemanticConvetion.GEN_AI_AGENT_STRATEGY, extraction_name)
+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_STRATEGY, extraction_name)
if extraction_name == "LLMExtractionStrategy" and hasattr(extraction_strategy, 'provider'):
_, llm_model = extraction_strategy.provider.split('/')
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL, llm_model)
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL, llm_model)
elif extraction_name == "CosineStrategy":
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL, "all-MiniLM-L6-v2")
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL, "all-MiniLM-L6-v2")
elif extraction_name == "JsonCssExtractionStrategy" and hasattr(extraction_strategy, 'schema'):
- span.set_attribute(SemanticConvetion.GEN_AI_AGENT_SCHEMA, str(extraction_strategy.schema))
+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_SCHEMA, str(extraction_strategy.schema))
span.set_status(Status(StatusCode.OK))
diff --git a/sdk/python/src/openlit/instrumentation/crawl4ai/crawl4ai.py b/sdk/python/src/openlit/instrumentation/crawl4ai/crawl4ai.py
index f4fe50b3..d9dd68e4 100644
--- a/sdk/python/src/openlit/instrumentation/crawl4ai/crawl4ai.py
+++ b/sdk/python/src/openlit/instrumentation/crawl4ai/crawl4ai.py
@@ -9,7 +9,7 @@ from opentelemetry.sdk.resources import SERVICE_NAME, TELEMETRY_SDK_NAME, DEPLOY
from openlit.__helpers import (
handle_exception,
)
-from openlit.semcov import SemanticConvetion
+from openlit.semcov import SemanticConvention
# Initialize logger for logging potential issues and operations
logger = logging.getLogger(__name__)
@@ -56,38 +56,38 @@ def wrap_crawl(gen_ai_endpoint, version, environment, application_name,
try:
# Set base span attribues
span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
- span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
- SemanticConvetion.GEN_AI_SYSTEM_CRAWL4AI)
- span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
- SemanticConvetion.GEN_AI_OPERATION_TYPE_AGENT)
- span.set_attribute(SemanticConvetion.GEN_AI_ENDPOINT,
+ span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
+ SemanticConvention.GEN_AI_SYSTEM_CRAWL4AI)
+ span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_AGENT)
+ span.set_attribute(SemanticConvention.GEN_AI_ENDPOINT,
gen_ai_endpoint)
span.set_attribute(SERVICE_NAME,
application_name)
span.set_attribute(DEPLOYMENT_ENVIRONMENT,
environment)
- span.set_attribute(SemanticConvetion.GEN_AI_AGENT_TYPE,
- SemanticConvetion.GEN_AI_AGENT_TYPE_BROWSER)
- span.set_attribute(SemanticConvetion.GEN_AI_AGENT_ENABLE_CACHE, not kwargs.get("disable_cache", False))
+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_TYPE,
+ SemanticConvention.GEN_AI_AGENT_TYPE_BROWSER)
+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_ENABLE_CACHE, not kwargs.get("disable_cache", False))
url = kwargs.get("url") if "url" in kwargs else str(args[0]) if args else None
if url is not None:
- span.set_attribute(SemanticConvetion.GEN_AI_AGENT_BROWSE_URL, url)
+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_BROWSE_URL, url)
extraction_strategy = kwargs.get("extraction_strategy", "NoExtractionStrategy")
extraction_name = extraction_strategy.name if hasattr(extraction_strategy, 'name') else extraction_strategy
- span.set_attribute(SemanticConvetion.GEN_AI_AGENT_STRATEGY, extraction_name)
+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_STRATEGY, extraction_name)
if extraction_name == "LLMExtractionStrategy" and hasattr(extraction_strategy, 'provider'):
_, llm_model = extraction_strategy.provider.split('/')
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL, llm_model)
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL, llm_model)
elif extraction_name == "CosineStrategy":
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL, "all-MiniLM-L6-v2")
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL, "all-MiniLM-L6-v2")
elif extraction_name == "JsonCssExtractionStrategy" and hasattr(extraction_strategy, 'schema'):
- span.set_attribute(SemanticConvetion.GEN_AI_AGENT_SCHEMA, str(extraction_strategy.schema))
+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_SCHEMA, str(extraction_strategy.schema))
span.set_status(Status(StatusCode.OK))
diff --git a/sdk/python/src/openlit/instrumentation/crewai/crewai.py b/sdk/python/src/openlit/instrumentation/crewai/crewai.py
index 75f946ae..431fb7fe 100644
--- a/sdk/python/src/openlit/instrumentation/crewai/crewai.py
+++ b/sdk/python/src/openlit/instrumentation/crewai/crewai.py
@@ -10,7 +10,7 @@ from opentelemetry.sdk.resources import SERVICE_NAME, TELEMETRY_SDK_NAME, DEPLOY
from openlit.__helpers import (
handle_exception,
)
-from openlit.semcov import SemanticConvetion
+from openlit.semcov import SemanticConvention
# Initialize logger for logging potential issues and operations
logger = logging.getLogger(__name__)
@@ -69,11 +69,11 @@ def crew_wrap(gen_ai_endpoint, version, environment, application_name,
try:
# Set base span attribues
span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
- span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
- SemanticConvetion.GEN_AI_SYSTEM_CREWAI)
- span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
- SemanticConvetion.GEN_AI_OPERATION_TYPE_AGENT)
- span.set_attribute(SemanticConvetion.GEN_AI_ENDPOINT,
+ span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
+ SemanticConvention.GEN_AI_SYSTEM_CREWAI)
+ span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_AGENT)
+ span.set_attribute(SemanticConvention.GEN_AI_ENDPOINT,
gen_ai_endpoint)
span.set_attribute(SERVICE_NAME,
application_name)
@@ -95,17 +95,17 @@ def crew_wrap(gen_ai_endpoint, version, environment, application_name,
else:
task[key] = str(value)
- span.set_attribute(SemanticConvetion.GEN_AI_AGENT_TASK_ID,
+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_TASK_ID,
task.get('id', ''))
- span.set_attribute(SemanticConvetion.GEN_AI_AGENT_TASK,
+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_TASK,
task.get('description', ''))
- span.set_attribute(SemanticConvetion.GEN_AI_AGENT_EXPECTED_OUTPUT,
+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_EXPECTED_OUTPUT,
task.get('expected_output', ''))
- span.set_attribute(SemanticConvetion.GEN_AI_AGENT_ACTUAL_OUTPUT,
+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_ACTUAL_OUTPUT,
task.get('output', ''))
- span.set_attribute(SemanticConvetion.GEN_AI_AGENT_HUMAN_INPUT,
+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_HUMAN_INPUT,
task.get('human_input', ''))
- span.set_attribute(SemanticConvetion.GEN_AI_AGENT_TASK_ASSOCIATION,
+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_TASK_ASSOCIATION,
str(task.get('processed_by_agents', '')))
elif instance_class == "Agent":
@@ -117,25 +117,25 @@ def crew_wrap(gen_ai_endpoint, version, environment, application_name,
continue
agent[key] = str(value)
- span.set_attribute(SemanticConvetion.GEN_AI_AGENT_ID,
+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_ID,
agent.get('id', ''))
- span.set_attribute(SemanticConvetion.GEN_AI_AGENT_ROLE,
+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_ROLE,
agent.get('role', ''))
- span.set_attribute(SemanticConvetion.GEN_AI_AGENT_GOAL,
+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_GOAL,
agent.get('goal', ''))
- span.set_attribute(SemanticConvetion.GEN_AI_AGENT_CONTEXT,
+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_CONTEXT,
agent.get('backstory', ''))
- span.set_attribute(SemanticConvetion.GEN_AI_AGENT_ENABLE_CACHE,
+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_ENABLE_CACHE,
agent.get('cache', ''))
- span.set_attribute(SemanticConvetion.GEN_AI_AGENT_ALLOW_DELEGATION,
+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_ALLOW_DELEGATION,
agent.get('allow_delegation', ''))
- span.set_attribute(SemanticConvetion.GEN_AI_AGENT_ALLOW_CODE_EXECUTION,
+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_ALLOW_CODE_EXECUTION,
agent.get('allow_code_execution', ''))
- span.set_attribute(SemanticConvetion.GEN_AI_AGENT_MAX_RETRY_LIMIT,
+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_MAX_RETRY_LIMIT,
agent.get('max_retry_limit', ''))
- span.set_attribute(SemanticConvetion.GEN_AI_AGENT_TOOLS,
+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_TOOLS,
str(agent.get('tools', '')))
- span.set_attribute(SemanticConvetion.GEN_AI_AGENT_TOOL_RESULTS,
+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_TOOL_RESULTS,
str(agent.get('tools_results', '')))
span.set_status(Status(StatusCode.OK))
diff --git a/sdk/python/src/openlit/instrumentation/dynamiq/dynamiq.py b/sdk/python/src/openlit/instrumentation/dynamiq/dynamiq.py
index 260c90e6..4eb3f978 100644
--- a/sdk/python/src/openlit/instrumentation/dynamiq/dynamiq.py
+++ b/sdk/python/src/openlit/instrumentation/dynamiq/dynamiq.py
@@ -9,7 +9,7 @@ from opentelemetry.sdk.resources import SERVICE_NAME, TELEMETRY_SDK_NAME, DEPLOY
from openlit.__helpers import (
handle_exception,
)
-from openlit.semcov import SemanticConvetion
+from openlit.semcov import SemanticConvention
# Initialize logger for logging potential issues and operations
logger = logging.getLogger(__name__)
@@ -56,11 +56,11 @@ def dynamiq_wrap(gen_ai_endpoint, version, environment, application_name,
try:
# Set base span attribues
span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
- span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
- SemanticConvetion.GEN_AI_SYSTEM_DYNAMIQ)
- span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
- SemanticConvetion.GEN_AI_OPERATION_TYPE_AGENT)
- span.set_attribute(SemanticConvetion.GEN_AI_ENDPOINT,
+ span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
+ SemanticConvention.GEN_AI_SYSTEM_DYNAMIQ)
+ span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_AGENT)
+ span.set_attribute(SemanticConvention.GEN_AI_ENDPOINT,
gen_ai_endpoint)
span.set_attribute(SERVICE_NAME,
application_name)
@@ -68,32 +68,32 @@ def dynamiq_wrap(gen_ai_endpoint, version, environment, application_name,
environment)
if gen_ai_endpoint == "dynamiq.agent_run":
- span.set_attribute(SemanticConvetion.GEN_AI_AGENT_ID,
+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_ID,
getattr(instance, 'id', '') or '')
- span.set_attribute(SemanticConvetion.GEN_AI_AGENT_ROLE,
+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_ROLE,
getattr(instance, 'name', '') or '')
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
getattr(getattr(instance, 'llm', None), 'model', '') or '')
- span.set_attribute(SemanticConvetion.GEN_AI_AGENT_TYPE,
+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_TYPE,
str(getattr(instance, 'type', '')) or '')
elif gen_ai_endpoint == "dynamiq.workflow_run":
- span.set_attribute(SemanticConvetion.GEN_AI_AGENT_ID,
+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_ID,
getattr(instance, 'id', '') or '')
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
getattr(getattr(instance.flow, 'nodes', [None])[0], 'model', 'default_model'))
elif gen_ai_endpoint == "dynamiq.memory_add":
- span.set_attribute(SemanticConvetion.DB_OPERATION_NAME,
- SemanticConvetion.DB_OPERATION_ADD)
- span.set_attribute(SemanticConvetion.DB_METADATA, str(kwargs.get('metadata', '')))
+ span.set_attribute(SemanticConvention.DB_OPERATION_NAME,
+ SemanticConvention.DB_OPERATION_ADD)
+ span.set_attribute(SemanticConvention.DB_METADATA, str(kwargs.get('metadata', '')))
elif gen_ai_endpoint == "dynamiq.memory_search":
query_value = kwargs.get('query', '') or (args[0] if args else '')
- span.set_attribute(SemanticConvetion.DB_OPERATION_NAME,
- SemanticConvetion.DB_OPERATION_GET)
- span.set_attribute(SemanticConvetion.DB_FILTER, str(kwargs.get('filters', '')))
- span.set_attribute(SemanticConvetion.DB_STATEMENT, query_value)
+ span.set_attribute(SemanticConvention.DB_OPERATION_NAME,
+ SemanticConvention.DB_OPERATION_GET)
+ span.set_attribute(SemanticConvention.DB_FILTER, str(kwargs.get('filters', '')))
+ span.set_attribute(SemanticConvention.DB_STATEMENT, query_value)
span.set_status(Status(StatusCode.OK))
diff --git a/sdk/python/src/openlit/instrumentation/elevenlabs/async_elevenlabs.py b/sdk/python/src/openlit/instrumentation/elevenlabs/async_elevenlabs.py
index cdbb837c..6297cccb 100644
--- a/sdk/python/src/openlit/instrumentation/elevenlabs/async_elevenlabs.py
+++ b/sdk/python/src/openlit/instrumentation/elevenlabs/async_elevenlabs.py
@@ -11,7 +11,7 @@ from openlit.__helpers import (
handle_exception,
create_metrics_attributes,
)
-from openlit.semcov import SemanticConvetion
+from openlit.semcov import SemanticConvention
# Initialize logger for logging potential issues and operations
logger = logging.getLogger(__name__)
@@ -53,7 +53,7 @@ def async_generate(gen_ai_endpoint, version, environment, application_name,
server_address, server_port = "api.elevenlabs.io", 443
request_model = kwargs.get('model', kwargs.get('model_id', 'eleven_multilingual_v2'))
- span_name = f'{SemanticConvetion.GEN_AI_OPERATION_TYPE_AUDIO} {request_model}'
+ span_name = f'{SemanticConvention.GEN_AI_OPERATION_TYPE_AUDIO} {request_model}'
with tracer.start_as_current_span(span_name, kind= SpanKind.CLIENT) as span:
start_time = time.time()
@@ -67,48 +67,48 @@ def async_generate(gen_ai_endpoint, version, environment, application_name,
# Set Span attributes
span.set_attribute(TELEMETRY_SDK_NAME, 'openlit')
- span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
- SemanticConvetion.GEN_AI_OPERATION_TYPE_AUDIO)
- span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
- SemanticConvetion.GEN_AI_SYSTEM_ASSEMBLYAI)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_AUDIO)
+ span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
+ SemanticConvention.GEN_AI_SYSTEM_ASSEMBLYAI)
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
request_model)
- span.set_attribute(SemanticConvetion.SERVER_ADDRESS,
+ span.set_attribute(SemanticConvention.SERVER_ADDRESS,
server_address)
- span.set_attribute(SemanticConvetion.SERVER_PORT,
+ span.set_attribute(SemanticConvention.SERVER_PORT,
server_port)
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL,
request_model)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
request_model)
- span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
+ span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
'audio')
# Set Span attributes (Extras)
if gen_ai_endpoint == 'elevenlabs.generate':
if isinstance(kwargs.get('voice', 'Rachel'), str):
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_AUDIO_VOICE,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_AUDIO_VOICE,
kwargs.get('voice', 'Rachel'))
else:
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_AUDIO_VOICE,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_AUDIO_VOICE,
kwargs.get('voice_id', ''))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_AUDIO_RESPONSE_FORMAT,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_AUDIO_RESPONSE_FORMAT,
kwargs.get('output_format', 'mp3'))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_AUDIO_SETTINGS,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_AUDIO_SETTINGS,
str(kwargs.get('voice_settings', '')))
span.set_attribute(DEPLOYMENT_ENVIRONMENT,
environment)
span.set_attribute(SERVICE_NAME,
application_name)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST,
cost)
- span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
+ span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION,
version)
if capture_message_content:
span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_PROMPT: str(kwargs.get('text', '')),
+ SemanticConvention.GEN_AI_CONTENT_PROMPT: str(kwargs.get('text', '')),
},
)
@@ -118,8 +118,8 @@ def async_generate(gen_ai_endpoint, version, environment, application_name,
attributes = create_metrics_attributes(
service_name=application_name,
deployment_environment=environment,
- operation=SemanticConvetion.GEN_AI_OPERATION_TYPE_AUDIO,
- system=SemanticConvetion.GEN_AI_SYSTEM_ELEVENLABS,
+ operation=SemanticConvention.GEN_AI_OPERATION_TYPE_AUDIO,
+ system=SemanticConvention.GEN_AI_SYSTEM_ELEVENLABS,
request_model=request_model,
server_address=server_address,
server_port=server_port,
diff --git a/sdk/python/src/openlit/instrumentation/elevenlabs/elevenlabs.py b/sdk/python/src/openlit/instrumentation/elevenlabs/elevenlabs.py
index b3745965..84f9c99b 100644
--- a/sdk/python/src/openlit/instrumentation/elevenlabs/elevenlabs.py
+++ b/sdk/python/src/openlit/instrumentation/elevenlabs/elevenlabs.py
@@ -11,7 +11,7 @@ from openlit.__helpers import (
handle_exception,
create_metrics_attributes,
)
-from openlit.semcov import SemanticConvetion
+from openlit.semcov import SemanticConvention
# Initialize logger for logging potential issues and operations
logger = logging.getLogger(__name__)
@@ -53,7 +53,7 @@ def generate(gen_ai_endpoint, version, environment, application_name,
server_address, server_port = "api.elevenlabs.io", 443
request_model = kwargs.get('model', kwargs.get('model_id', 'eleven_multilingual_v2'))
- span_name = f'{SemanticConvetion.GEN_AI_OPERATION_TYPE_AUDIO} {request_model}'
+ span_name = f'{SemanticConvention.GEN_AI_OPERATION_TYPE_AUDIO} {request_model}'
with tracer.start_as_current_span(span_name, kind= SpanKind.CLIENT) as span:
start_time = time.time()
@@ -67,48 +67,48 @@ def generate(gen_ai_endpoint, version, environment, application_name,
# Set Span attributes
span.set_attribute(TELEMETRY_SDK_NAME, 'openlit')
- span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
- SemanticConvetion.GEN_AI_OPERATION_TYPE_AUDIO)
- span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
- SemanticConvetion.GEN_AI_SYSTEM_ASSEMBLYAI)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_AUDIO)
+ span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
+ SemanticConvention.GEN_AI_SYSTEM_ASSEMBLYAI)
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
request_model)
- span.set_attribute(SemanticConvetion.SERVER_ADDRESS,
+ span.set_attribute(SemanticConvention.SERVER_ADDRESS,
server_address)
- span.set_attribute(SemanticConvetion.SERVER_PORT,
+ span.set_attribute(SemanticConvention.SERVER_PORT,
server_port)
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL,
request_model)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
request_model)
- span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
+ span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
'audio')
# Set Span attributes (Extras)
if gen_ai_endpoint == 'elevenlabs.generate':
if isinstance(kwargs.get('voice', 'Rachel'), str):
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_AUDIO_VOICE,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_AUDIO_VOICE,
kwargs.get('voice', 'Rachel'))
else:
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_AUDIO_VOICE,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_AUDIO_VOICE,
kwargs.get('voice_id', ''))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_AUDIO_RESPONSE_FORMAT,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_AUDIO_RESPONSE_FORMAT,
kwargs.get('output_format', 'mp3'))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_AUDIO_SETTINGS,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_AUDIO_SETTINGS,
str(kwargs.get('voice_settings', '')))
span.set_attribute(DEPLOYMENT_ENVIRONMENT,
environment)
span.set_attribute(SERVICE_NAME,
application_name)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST,
cost)
- span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
+ span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION,
version)
if capture_message_content:
span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_PROMPT: str(kwargs.get('text', '')),
+ SemanticConvention.GEN_AI_CONTENT_PROMPT: str(kwargs.get('text', '')),
},
)
@@ -118,8 +118,8 @@ def generate(gen_ai_endpoint, version, environment, application_name,
attributes = create_metrics_attributes(
service_name=application_name,
deployment_environment=environment,
- operation=SemanticConvetion.GEN_AI_OPERATION_TYPE_AUDIO,
- system=SemanticConvetion.GEN_AI_SYSTEM_ELEVENLABS,
+ operation=SemanticConvention.GEN_AI_OPERATION_TYPE_AUDIO,
+ system=SemanticConvention.GEN_AI_SYSTEM_ELEVENLABS,
request_model=request_model,
server_address=server_address,
server_port=server_port,
diff --git a/sdk/python/src/openlit/instrumentation/embedchain/embedchain.py b/sdk/python/src/openlit/instrumentation/embedchain/embedchain.py
index afa1c3e8..5ef511ae 100644
--- a/sdk/python/src/openlit/instrumentation/embedchain/embedchain.py
+++ b/sdk/python/src/openlit/instrumentation/embedchain/embedchain.py
@@ -7,7 +7,7 @@ import logging
from opentelemetry.trace import SpanKind, Status, StatusCode
from opentelemetry.sdk.resources import SERVICE_NAME, TELEMETRY_SDK_NAME, DEPLOYMENT_ENVIRONMENT
from openlit.__helpers import handle_exception
-from openlit.semcov import SemanticConvetion
+from openlit.semcov import SemanticConvention
# Initialize logger for logging potential issues and operations
logger = logging.getLogger(__name__)
@@ -59,21 +59,21 @@ def evaluate(gen_ai_endpoint, version, environment, application_name,
try:
span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
- span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
- SemanticConvetion.GEN_AI_SYSTEM_EMBEDCHAIN)
- span.set_attribute(SemanticConvetion.GEN_AI_ENDPOINT,
+ span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
+ SemanticConvention.GEN_AI_SYSTEM_EMBEDCHAIN)
+ span.set_attribute(SemanticConvention.GEN_AI_ENDPOINT,
gen_ai_endpoint)
span.set_attribute(DEPLOYMENT_ENVIRONMENT,
environment)
- span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
- SemanticConvetion.GEN_AI_OPERATION_TYPE_FRAMEWORK)
+ span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_FRAMEWORK)
span.set_attribute(SERVICE_NAME,
application_name)
- span.set_attribute(SemanticConvetion.GEN_AI_EVAL_CONTEXT_RELEVANCY,
+ span.set_attribute(SemanticConvention.GEN_AI_EVAL_CONTEXT_RELEVANCY,
response["context_relevancy"])
- span.set_attribute(SemanticConvetion.GEN_AI_EVAL_ANSWER_RELEVANCY,
+ span.set_attribute(SemanticConvention.GEN_AI_EVAL_ANSWER_RELEVANCY,
response["answer_relevancy"])
- span.set_attribute(SemanticConvetion.GEN_AI_EVAL_GROUNDEDNESS,
+ span.set_attribute(SemanticConvention.GEN_AI_EVAL_GROUNDEDNESS,
response["groundedness"])
span.set_status(Status(StatusCode.OK))
@@ -137,17 +137,17 @@ def get_data_sources(gen_ai_endpoint, version, environment, application_name,
try:
span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
- span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
- SemanticConvetion.GEN_AI_SYSTEM_EMBEDCHAIN)
- span.set_attribute(SemanticConvetion.GEN_AI_ENDPOINT,
+ span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
+ SemanticConvention.GEN_AI_SYSTEM_EMBEDCHAIN)
+ span.set_attribute(SemanticConvention.GEN_AI_ENDPOINT,
gen_ai_endpoint)
span.set_attribute(DEPLOYMENT_ENVIRONMENT,
environment)
- span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
- SemanticConvetion.GEN_AI_OPERATION_TYPE_FRAMEWORK)
+ span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_FRAMEWORK)
span.set_attribute(SERVICE_NAME,
application_name)
- span.set_attribute(SemanticConvetion.GEN_AI_DATA_SOURCES,
+ span.set_attribute(SemanticConvention.GEN_AI_DATA_SOURCES,
len(response))
span.set_status(Status(StatusCode.OK))
diff --git a/sdk/python/src/openlit/instrumentation/firecrawl/firecrawl.py b/sdk/python/src/openlit/instrumentation/firecrawl/firecrawl.py
index 957ce856..538c63ce 100644
--- a/sdk/python/src/openlit/instrumentation/firecrawl/firecrawl.py
+++ b/sdk/python/src/openlit/instrumentation/firecrawl/firecrawl.py
@@ -9,7 +9,7 @@ from opentelemetry.sdk.resources import SERVICE_NAME, TELEMETRY_SDK_NAME, DEPLOY
from openlit.__helpers import (
handle_exception,
)
-from openlit.semcov import SemanticConvetion
+from openlit.semcov import SemanticConvention
# Initialize logger for logging potential issues and operations
logger = logging.getLogger(__name__)
@@ -56,24 +56,24 @@ def wrap_crawl(gen_ai_endpoint, version, environment, application_name,
try:
# Set base span attribues
span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
- span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
- SemanticConvetion.GEN_AI_SYSTEM_FIRECRAWL)
- span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
- SemanticConvetion.GEN_AI_OPERATION_TYPE_AGENT)
- span.set_attribute(SemanticConvetion.GEN_AI_ENDPOINT,
+ span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
+ SemanticConvention.GEN_AI_SYSTEM_FIRECRAWL)
+ span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_AGENT)
+ span.set_attribute(SemanticConvention.GEN_AI_ENDPOINT,
gen_ai_endpoint)
span.set_attribute(SERVICE_NAME,
application_name)
span.set_attribute(DEPLOYMENT_ENVIRONMENT,
environment)
- span.set_attribute(SemanticConvetion.GEN_AI_AGENT_TYPE,
- SemanticConvetion.GEN_AI_AGENT_TYPE_BROWSER)
- span.set_attribute(SemanticConvetion.GEN_AI_AGENT_PARAMS,
+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_TYPE,
+ SemanticConvention.GEN_AI_AGENT_TYPE_BROWSER)
+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_PARAMS,
str(kwargs.get("params")))
url = kwargs.get("url") if "url" in kwargs else str(args[0]) if args else None
if url is not None:
- span.set_attribute(SemanticConvetion.GEN_AI_AGENT_BROWSE_URL, url)
+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_BROWSE_URL, url)
span.set_status(Status(StatusCode.OK))
diff --git a/sdk/python/src/openlit/instrumentation/google_ai_studio/async_google_ai_studio.py b/sdk/python/src/openlit/instrumentation/google_ai_studio/async_google_ai_studio.py
index acfe5533..5e543d54 100644
--- a/sdk/python/src/openlit/instrumentation/google_ai_studio/async_google_ai_studio.py
+++ b/sdk/python/src/openlit/instrumentation/google_ai_studio/async_google_ai_studio.py
@@ -13,7 +13,7 @@ from openlit.__helpers import (
create_metrics_attributes,
set_server_address_and_port
)
-from openlit.semcov import SemanticConvetion
+from openlit.semcov import SemanticConvention
# Initialize logger for logging potential issues and operations
logger = logging.getLogger(__name__)
@@ -56,7 +56,7 @@ def async_generate(version, environment, application_name,
server_address, server_port = set_server_address_and_port(instance, "generativelanguage.googleapis.com", 443)
request_model = kwargs.get("model", "gemini-2.0-flash")
- span_name = f"{SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT} {request_model}"
+ span_name = f"{SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT} {request_model}"
with tracer.start_as_current_span(span_name, kind=SpanKind.CLIENT) as span:
start_time = time.time()
@@ -110,26 +110,26 @@ def async_generate(version, environment, application_name,
# Set base span attribues (OTel Semconv)
span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
- span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
- SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT)
- span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
- SemanticConvetion.GEN_AI_SYSTEM_GEMINI)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT)
+ span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
+ SemanticConvention.GEN_AI_SYSTEM_GEMINI)
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
request_model)
- span.set_attribute(SemanticConvetion.SERVER_PORT,
+ span.set_attribute(SemanticConvention.SERVER_PORT,
server_port)
inference_config = kwargs.get('config', {})
# List of attributes and their config keys
attributes = [
- (SemanticConvetion.GEN_AI_REQUEST_FREQUENCY_PENALTY, 'frequency_penalty'),
- (SemanticConvetion.GEN_AI_REQUEST_MAX_TOKENS, 'max_tokens'),
- (SemanticConvetion.GEN_AI_REQUEST_PRESENCE_PENALTY, 'presence_penalty'),
- (SemanticConvetion.GEN_AI_REQUEST_STOP_SEQUENCES, 'stop_sequences'),
- (SemanticConvetion.GEN_AI_REQUEST_TEMPERATURE, 'temperature'),
- (SemanticConvetion.GEN_AI_REQUEST_TOP_P, 'top_p'),
- (SemanticConvetion.GEN_AI_REQUEST_TOP_K, 'top_k'),
+ (SemanticConvention.GEN_AI_REQUEST_FREQUENCY_PENALTY, 'frequency_penalty'),
+ (SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS, 'max_tokens'),
+ (SemanticConvention.GEN_AI_REQUEST_PRESENCE_PENALTY, 'presence_penalty'),
+ (SemanticConvention.GEN_AI_REQUEST_STOP_SEQUENCES, 'stop_sequences'),
+ (SemanticConvention.GEN_AI_REQUEST_TEMPERATURE, 'temperature'),
+ (SemanticConvention.GEN_AI_REQUEST_TOP_P, 'top_p'),
+ (SemanticConvention.GEN_AI_REQUEST_TOP_K, 'top_k'),
]
# Set each attribute if the corresponding value exists and is not None
@@ -139,15 +139,15 @@ def async_generate(version, environment, application_name,
if value is not None:
span.set_attribute(attribute, value)
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL,
response_dict.get('model_version'))
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_INPUT_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS,
input_tokens)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_OUTPUT_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS,
output_tokens)
- span.set_attribute(SemanticConvetion.SERVER_ADDRESS,
+ span.set_attribute(SemanticConvention.SERVER_ADDRESS,
server_address)
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_FINISH_REASON,
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON,
[str(response_dict.get('candidates')[0].get('finish_reason'))])
# Set base span attribues (Extras)
@@ -155,35 +155,35 @@ def async_generate(version, environment, application_name,
environment)
span.set_attribute(SERVICE_NAME,
application_name)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IS_STREAM,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM,
False)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_TOTAL_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS,
input_tokens + output_tokens)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST,
cost)
- span.set_attribute(SemanticConvetion.GEN_AI_SERVER_TTFT,
+ span.set_attribute(SemanticConvention.GEN_AI_SERVER_TTFT,
end_time - start_time)
- span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
+ span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION,
version)
if capture_message_content:
span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_PROMPT: prompt,
+ SemanticConvention.GEN_AI_CONTENT_PROMPT: prompt,
},
)
span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_COMPLETION_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_COMPLETION_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_COMPLETION: response.text,
+ SemanticConvention.GEN_AI_CONTENT_COMPLETION: response.text,
},
)
if isinstance(response_dict.get('text'), str):
- span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
+ span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
"text")
elif response_dict.get('text') is not None:
- span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
+ span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
"json")
span.set_status(Status(StatusCode.OK))
@@ -192,8 +192,8 @@ def async_generate(version, environment, application_name,
attributes = create_metrics_attributes(
service_name=application_name,
deployment_environment=environment,
- operation=SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT,
- system=SemanticConvetion.GEN_AI_SYSTEM_GEMINI,
+ operation=SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
+ system=SemanticConvention.GEN_AI_SYSTEM_GEMINI,
request_model=request_model,
server_address=server_address,
server_port=server_port,
diff --git a/sdk/python/src/openlit/instrumentation/google_ai_studio/google_ai_studio.py b/sdk/python/src/openlit/instrumentation/google_ai_studio/google_ai_studio.py
index b12974e8..0afbde41 100644
--- a/sdk/python/src/openlit/instrumentation/google_ai_studio/google_ai_studio.py
+++ b/sdk/python/src/openlit/instrumentation/google_ai_studio/google_ai_studio.py
@@ -13,7 +13,7 @@ from openlit.__helpers import (
create_metrics_attributes,
set_server_address_and_port
)
-from openlit.semcov import SemanticConvetion
+from openlit.semcov import SemanticConvention
# Initialize logger for logging potential issues and operations
logger = logging.getLogger(__name__)
@@ -56,7 +56,7 @@ def generate(version, environment, application_name,
server_address, server_port = set_server_address_and_port(instance, "generativelanguage.googleapis.com", 443)
request_model = kwargs.get("model", "gemini-2.0-flash")
- span_name = f"{SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT} {request_model}"
+ span_name = f"{SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT} {request_model}"
with tracer.start_as_current_span(span_name, kind=SpanKind.CLIENT) as span:
start_time = time.time()
@@ -110,26 +110,26 @@ def generate(version, environment, application_name,
# Set base span attribues (OTel Semconv)
span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
- span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
- SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT)
- span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
- SemanticConvetion.GEN_AI_SYSTEM_GEMINI)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT)
+ span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
+ SemanticConvention.GEN_AI_SYSTEM_GEMINI)
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
request_model)
- span.set_attribute(SemanticConvetion.SERVER_PORT,
+ span.set_attribute(SemanticConvention.SERVER_PORT,
server_port)
inference_config = kwargs.get('config', {})
# List of attributes and their config keys
attributes = [
- (SemanticConvetion.GEN_AI_REQUEST_FREQUENCY_PENALTY, 'frequency_penalty'),
- (SemanticConvetion.GEN_AI_REQUEST_MAX_TOKENS, 'max_tokens'),
- (SemanticConvetion.GEN_AI_REQUEST_PRESENCE_PENALTY, 'presence_penalty'),
- (SemanticConvetion.GEN_AI_REQUEST_STOP_SEQUENCES, 'stop_sequences'),
- (SemanticConvetion.GEN_AI_REQUEST_TEMPERATURE, 'temperature'),
- (SemanticConvetion.GEN_AI_REQUEST_TOP_P, 'top_p'),
- (SemanticConvetion.GEN_AI_REQUEST_TOP_K, 'top_k'),
+ (SemanticConvention.GEN_AI_REQUEST_FREQUENCY_PENALTY, 'frequency_penalty'),
+ (SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS, 'max_tokens'),
+ (SemanticConvention.GEN_AI_REQUEST_PRESENCE_PENALTY, 'presence_penalty'),
+ (SemanticConvention.GEN_AI_REQUEST_STOP_SEQUENCES, 'stop_sequences'),
+ (SemanticConvention.GEN_AI_REQUEST_TEMPERATURE, 'temperature'),
+ (SemanticConvention.GEN_AI_REQUEST_TOP_P, 'top_p'),
+ (SemanticConvention.GEN_AI_REQUEST_TOP_K, 'top_k'),
]
# Set each attribute if the corresponding value exists and is not None
@@ -139,15 +139,15 @@ def generate(version, environment, application_name,
if value is not None:
span.set_attribute(attribute, value)
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL,
response_dict.get('model_version'))
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_INPUT_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS,
input_tokens)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_OUTPUT_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS,
output_tokens)
- span.set_attribute(SemanticConvetion.SERVER_ADDRESS,
+ span.set_attribute(SemanticConvention.SERVER_ADDRESS,
server_address)
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_FINISH_REASON,
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON,
[str(response_dict.get('candidates')[0].get('finish_reason'))])
# Set base span attribues (Extras)
@@ -155,35 +155,35 @@ def generate(version, environment, application_name,
environment)
span.set_attribute(SERVICE_NAME,
application_name)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IS_STREAM,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM,
False)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_TOTAL_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS,
input_tokens + output_tokens)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST,
cost)
- span.set_attribute(SemanticConvetion.GEN_AI_SERVER_TTFT,
+ span.set_attribute(SemanticConvention.GEN_AI_SERVER_TTFT,
end_time - start_time)
- span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
+ span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION,
version)
if capture_message_content:
span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_PROMPT: prompt,
+ SemanticConvention.GEN_AI_CONTENT_PROMPT: prompt,
},
)
span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_COMPLETION_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_COMPLETION_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_COMPLETION: response.text,
+ SemanticConvention.GEN_AI_CONTENT_COMPLETION: response.text,
},
)
if isinstance(response_dict.get('text'), str):
- span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
+ span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
"text")
elif response_dict.get('text') is not None:
- span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
+ span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
"json")
span.set_status(Status(StatusCode.OK))
@@ -192,8 +192,8 @@ def generate(version, environment, application_name,
attributes = create_metrics_attributes(
service_name=application_name,
deployment_environment=environment,
- operation=SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT,
- system=SemanticConvetion.GEN_AI_SYSTEM_GEMINI,
+ operation=SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
+ system=SemanticConvention.GEN_AI_SYSTEM_GEMINI,
request_model=request_model,
server_address=server_address,
server_port=server_port,
diff --git a/sdk/python/src/openlit/instrumentation/gpt4all/gpt4all.py b/sdk/python/src/openlit/instrumentation/gpt4all/gpt4all.py
index 824aea6f..31a0c874 100644
--- a/sdk/python/src/openlit/instrumentation/gpt4all/gpt4all.py
+++ b/sdk/python/src/openlit/instrumentation/gpt4all/gpt4all.py
@@ -14,7 +14,7 @@ from openlit.__helpers import (
calculate_tbt,
calculate_ttft
)
-from openlit.semcov import SemanticConvetion
+from openlit.semcov import SemanticConvention
# Initialize logger for logging potential issues and operations
logger = logging.getLogger(__name__)
@@ -116,39 +116,39 @@ def generate(version, environment, application_name,
# Set Span attributes (OTel Semconv)
self._span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
- self._span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
- SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT)
- self._span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
- SemanticConvetion.GEN_AI_SYSTEM_GPT4ALL)
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
+ self._span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT)
+ self._span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
+ SemanticConvention.GEN_AI_SYSTEM_GPT4ALL)
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
self._request_model)
- self._span.set_attribute(SemanticConvetion.SERVER_PORT,
+ self._span.set_attribute(SemanticConvention.SERVER_PORT,
self._server_port)
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_FREQUENCY_PENALTY,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_FREQUENCY_PENALTY,
self._kwargs.get("repeat_penalty", 1.18))
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MAX_TOKENS,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS,
self._kwargs.get("max_tokens", 200))
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_PRESENCE_PENALTY,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_PRESENCE_PENALTY,
self._kwargs.get("presence_penalty", 0.0))
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TEMPERATURE,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TEMPERATURE,
self._kwargs.get("temp", 0.7))
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TOP_P,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TOP_P,
self._kwargs.get("top_p", 0.4))
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TOP_K,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TOP_K,
self._kwargs.get("top_k", 40))
- self._span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_MODEL,
+ self._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL,
self._request_model)
- self._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_INPUT_TOKENS,
+ self._span.set_attribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS,
input_tokens)
- self._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_OUTPUT_TOKENS,
+ self._span.set_attribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS,
output_tokens)
- self._span.set_attribute(SemanticConvetion.SERVER_ADDRESS,
+ self._span.set_attribute(SemanticConvention.SERVER_ADDRESS,
self._server_address)
if isinstance(self._llmresponse, str):
- self._span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
+ self._span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
"text")
else:
- self._span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
+ self._span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
"json")
# Set Span attributes (Extra)
@@ -156,29 +156,29 @@ def generate(version, environment, application_name,
environment)
self._span.set_attribute(SERVICE_NAME,
application_name)
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IS_STREAM,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM,
True)
- self._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_TOTAL_TOKENS,
+ self._span.set_attribute(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS,
input_tokens + output_tokens)
- self._span.set_attribute(SemanticConvetion.GEN_AI_SERVER_TBT,
+ self._span.set_attribute(SemanticConvention.GEN_AI_SERVER_TBT,
self._tbt)
- self._span.set_attribute(SemanticConvetion.GEN_AI_SERVER_TTFT,
+ self._span.set_attribute(SemanticConvention.GEN_AI_SERVER_TTFT,
self._ttft)
- self._span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
+ self._span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION,
version)
- self._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
+ self._span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST,
0)
if capture_message_content:
self._span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_PROMPT: prompt,
+ SemanticConvention.GEN_AI_CONTENT_PROMPT: prompt,
},
)
self._span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_COMPLETION_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_COMPLETION_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_COMPLETION: self._llmresponse,
+ SemanticConvention.GEN_AI_CONTENT_COMPLETION: self._llmresponse,
},
)
@@ -188,8 +188,8 @@ def generate(version, environment, application_name,
attributes = create_metrics_attributes(
service_name=application_name,
deployment_environment=environment,
- operation=SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT,
- system=SemanticConvetion.GEN_AI_SYSTEM_GPT4ALL,
+ operation=SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
+ system=SemanticConvention.GEN_AI_SYSTEM_GPT4ALL,
request_model=self._request_model,
server_address=self._server_address,
server_port=self._server_port,
@@ -243,7 +243,7 @@ def generate(version, environment, application_name,
server_address, server_port = set_server_address_and_port(instance, "localhost", 80)
request_model = str(instance.model.model_path).rsplit('/', maxsplit=1)[-1] or "orca-mini-3b-gguf2-q4_0.gguf"
- span_name = f"{SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT} {request_model}"
+ span_name = f"{SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT} {request_model}"
# pylint: disable=no-else-return
if streaming:
@@ -269,39 +269,39 @@ def generate(version, environment, application_name,
# Set Span attributes (OTel Semconv)
span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
- span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
- SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT)
- span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
- SemanticConvetion.GEN_AI_SYSTEM_GPT4ALL)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT)
+ span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
+ SemanticConvention.GEN_AI_SYSTEM_GPT4ALL)
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
request_model)
- span.set_attribute(SemanticConvetion.SERVER_PORT,
+ span.set_attribute(SemanticConvention.SERVER_PORT,
server_port)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_FREQUENCY_PENALTY,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_FREQUENCY_PENALTY,
kwargs.get("repeat_penalty", 1.18))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MAX_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS,
kwargs.get("max_tokens", 200))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_PRESENCE_PENALTY,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_PRESENCE_PENALTY,
kwargs.get("presence_penalty", 0.0))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TEMPERATURE,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TEMPERATURE,
kwargs.get("temp", 0.7))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TOP_P,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TOP_P,
kwargs.get("top_p", 0.4))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TOP_K,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TOP_K,
kwargs.get("top_k", 40))
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL,
request_model)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_INPUT_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS,
input_tokens)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_OUTPUT_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS,
output_tokens)
- span.set_attribute(SemanticConvetion.SERVER_ADDRESS,
+ span.set_attribute(SemanticConvention.SERVER_ADDRESS,
server_address)
if isinstance(response, str):
- span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
+ span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
"text")
else:
- span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
+ span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
"json")
# Set Span attributes (Extra)
@@ -309,27 +309,27 @@ def generate(version, environment, application_name,
environment)
span.set_attribute(SERVICE_NAME,
application_name)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IS_STREAM,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM,
False)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_TOTAL_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS,
input_tokens + output_tokens)
- span.set_attribute(SemanticConvetion.GEN_AI_SERVER_TTFT,
+ span.set_attribute(SemanticConvention.GEN_AI_SERVER_TTFT,
end_time - start_time)
- span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
+ span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION,
version)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST,
0)
if capture_message_content:
span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_PROMPT: prompt,
+ SemanticConvention.GEN_AI_CONTENT_PROMPT: prompt,
},
)
span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_COMPLETION_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_COMPLETION_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_COMPLETION: response,
+ SemanticConvention.GEN_AI_CONTENT_COMPLETION: response,
},
)
@@ -339,8 +339,8 @@ def generate(version, environment, application_name,
attributes = create_metrics_attributes(
service_name=application_name,
deployment_environment=environment,
- operation=SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT,
- system=SemanticConvetion.GEN_AI_SYSTEM_GPT4ALL,
+ operation=SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
+ system=SemanticConvention.GEN_AI_SYSTEM_GPT4ALL,
request_model=request_model,
server_address=server_address,
server_port=server_port,
@@ -412,7 +412,7 @@ def embed(version, environment, application_name,
# pylint: disable=line-too-long
request_model = str(instance.gpt4all.model.model_path).rsplit('/', maxsplit=1)[-1] or "all-MiniLM-L6-v2.gguf2.f16.gguf"
- span_name = f"{SemanticConvetion.GEN_AI_OPERATION_TYPE_EMBEDDING} {request_model}"
+ span_name = f"{SemanticConvention.GEN_AI_OPERATION_TYPE_EMBEDDING} {request_model}"
with tracer.start_as_current_span(span_name, kind= SpanKind.CLIENT) as span:
start_time = time.time()
@@ -425,19 +425,19 @@ def embed(version, environment, application_name,
# Set Span attributes (OTel Semconv)
span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
- span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
- SemanticConvetion.GEN_AI_OPERATION_TYPE_EMBEDDING)
- span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
- SemanticConvetion.GEN_AI_SYSTEM_GPT4ALL)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_EMBEDDING)
+ span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
+ SemanticConvention.GEN_AI_SYSTEM_GPT4ALL)
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
request_model)
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL,
request_model)
- span.set_attribute(SemanticConvetion.SERVER_ADDRESS,
+ span.set_attribute(SemanticConvention.SERVER_ADDRESS,
server_address)
- span.set_attribute(SemanticConvetion.SERVER_PORT,
+ span.set_attribute(SemanticConvention.SERVER_PORT,
server_port)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_INPUT_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS,
input_tokens)
# Set Span attributes (Extras)
@@ -445,18 +445,18 @@ def embed(version, environment, application_name,
environment)
span.set_attribute(SERVICE_NAME,
application_name)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_TOTAL_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS,
input_tokens)
- span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
+ span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION,
version)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST,
0)
if capture_message_content:
span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_PROMPT: str(kwargs.get("input", "")),
+ SemanticConvention.GEN_AI_CONTENT_PROMPT: str(kwargs.get("input", "")),
},
)
@@ -466,8 +466,8 @@ def embed(version, environment, application_name,
attributes = create_metrics_attributes(
service_name=application_name,
deployment_environment=environment,
- operation=SemanticConvetion.GEN_AI_OPERATION_TYPE_EMBEDDING,
- system=SemanticConvetion.GEN_AI_SYSTEM_GPT4ALL,
+ operation=SemanticConvention.GEN_AI_OPERATION_TYPE_EMBEDDING,
+ system=SemanticConvention.GEN_AI_SYSTEM_GPT4ALL,
request_model=request_model,
server_address=server_address,
server_port=server_port,
diff --git a/sdk/python/src/openlit/instrumentation/gpu/__init__.py b/sdk/python/src/openlit/instrumentation/gpu/__init__.py
index a7fdaffb..c511ecb4 100644
--- a/sdk/python/src/openlit/instrumentation/gpu/__init__.py
+++ b/sdk/python/src/openlit/instrumentation/gpu/__init__.py
@@ -7,7 +7,7 @@ from functools import partial
from opentelemetry.instrumentation.instrumentor import BaseInstrumentor
from opentelemetry.sdk.resources import SERVICE_NAME, TELEMETRY_SDK_NAME, DEPLOYMENT_ENVIRONMENT
from opentelemetry.metrics import get_meter, CallbackOptions, Observation
-from openlit.semcov import SemanticConvetion
+from openlit.semcov import SemanticConvention
# Initialize logger for logging potential issues and operations
logger = logging.getLogger(__name__)
@@ -54,7 +54,7 @@ class GPUInstrumentor(BaseInstrumentor):
for semantic_name, internal_name in metric_names:
meter.create_observable_gauge(
- name=getattr(SemanticConvetion, semantic_name),
+ name=getattr(SemanticConvention, semantic_name),
callbacks=[partial(self._collect_metric,
environment, application_name, internal_name)],
description=f"GPU {internal_name.replace('_', ' ').title()}",
@@ -141,9 +141,9 @@ class GPUInstrumentor(BaseInstrumentor):
TELEMETRY_SDK_NAME: "openlit",
SERVICE_NAME: application_name,
DEPLOYMENT_ENVIRONMENT: environment,
- SemanticConvetion.GPU_INDEX: str(gpu_index),
- SemanticConvetion.GPU_UUID: safe_decode(pynvml.nvmlDeviceGetUUID(handle)),
- SemanticConvetion.GPU_NAME: safe_decode(pynvml.nvmlDeviceGetName(handle))
+ SemanticConvention.GPU_INDEX: str(gpu_index),
+ SemanticConvention.GPU_UUID: safe_decode(pynvml.nvmlDeviceGetUUID(handle)),
+ SemanticConvention.GPU_NAME: safe_decode(pynvml.nvmlDeviceGetName(handle))
}
yield Observation(get_metric_value(handle, metric_name), attributes)
@@ -202,10 +202,10 @@ class GPUInstrumentor(BaseInstrumentor):
SERVICE_NAME: application_name,
DEPLOYMENT_ENVIRONMENT: environment,
# pylint: disable=line-too-long
- SemanticConvetion.GPU_INDEX: amdsmi.amdsmi_get_xgmi_info(device_handle)['index'],
+ SemanticConvention.GPU_INDEX: amdsmi.amdsmi_get_xgmi_info(device_handle)['index'],
# pylint: disable=line-too-long
- SemanticConvetion.GPU_UUID: amdsmi.amdsmi_get_gpu_asic_info(device_handle)['market_name'],
- SemanticConvetion.GPU_NAME: amdsmi.amdsmi_get_device_name(device_handle)
+ SemanticConvention.GPU_UUID: amdsmi.amdsmi_get_gpu_asic_info(device_handle)['market_name'],
+ SemanticConvention.GPU_NAME: amdsmi.amdsmi_get_device_name(device_handle)
}
yield Observation(get_metric_value(device_handle, metric_name), attributes)
diff --git a/sdk/python/src/openlit/instrumentation/groq/async_groq.py b/sdk/python/src/openlit/instrumentation/groq/async_groq.py
index fe2bff90..397dcebd 100644
--- a/sdk/python/src/openlit/instrumentation/groq/async_groq.py
+++ b/sdk/python/src/openlit/instrumentation/groq/async_groq.py
@@ -15,7 +15,7 @@ from openlit.__helpers import (
create_metrics_attributes,
set_server_address_and_port
)
-from openlit.semcov import SemanticConvetion
+from openlit.semcov import SemanticConvention
# Initialize logger for logging potential issues and operations
logger = logging.getLogger(__name__)
@@ -157,49 +157,49 @@ def async_chat(version, environment, application_name,
# Set Span attributes (OTel Semconv)
self._span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
- self._span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
- SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT)
- self._span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
- SemanticConvetion.GEN_AI_SYSTEM_GROQ)
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
+ self._span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT)
+ self._span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
+ SemanticConvention.GEN_AI_SYSTEM_GROQ)
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
request_model)
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_SEED,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_SEED,
self._kwargs.get("seed", ""))
- self._span.set_attribute(SemanticConvetion.SERVER_PORT,
+ self._span.set_attribute(SemanticConvention.SERVER_PORT,
self._server_port)
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_FREQUENCY_PENALTY,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_FREQUENCY_PENALTY,
self._kwargs.get("frequency_penalty", 0.0))
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MAX_TOKENS,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS,
self._kwargs.get("max_completion_tokens", -1))
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_PRESENCE_PENALTY,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_PRESENCE_PENALTY,
self._kwargs.get("presence_penalty", 0.0))
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_STOP_SEQUENCES,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_STOP_SEQUENCES,
self._kwargs.get("stop", []))
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TEMPERATURE,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TEMPERATURE,
self._kwargs.get("temperature", 1.0))
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TOP_P,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TOP_P,
self._kwargs.get("top_p", 1.0))
- self._span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_FINISH_REASON,
+ self._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON,
[self._finish_reason])
- self._span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_ID,
+ self._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_ID,
self._response_id)
- self._span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_MODEL,
+ self._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL,
self._response_model)
- self._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_INPUT_TOKENS,
+ self._span.set_attribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS,
self._input_tokens)
- self._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_OUTPUT_TOKENS,
+ self._span.set_attribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS,
self._output_tokens)
- self._span.set_attribute(SemanticConvetion.SERVER_ADDRESS,
+ self._span.set_attribute(SemanticConvention.SERVER_ADDRESS,
self._server_address)
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_SERVICE_TIER,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_SERVICE_TIER,
self._kwargs.get("service_tier", "on_demand"))
- self._span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_SYSTEM_FINGERPRINT,
+ self._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_SYSTEM_FINGERPRINT,
self._system_fingerprint)
if isinstance(self._llmresponse, str):
- self._span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
+ self._span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
"text")
else:
- self._span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
+ self._span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
"json")
# Set Span attributes (Extra)
@@ -207,31 +207,31 @@ def async_chat(version, environment, application_name,
environment)
self._span.set_attribute(SERVICE_NAME,
application_name)
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_USER,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_USER,
self._kwargs.get("user", ""))
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IS_STREAM,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM,
True)
- self._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_TOTAL_TOKENS,
+ self._span.set_attribute(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS,
self._input_tokens + self._output_tokens)
- self._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
+ self._span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST,
cost)
- self._span.set_attribute(SemanticConvetion.GEN_AI_SERVER_TBT,
+ self._span.set_attribute(SemanticConvention.GEN_AI_SERVER_TBT,
self._tbt)
- self._span.set_attribute(SemanticConvetion.GEN_AI_SERVER_TTFT,
+ self._span.set_attribute(SemanticConvention.GEN_AI_SERVER_TTFT,
self._ttft)
- self._span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
+ self._span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION,
version)
if capture_message_content:
self._span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_PROMPT: prompt,
+ SemanticConvention.GEN_AI_CONTENT_PROMPT: prompt,
},
)
self._span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_COMPLETION_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_COMPLETION_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_COMPLETION: self._llmresponse,
+ SemanticConvention.GEN_AI_CONTENT_COMPLETION: self._llmresponse,
},
)
self._span.set_status(Status(StatusCode.OK))
@@ -240,8 +240,8 @@ def async_chat(version, environment, application_name,
attributes = create_metrics_attributes(
service_name=application_name,
deployment_environment=environment,
- operation=SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT,
- system=SemanticConvetion.GEN_AI_SYSTEM_GROQ,
+ operation=SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
+ system=SemanticConvention.GEN_AI_SYSTEM_GROQ,
request_model=request_model,
server_address=self._server_address,
server_port=self._server_port,
@@ -294,7 +294,7 @@ def async_chat(version, environment, application_name,
server_address, server_port = set_server_address_and_port(instance, "api.groq.com", 443)
request_model = kwargs.get("model", "gpt-4o")
- span_name = f"{SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT} {request_model}"
+ span_name = f"{SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT} {request_model}"
# pylint: disable=no-else-return
if streaming:
@@ -342,41 +342,41 @@ def async_chat(version, environment, application_name,
# Set base span attribues (OTel Semconv)
span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
- span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
- SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT)
- span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
- SemanticConvetion.GEN_AI_SYSTEM_GROQ)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT)
+ span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
+ SemanticConvention.GEN_AI_SYSTEM_GROQ)
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
request_model)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_SEED,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_SEED,
kwargs.get("seed", ""))
- span.set_attribute(SemanticConvetion.SERVER_PORT,
+ span.set_attribute(SemanticConvention.SERVER_PORT,
server_port)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_FREQUENCY_PENALTY,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_FREQUENCY_PENALTY,
kwargs.get("frequency_penalty", 0.0))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MAX_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS,
kwargs.get("max_completion_tokens", -1))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_PRESENCE_PENALTY,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_PRESENCE_PENALTY,
kwargs.get("presence_penalty", 0.0))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_STOP_SEQUENCES,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_STOP_SEQUENCES,
kwargs.get("stop", []))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TEMPERATURE,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TEMPERATURE,
kwargs.get("temperature", 1.0))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TOP_P,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TOP_P,
kwargs.get("top_p", 1.0))
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_ID,
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_ID,
response_dict.get("id"))
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL,
response_dict.get('model'))
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_INPUT_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS,
input_tokens)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_OUTPUT_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS,
output_tokens)
- span.set_attribute(SemanticConvetion.SERVER_ADDRESS,
+ span.set_attribute(SemanticConvention.SERVER_ADDRESS,
server_address)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_SERVICE_TIER,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_SERVICE_TIER,
kwargs.get("service_tier", "on_demand"))
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_SYSTEM_FINGERPRINT,
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_SYSTEM_FINGERPRINT,
response_dict.get('system_fingerprint'))
# Set base span attribues (Extras)
@@ -384,46 +384,46 @@ def async_chat(version, environment, application_name,
environment)
span.set_attribute(SERVICE_NAME,
application_name)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_USER,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_USER,
kwargs.get("user", ""))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IS_STREAM,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM,
False)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_TOTAL_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS,
input_tokens + output_tokens)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST,
cost)
- span.set_attribute(SemanticConvetion.GEN_AI_SERVER_TTFT,
+ span.set_attribute(SemanticConvention.GEN_AI_SERVER_TTFT,
end_time - start_time)
- span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
+ span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION,
version)
if capture_message_content:
span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_PROMPT: prompt,
+ SemanticConvention.GEN_AI_CONTENT_PROMPT: prompt,
},
)
for i in range(kwargs.get('n',1)):
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_FINISH_REASON,
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON,
[response_dict.get('choices')[i].get('finish_reason')])
if capture_message_content:
span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_COMPLETION_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_COMPLETION_EVENT,
attributes={
# pylint: disable=line-too-long
- SemanticConvetion.GEN_AI_CONTENT_COMPLETION: str(response_dict.get('choices')[i].get('message').get('content')),
+ SemanticConvention.GEN_AI_CONTENT_COMPLETION: str(response_dict.get('choices')[i].get('message').get('content')),
},
)
if kwargs.get('tools'):
- span.set_attribute(SemanticConvetion.GEN_AI_TOOL_CALLS,
+ span.set_attribute(SemanticConvention.GEN_AI_TOOL_CALLS,
str(response_dict.get('choices')[i].get('message').get('tool_calls')))
if isinstance(response_dict.get('choices')[i].get('message').get('content'), str):
- span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
+ span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
"text")
elif response_dict.get('choices')[i].get('message').get('content') is not None:
- span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
+ span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
"json")
span.set_status(Status(StatusCode.OK))
@@ -432,8 +432,8 @@ def async_chat(version, environment, application_name,
attributes = create_metrics_attributes(
service_name=application_name,
deployment_environment=environment,
- operation=SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT,
- system=SemanticConvetion.GEN_AI_SYSTEM_GROQ,
+ operation=SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
+ system=SemanticConvention.GEN_AI_SYSTEM_GROQ,
request_model=request_model,
server_address=server_address,
server_port=server_port,
diff --git a/sdk/python/src/openlit/instrumentation/groq/groq.py b/sdk/python/src/openlit/instrumentation/groq/groq.py
index 88f59834..85d23483 100644
--- a/sdk/python/src/openlit/instrumentation/groq/groq.py
+++ b/sdk/python/src/openlit/instrumentation/groq/groq.py
@@ -15,7 +15,7 @@ from openlit.__helpers import (
create_metrics_attributes,
set_server_address_and_port
)
-from openlit.semcov import SemanticConvetion
+from openlit.semcov import SemanticConvention
# Initialize logger for logging potential issues and operations
logger = logging.getLogger(__name__)
@@ -157,49 +157,49 @@ def chat(version, environment, application_name,
# Set Span attributes (OTel Semconv)
self._span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
- self._span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
- SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT)
- self._span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
- SemanticConvetion.GEN_AI_SYSTEM_GROQ)
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
+ self._span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT)
+ self._span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
+ SemanticConvention.GEN_AI_SYSTEM_GROQ)
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
request_model)
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_SEED,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_SEED,
self._kwargs.get("seed", ""))
- self._span.set_attribute(SemanticConvetion.SERVER_PORT,
+ self._span.set_attribute(SemanticConvention.SERVER_PORT,
self._server_port)
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_FREQUENCY_PENALTY,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_FREQUENCY_PENALTY,
self._kwargs.get("frequency_penalty", 0.0))
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MAX_TOKENS,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS,
self._kwargs.get("max_completion_tokens", -1))
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_PRESENCE_PENALTY,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_PRESENCE_PENALTY,
self._kwargs.get("presence_penalty", 0.0))
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_STOP_SEQUENCES,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_STOP_SEQUENCES,
self._kwargs.get("stop", []))
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TEMPERATURE,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TEMPERATURE,
self._kwargs.get("temperature", 1.0))
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TOP_P,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TOP_P,
self._kwargs.get("top_p", 1.0))
- self._span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_FINISH_REASON,
+ self._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON,
[self._finish_reason])
- self._span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_ID,
+ self._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_ID,
self._response_id)
- self._span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_MODEL,
+ self._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL,
self._response_model)
- self._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_INPUT_TOKENS,
+ self._span.set_attribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS,
self._input_tokens)
- self._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_OUTPUT_TOKENS,
+ self._span.set_attribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS,
self._output_tokens)
- self._span.set_attribute(SemanticConvetion.SERVER_ADDRESS,
+ self._span.set_attribute(SemanticConvention.SERVER_ADDRESS,
self._server_address)
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_SERVICE_TIER,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_SERVICE_TIER,
self._kwargs.get("service_tier", "on_demand"))
- self._span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_SYSTEM_FINGERPRINT,
+ self._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_SYSTEM_FINGERPRINT,
self._system_fingerprint)
if isinstance(self._llmresponse, str):
- self._span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
+ self._span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
"text")
else:
- self._span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
+ self._span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
"json")
# Set Span attributes (Extra)
@@ -207,31 +207,31 @@ def chat(version, environment, application_name,
environment)
self._span.set_attribute(SERVICE_NAME,
application_name)
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_USER,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_USER,
self._kwargs.get("user", ""))
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IS_STREAM,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM,
True)
- self._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_TOTAL_TOKENS,
+ self._span.set_attribute(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS,
self._input_tokens + self._output_tokens)
- self._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
+ self._span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST,
cost)
- self._span.set_attribute(SemanticConvetion.GEN_AI_SERVER_TBT,
+ self._span.set_attribute(SemanticConvention.GEN_AI_SERVER_TBT,
self._tbt)
- self._span.set_attribute(SemanticConvetion.GEN_AI_SERVER_TTFT,
+ self._span.set_attribute(SemanticConvention.GEN_AI_SERVER_TTFT,
self._ttft)
- self._span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
+ self._span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION,
version)
if capture_message_content:
self._span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_PROMPT: prompt,
+ SemanticConvention.GEN_AI_CONTENT_PROMPT: prompt,
},
)
self._span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_COMPLETION_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_COMPLETION_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_COMPLETION: self._llmresponse,
+ SemanticConvention.GEN_AI_CONTENT_COMPLETION: self._llmresponse,
},
)
self._span.set_status(Status(StatusCode.OK))
@@ -240,8 +240,8 @@ def chat(version, environment, application_name,
attributes = create_metrics_attributes(
service_name=application_name,
deployment_environment=environment,
- operation=SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT,
- system=SemanticConvetion.GEN_AI_SYSTEM_GROQ,
+ operation=SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
+ system=SemanticConvention.GEN_AI_SYSTEM_GROQ,
request_model=request_model,
server_address=self._server_address,
server_port=self._server_port,
@@ -294,7 +294,7 @@ def chat(version, environment, application_name,
server_address, server_port = set_server_address_and_port(instance, "api.groq.com", 443)
request_model = kwargs.get("model", "gpt-4o")
- span_name = f"{SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT} {request_model}"
+ span_name = f"{SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT} {request_model}"
# pylint: disable=no-else-return
if streaming:
@@ -342,41 +342,41 @@ def chat(version, environment, application_name,
# Set base span attribues (OTel Semconv)
span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
- span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
- SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT)
- span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
- SemanticConvetion.GEN_AI_SYSTEM_GROQ)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT)
+ span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
+ SemanticConvention.GEN_AI_SYSTEM_GROQ)
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
request_model)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_SEED,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_SEED,
kwargs.get("seed", ""))
- span.set_attribute(SemanticConvetion.SERVER_PORT,
+ span.set_attribute(SemanticConvention.SERVER_PORT,
server_port)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_FREQUENCY_PENALTY,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_FREQUENCY_PENALTY,
kwargs.get("frequency_penalty", 0.0))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MAX_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS,
kwargs.get("max_completion_tokens", -1))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_PRESENCE_PENALTY,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_PRESENCE_PENALTY,
kwargs.get("presence_penalty", 0.0))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_STOP_SEQUENCES,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_STOP_SEQUENCES,
kwargs.get("stop", []))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TEMPERATURE,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TEMPERATURE,
kwargs.get("temperature", 1.0))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TOP_P,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TOP_P,
kwargs.get("top_p", 1.0))
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_ID,
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_ID,
response_dict.get("id"))
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL,
response_dict.get('model'))
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_INPUT_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS,
input_tokens)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_OUTPUT_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS,
output_tokens)
- span.set_attribute(SemanticConvetion.SERVER_ADDRESS,
+ span.set_attribute(SemanticConvention.SERVER_ADDRESS,
server_address)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_SERVICE_TIER,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_SERVICE_TIER,
kwargs.get("service_tier", "on_demand"))
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_SYSTEM_FINGERPRINT,
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_SYSTEM_FINGERPRINT,
response_dict.get('system_fingerprint'))
# Set base span attribues (Extras)
@@ -384,46 +384,46 @@ def chat(version, environment, application_name,
environment)
span.set_attribute(SERVICE_NAME,
application_name)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_USER,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_USER,
kwargs.get("user", ""))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IS_STREAM,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM,
False)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_TOTAL_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS,
input_tokens + output_tokens)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST,
cost)
- span.set_attribute(SemanticConvetion.GEN_AI_SERVER_TTFT,
+ span.set_attribute(SemanticConvention.GEN_AI_SERVER_TTFT,
end_time - start_time)
- span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
+ span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION,
version)
if capture_message_content:
span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_PROMPT: prompt,
+ SemanticConvention.GEN_AI_CONTENT_PROMPT: prompt,
},
)
for i in range(kwargs.get('n',1)):
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_FINISH_REASON,
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON,
[response_dict.get('choices')[i].get('finish_reason')])
if capture_message_content:
span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_COMPLETION_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_COMPLETION_EVENT,
attributes={
# pylint: disable=line-too-long
- SemanticConvetion.GEN_AI_CONTENT_COMPLETION: str(response_dict.get('choices')[i].get('message').get('content')),
+ SemanticConvention.GEN_AI_CONTENT_COMPLETION: str(response_dict.get('choices')[i].get('message').get('content')),
},
)
if kwargs.get('tools'):
- span.set_attribute(SemanticConvetion.GEN_AI_TOOL_CALLS,
+ span.set_attribute(SemanticConvention.GEN_AI_TOOL_CALLS,
str(response_dict.get('choices')[i].get('message').get('tool_calls')))
if isinstance(response_dict.get('choices')[i].get('message').get('content'), str):
- span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
+ span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
"text")
elif response_dict.get('choices')[i].get('message').get('content') is not None:
- span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
+ span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
"json")
span.set_status(Status(StatusCode.OK))
@@ -432,8 +432,8 @@ def chat(version, environment, application_name,
attributes = create_metrics_attributes(
service_name=application_name,
deployment_environment=environment,
- operation=SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT,
- system=SemanticConvetion.GEN_AI_SYSTEM_GROQ,
+ operation=SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
+ system=SemanticConvention.GEN_AI_SYSTEM_GROQ,
request_model=request_model,
server_address=server_address,
server_port=server_port,
diff --git a/sdk/python/src/openlit/instrumentation/haystack/haystack.py b/sdk/python/src/openlit/instrumentation/haystack/haystack.py
index 6748e656..b06ec9f2 100644
--- a/sdk/python/src/openlit/instrumentation/haystack/haystack.py
+++ b/sdk/python/src/openlit/instrumentation/haystack/haystack.py
@@ -7,7 +7,7 @@ import logging
from opentelemetry.trace import SpanKind, Status, StatusCode
from opentelemetry.sdk.resources import SERVICE_NAME, TELEMETRY_SDK_NAME, DEPLOYMENT_ENVIRONMENT
from openlit.__helpers import handle_exception
-from openlit.semcov import SemanticConvetion
+from openlit.semcov import SemanticConvention
# Initialize logger for logging potential issues and operations
logger = logging.getLogger(__name__)
@@ -59,14 +59,14 @@ def join_data(gen_ai_endpoint, version, environment, application_name,
try:
span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
- span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
- SemanticConvetion.GEN_AI_SYSTEM_HAYSTACK)
- span.set_attribute(SemanticConvetion.GEN_AI_ENDPOINT,
+ span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
+ SemanticConvention.GEN_AI_SYSTEM_HAYSTACK)
+ span.set_attribute(SemanticConvention.GEN_AI_ENDPOINT,
gen_ai_endpoint)
span.set_attribute(DEPLOYMENT_ENVIRONMENT,
environment)
- span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
- SemanticConvetion.GEN_AI_OPERATION_TYPE_FRAMEWORK)
+ span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_FRAMEWORK)
span.set_attribute(SERVICE_NAME,
application_name)
span.set_status(Status(StatusCode.OK))
diff --git a/sdk/python/src/openlit/instrumentation/julep/async_julep.py b/sdk/python/src/openlit/instrumentation/julep/async_julep.py
index 29b1e1eb..fe08901c 100644
--- a/sdk/python/src/openlit/instrumentation/julep/async_julep.py
+++ b/sdk/python/src/openlit/instrumentation/julep/async_julep.py
@@ -7,7 +7,7 @@ import logging
from opentelemetry.trace import SpanKind, Status, StatusCode
from opentelemetry.sdk.resources import SERVICE_NAME, TELEMETRY_SDK_NAME, DEPLOYMENT_ENVIRONMENT
from openlit.__helpers import handle_exception
-from openlit.semcov import SemanticConvetion
+from openlit.semcov import SemanticConvention
# Initialize logger for logging potential issues and operations
logger = logging.getLogger(__name__)
@@ -60,39 +60,39 @@ def async_wrap_julep(gen_ai_endpoint, version, environment, application_name,
try:
span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
- span.set_attribute(SemanticConvetion.GEN_AI_ENDPOINT,
+ span.set_attribute(SemanticConvention.GEN_AI_ENDPOINT,
gen_ai_endpoint)
- span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
- SemanticConvetion.GEN_AI_SYSTEM_JULEP)
+ span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
+ SemanticConvention.GEN_AI_SYSTEM_JULEP)
span.set_attribute(DEPLOYMENT_ENVIRONMENT,
environment)
span.set_attribute(SERVICE_NAME,
application_name)
- span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
- SemanticConvetion.GEN_AI_OPERATION_TYPE_AGENT)
+ span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_AGENT)
if gen_ai_endpoint == "julep.agents_create":
- span.set_attribute(SemanticConvetion.GEN_AI_AGENT_ID,
+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_ID,
response.id)
- span.set_attribute(SemanticConvetion.GEN_AI_AGENT_ROLE,
+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_ROLE,
kwargs.get("name", ""))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
kwargs.get("model", "gpt-4-turbo"))
- span.set_attribute(SemanticConvetion.GEN_AI_AGENT_CONTEXT,
+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_CONTEXT,
kwargs.get("about", ""))
elif gen_ai_endpoint == "julep.task_create":
- span.set_attribute(SemanticConvetion.GEN_AI_AGENT_TOOLS,
+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_TOOLS,
str(kwargs.get("tools", "")))
elif gen_ai_endpoint == "julep.execution_create":
- span.set_attribute(SemanticConvetion.GEN_AI_AGENT_TASK_ID,
+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_TASK_ID,
kwargs.get("task_id", ""))
if capture_message_content:
span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_PROMPT:str(kwargs.get("input", "")),
+ SemanticConvention.GEN_AI_CONTENT_PROMPT:str(kwargs.get("input", "")),
},
)
diff --git a/sdk/python/src/openlit/instrumentation/julep/julep.py b/sdk/python/src/openlit/instrumentation/julep/julep.py
index fae7f2de..0c5e2f33 100644
--- a/sdk/python/src/openlit/instrumentation/julep/julep.py
+++ b/sdk/python/src/openlit/instrumentation/julep/julep.py
@@ -7,7 +7,7 @@ import logging
from opentelemetry.trace import SpanKind, Status, StatusCode
from opentelemetry.sdk.resources import SERVICE_NAME, TELEMETRY_SDK_NAME, DEPLOYMENT_ENVIRONMENT
from openlit.__helpers import handle_exception
-from openlit.semcov import SemanticConvetion
+from openlit.semcov import SemanticConvention
# Initialize logger for logging potential issues and operations
logger = logging.getLogger(__name__)
@@ -60,39 +60,39 @@ def wrap_julep(gen_ai_endpoint, version, environment, application_name,
try:
span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
- span.set_attribute(SemanticConvetion.GEN_AI_ENDPOINT,
+ span.set_attribute(SemanticConvention.GEN_AI_ENDPOINT,
gen_ai_endpoint)
- span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
- SemanticConvetion.GEN_AI_SYSTEM_JULEP)
+ span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
+ SemanticConvention.GEN_AI_SYSTEM_JULEP)
span.set_attribute(DEPLOYMENT_ENVIRONMENT,
environment)
span.set_attribute(SERVICE_NAME,
application_name)
- span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
- SemanticConvetion.GEN_AI_OPERATION_TYPE_AGENT)
+ span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_AGENT)
if gen_ai_endpoint == "julep.agents_create":
- span.set_attribute(SemanticConvetion.GEN_AI_AGENT_ID,
+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_ID,
response.id)
- span.set_attribute(SemanticConvetion.GEN_AI_AGENT_ROLE,
+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_ROLE,
kwargs.get("name", ""))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
kwargs.get("model", "gpt-4-turbo"))
- span.set_attribute(SemanticConvetion.GEN_AI_AGENT_CONTEXT,
+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_CONTEXT,
kwargs.get("about", ""))
elif gen_ai_endpoint == "julep.task_create":
- span.set_attribute(SemanticConvetion.GEN_AI_AGENT_TOOLS,
+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_TOOLS,
str(kwargs.get("tools", "")))
elif gen_ai_endpoint == "julep.execution_create":
- span.set_attribute(SemanticConvetion.GEN_AI_AGENT_TASK_ID,
+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_TASK_ID,
kwargs.get("task_id", ""))
if capture_message_content:
span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_PROMPT:str(kwargs.get("input", "")),
+ SemanticConvention.GEN_AI_CONTENT_PROMPT:str(kwargs.get("input", "")),
},
)
diff --git a/sdk/python/src/openlit/instrumentation/langchain/async_langchain.py b/sdk/python/src/openlit/instrumentation/langchain/async_langchain.py
index b40a09ce..1803d510 100644
--- a/sdk/python/src/openlit/instrumentation/langchain/async_langchain.py
+++ b/sdk/python/src/openlit/instrumentation/langchain/async_langchain.py
@@ -15,7 +15,7 @@ from openlit.__helpers import (
calculate_tbt,
create_metrics_attributes,
)
-from openlit.semcov import SemanticConvetion
+from openlit.semcov import SemanticConvention
# Initialize logger for logging potential issues and operations
logger = logging.getLogger(__name__)
@@ -87,17 +87,17 @@ def async_general_wrap(gen_ai_endpoint, version, environment, application_name,
try:
span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
- span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
- SemanticConvetion.GEN_AI_SYSTEM_LANGCHAIN)
- span.set_attribute(SemanticConvetion.GEN_AI_ENDPOINT,
+ span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
+ SemanticConvention.GEN_AI_SYSTEM_LANGCHAIN)
+ span.set_attribute(SemanticConvention.GEN_AI_ENDPOINT,
gen_ai_endpoint)
span.set_attribute(DEPLOYMENT_ENVIRONMENT,
environment)
- span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
- SemanticConvetion.GEN_AI_OPERATION_TYPE_FRAMEWORK)
+ span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_FRAMEWORK)
span.set_attribute(SERVICE_NAME,
application_name)
- span.set_attribute(SemanticConvetion.GEN_AI_RETRIEVAL_SOURCE,
+ span.set_attribute(SemanticConvention.GEN_AI_RETRIEVAL_SOURCE,
response[0].metadata["source"])
span.set_status(Status(StatusCode.OK))
@@ -161,19 +161,19 @@ def async_hub(gen_ai_endpoint, version, environment, application_name, tracer,
try:
span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
- span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
- SemanticConvetion.GEN_AI_SYSTEM_LANGCHAIN)
- span.set_attribute(SemanticConvetion.GEN_AI_ENDPOINT,
+ span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
+ SemanticConvention.GEN_AI_SYSTEM_LANGCHAIN)
+ span.set_attribute(SemanticConvention.GEN_AI_ENDPOINT,
gen_ai_endpoint)
span.set_attribute(DEPLOYMENT_ENVIRONMENT,
environment)
- span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
- SemanticConvetion.GEN_AI_OPERATION_TYPE_FRAMEWORK)
+ span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_FRAMEWORK)
span.set_attribute(SERVICE_NAME,
application_name)
- span.set_attribute(SemanticConvetion.GEN_AI_HUB_OWNER,
+ span.set_attribute(SemanticConvention.GEN_AI_HUB_OWNER,
response.metadata["lc_hub_owner"])
- span.set_attribute(SemanticConvetion.GEN_AI_HUB_REPO,
+ span.set_attribute(SemanticConvention.GEN_AI_HUB_REPO,
response.metadata["lc_hub_repo"])
span.set_status(Status(StatusCode.OK))
@@ -241,7 +241,7 @@ def async_chat(gen_ai_endpoint, version, environment, application_name,
else:
request_model = "NOT_FOUND"
- span_name = f"{SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT} {request_model}"
+ span_name = f"{SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT} {request_model}"
with tracer.start_as_current_span(span_name, kind=SpanKind.CLIENT) as span:
start_time = time.time()
@@ -294,27 +294,27 @@ def async_chat(gen_ai_endpoint, version, environment, application_name,
# Set base span attribues (OTel Semconv)
span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
- span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
- SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT)
- span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
- SemanticConvetion.GEN_AI_SYSTEM_LANGCHAIN)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT)
+ span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
+ SemanticConvention.GEN_AI_SYSTEM_LANGCHAIN)
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
request_model)
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL,
request_model)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TEMPERATURE,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TEMPERATURE,
str(getattr(instance, 'temperature', 1)))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TOP_K,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TOP_K,
str(getattr(instance, 'top_k', 1)))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TOP_P,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TOP_P,
str(getattr(instance, 'top_p', 1)))
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_INPUT_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS,
input_tokens)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_OUTPUT_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS,
output_tokens)
- span.set_attribute(SemanticConvetion.SERVER_ADDRESS,
+ span.set_attribute(SemanticConvention.SERVER_ADDRESS,
server_address)
- span.set_attribute(SemanticConvetion.SERVER_PORT,
+ span.set_attribute(SemanticConvention.SERVER_PORT,
server_port)
# Set base span attribues (Extras)
@@ -322,28 +322,28 @@ def async_chat(gen_ai_endpoint, version, environment, application_name,
environment)
span.set_attribute(SERVICE_NAME,
application_name)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IS_STREAM,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM,
False)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_TOTAL_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS,
input_tokens + output_tokens)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST,
cost)
- span.set_attribute(SemanticConvetion.GEN_AI_SERVER_TTFT,
+ span.set_attribute(SemanticConvention.GEN_AI_SERVER_TTFT,
end_time - start_time)
- span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
+ span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION,
version)
if capture_message_content:
span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_PROMPT: prompt,
+ SemanticConvention.GEN_AI_CONTENT_PROMPT: prompt,
},
)
span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_COMPLETION_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_COMPLETION_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_COMPLETION: llm_response,
+ SemanticConvention.GEN_AI_CONTENT_COMPLETION: llm_response,
},
)
@@ -353,8 +353,8 @@ def async_chat(gen_ai_endpoint, version, environment, application_name,
attributes = create_metrics_attributes(
service_name=application_name,
deployment_environment=environment,
- operation=SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT,
- system=SemanticConvetion.GEN_AI_SYSTEM_LANGCHAIN,
+ operation=SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
+ system=SemanticConvention.GEN_AI_SYSTEM_LANGCHAIN,
request_model=request_model,
server_address=server_address,
server_port=server_port,
diff --git a/sdk/python/src/openlit/instrumentation/langchain/langchain.py b/sdk/python/src/openlit/instrumentation/langchain/langchain.py
index 65fc94d3..a1333f32 100644
--- a/sdk/python/src/openlit/instrumentation/langchain/langchain.py
+++ b/sdk/python/src/openlit/instrumentation/langchain/langchain.py
@@ -16,7 +16,7 @@ from openlit.__helpers import (
create_metrics_attributes,
extract_and_format_input,
)
-from openlit.semcov import SemanticConvetion
+from openlit.semcov import SemanticConvention
# Initialize logger for logging potential issues and operations
logger = logging.getLogger(__name__)
@@ -88,17 +88,17 @@ def general_wrap(gen_ai_endpoint, version, environment, application_name,
try:
span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
- span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
- SemanticConvetion.GEN_AI_SYSTEM_LANGCHAIN)
- span.set_attribute(SemanticConvetion.GEN_AI_ENDPOINT,
+ span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
+ SemanticConvention.GEN_AI_SYSTEM_LANGCHAIN)
+ span.set_attribute(SemanticConvention.GEN_AI_ENDPOINT,
gen_ai_endpoint)
span.set_attribute(DEPLOYMENT_ENVIRONMENT,
environment)
- span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
- SemanticConvetion.GEN_AI_OPERATION_TYPE_FRAMEWORK)
+ span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_FRAMEWORK)
span.set_attribute(SERVICE_NAME,
application_name)
- span.set_attribute(SemanticConvetion.GEN_AI_RETRIEVAL_SOURCE,
+ span.set_attribute(SemanticConvention.GEN_AI_RETRIEVAL_SOURCE,
response[0].metadata["source"])
span.set_status(Status(StatusCode.OK))
@@ -162,19 +162,19 @@ def hub(gen_ai_endpoint, version, environment, application_name, tracer,
try:
span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
- span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
- SemanticConvetion.GEN_AI_SYSTEM_LANGCHAIN)
- span.set_attribute(SemanticConvetion.GEN_AI_ENDPOINT,
+ span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
+ SemanticConvention.GEN_AI_SYSTEM_LANGCHAIN)
+ span.set_attribute(SemanticConvention.GEN_AI_ENDPOINT,
gen_ai_endpoint)
span.set_attribute(DEPLOYMENT_ENVIRONMENT,
environment)
- span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
- SemanticConvetion.GEN_AI_OPERATION_TYPE_FRAMEWORK)
+ span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_FRAMEWORK)
span.set_attribute(SERVICE_NAME,
application_name)
- span.set_attribute(SemanticConvetion.GEN_AI_HUB_OWNER,
+ span.set_attribute(SemanticConvention.GEN_AI_HUB_OWNER,
response.metadata["lc_hub_owner"])
- span.set_attribute(SemanticConvetion.GEN_AI_HUB_REPO,
+ span.set_attribute(SemanticConvention.GEN_AI_HUB_REPO,
response.metadata["lc_hub_repo"])
span.set_status(Status(StatusCode.OK))
@@ -242,7 +242,7 @@ def chat(gen_ai_endpoint, version, environment, application_name,
else:
request_model = "NOT_FOUND"
- span_name = f"{SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT} {request_model}"
+ span_name = f"{SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT} {request_model}"
with tracer.start_as_current_span(span_name, kind=SpanKind.CLIENT) as span:
start_time = time.time()
@@ -268,27 +268,27 @@ def chat(gen_ai_endpoint, version, environment, application_name,
# Set base span attribues (OTel Semconv)
span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
- span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
- SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT)
- span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
- SemanticConvetion.GEN_AI_SYSTEM_LANGCHAIN)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT)
+ span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
+ SemanticConvention.GEN_AI_SYSTEM_LANGCHAIN)
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
request_model)
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL,
request_model)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TEMPERATURE,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TEMPERATURE,
str(getattr(instance, 'temperature', 1)))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TOP_K,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TOP_K,
str(getattr(instance, 'top_k', 1)))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TOP_P,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TOP_P,
str(getattr(instance, 'top_p', 1)))
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_INPUT_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS,
input_tokens)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_OUTPUT_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS,
output_tokens)
- span.set_attribute(SemanticConvetion.SERVER_ADDRESS,
+ span.set_attribute(SemanticConvention.SERVER_ADDRESS,
server_address)
- span.set_attribute(SemanticConvetion.SERVER_PORT,
+ span.set_attribute(SemanticConvention.SERVER_PORT,
server_port)
# Set base span attribues (Extras)
@@ -296,28 +296,28 @@ def chat(gen_ai_endpoint, version, environment, application_name,
environment)
span.set_attribute(SERVICE_NAME,
application_name)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IS_STREAM,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM,
False)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_TOTAL_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS,
input_tokens + output_tokens)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST,
cost)
- span.set_attribute(SemanticConvetion.GEN_AI_SERVER_TTFT,
+ span.set_attribute(SemanticConvention.GEN_AI_SERVER_TTFT,
end_time - start_time)
- span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
+ span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION,
version)
if capture_message_content:
span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_PROMPT: prompt,
+ SemanticConvention.GEN_AI_CONTENT_PROMPT: prompt,
},
)
span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_COMPLETION_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_COMPLETION_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_COMPLETION: llm_response,
+ SemanticConvention.GEN_AI_CONTENT_COMPLETION: llm_response,
},
)
@@ -327,8 +327,8 @@ def chat(gen_ai_endpoint, version, environment, application_name,
attributes = create_metrics_attributes(
service_name=application_name,
deployment_environment=environment,
- operation=SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT,
- system=SemanticConvetion.GEN_AI_SYSTEM_LANGCHAIN,
+ operation=SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
+ system=SemanticConvention.GEN_AI_SYSTEM_LANGCHAIN,
request_model=request_model,
server_address=server_address,
server_port=server_port,
diff --git a/sdk/python/src/openlit/instrumentation/letta/letta.py b/sdk/python/src/openlit/instrumentation/letta/letta.py
index d60830aa..508c88db 100644
--- a/sdk/python/src/openlit/instrumentation/letta/letta.py
+++ b/sdk/python/src/openlit/instrumentation/letta/letta.py
@@ -9,7 +9,7 @@ from opentelemetry.sdk.resources import SERVICE_NAME, TELEMETRY_SDK_NAME, DEPLOY
from openlit.__helpers import (
handle_exception, get_chat_model_cost
)
-from openlit.semcov import SemanticConvetion
+from openlit.semcov import SemanticConvention
# Initialize logger for logging potential issues and operations
logger = logging.getLogger(__name__)
@@ -56,27 +56,27 @@ def create_agent(gen_ai_endpoint, version, environment, application_name,
try:
# Set base span attribues
span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
- span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
- SemanticConvetion.GEN_AI_SYSTEM_LETTA)
- span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
- SemanticConvetion.GEN_AI_OPERATION_TYPE_AGENT)
- span.set_attribute(SemanticConvetion.GEN_AI_ENDPOINT,
+ span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
+ SemanticConvention.GEN_AI_SYSTEM_LETTA)
+ span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_AGENT)
+ span.set_attribute(SemanticConvention.GEN_AI_ENDPOINT,
gen_ai_endpoint)
span.set_attribute(SERVICE_NAME,
application_name)
span.set_attribute(DEPLOYMENT_ENVIRONMENT,
environment)
- span.set_attribute(SemanticConvetion.GEN_AI_AGENT_ID,
+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_ID,
response.id)
- span.set_attribute(SemanticConvetion.GEN_AI_AGENT_ROLE,
+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_ROLE,
response.name)
- span.set_attribute(SemanticConvetion.GEN_AI_AGENT_INSTRUCTIONS,
+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_INSTRUCTIONS,
response.system)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
response.llm_config.model)
- span.set_attribute(SemanticConvetion.GEN_AI_AGENT_TYPE,
+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_TYPE,
response.agent_type)
- span.set_attribute(SemanticConvetion.GEN_AI_AGENT_TOOLS,
+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_TOOLS,
response.tool_names)
span.set_status(Status(StatusCode.OK))
@@ -139,37 +139,37 @@ def send_message(gen_ai_endpoint, version, environment, application_name,
response.usage.completion_tokens)
# Set base span attribues
span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
- span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
- SemanticConvetion.GEN_AI_SYSTEM_LETTA)
- span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
- SemanticConvetion.GEN_AI_OPERATION_TYPE_AGENT)
- span.set_attribute(SemanticConvetion.GEN_AI_ENDPOINT,
+ span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
+ SemanticConvention.GEN_AI_SYSTEM_LETTA)
+ span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_AGENT)
+ span.set_attribute(SemanticConvention.GEN_AI_ENDPOINT,
gen_ai_endpoint)
span.set_attribute(SERVICE_NAME,
application_name)
- span.set_attribute(SemanticConvetion.GEN_AI_AGENT_STEP_COUNT,
+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_STEP_COUNT,
response.usage.step_count)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_INPUT_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS,
response.usage.prompt_tokens)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_OUTPUT_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS,
response.usage.completion_tokens)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_TOTAL_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS,
response.usage.total_tokens)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST,
cost)
if capture_message_content:
span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_PROMPT: kwargs.get("message", ""),
+ SemanticConvention.GEN_AI_CONTENT_PROMPT: kwargs.get("message", ""),
},
)
span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_COMPLETION_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_COMPLETION_EVENT,
# pylint: disable=line-too-long
attributes={
- SemanticConvetion.GEN_AI_CONTENT_COMPLETION: str(response.messages),
+ SemanticConvention.GEN_AI_CONTENT_COMPLETION: str(response.messages),
},
)
diff --git a/sdk/python/src/openlit/instrumentation/litellm/async_litellm.py b/sdk/python/src/openlit/instrumentation/litellm/async_litellm.py
index 47328ee47..ddd758f3 100644
--- a/sdk/python/src/openlit/instrumentation/litellm/async_litellm.py
+++ b/sdk/python/src/openlit/instrumentation/litellm/async_litellm.py
@@ -16,7 +16,7 @@ from openlit.__helpers import (
calculate_tbt,
create_metrics_attributes,
)
-from openlit.semcov import SemanticConvetion
+from openlit.semcov import SemanticConvention
# Initialize logger for logging potential issues and operations
logger = logging.getLogger(__name__)
@@ -151,51 +151,51 @@ def acompletion(version, environment, application_name,
# Set Span attributes (OTel Semconv)
self._span.set_attribute(TELEMETRY_SDK_NAME, 'openlit')
- self._span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
- SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT)
- self._span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
- SemanticConvetion.GEN_AI_SYSTEM_LITELLM)
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
+ self._span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT)
+ self._span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
+ SemanticConvention.GEN_AI_SYSTEM_LITELLM)
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
request_model)
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_SEED,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_SEED,
self._kwargs.get('seed', ''))
- self._span.set_attribute(SemanticConvetion.SERVER_PORT,
+ self._span.set_attribute(SemanticConvention.SERVER_PORT,
self._server_port)
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_FREQUENCY_PENALTY,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_FREQUENCY_PENALTY,
self._kwargs.get('frequency_penalty', 0.0))
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MAX_TOKENS,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS,
self._kwargs.get('max_tokens', -1))
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_PRESENCE_PENALTY,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_PRESENCE_PENALTY,
self._kwargs.get('presence_penalty', 0.0))
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_STOP_SEQUENCES,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_STOP_SEQUENCES,
self._kwargs.get('stop', []))
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TEMPERATURE,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TEMPERATURE,
self._kwargs.get('temperature', 1.0))
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TOP_P,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TOP_P,
self._kwargs.get('top_p', 1.0))
- self._span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_FINISH_REASON,
+ self._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON,
[self._finish_reason])
- self._span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_ID,
+ self._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_ID,
self._response_id)
- self._span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_MODEL,
+ self._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL,
self._response_model)
- self._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_INPUT_TOKENS,
+ self._span.set_attribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS,
input_tokens)
- self._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_OUTPUT_TOKENS,
+ self._span.set_attribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS,
output_tokens)
- self._span.set_attribute(SemanticConvetion.SERVER_ADDRESS,
+ self._span.set_attribute(SemanticConvention.SERVER_ADDRESS,
self._server_address)
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_SERVICE_TIER,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_SERVICE_TIER,
self._kwargs.get('service_tier', 'auto'))
- self._span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_SERVICE_TIER,
+ self._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_SERVICE_TIER,
self._response_service_tier)
- self._span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_SYSTEM_FINGERPRINT,
+ self._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_SYSTEM_FINGERPRINT,
self._response_service_tier)
if isinstance(self._llmresponse, str):
- self._span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
+ self._span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
'text')
else:
- self._span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
+ self._span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
'json')
# Set Span attributes (Extra)
@@ -203,31 +203,31 @@ def acompletion(version, environment, application_name,
environment)
self._span.set_attribute(SERVICE_NAME,
application_name)
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_USER,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_USER,
self._kwargs.get('user', ''))
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IS_STREAM,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM,
True)
- self._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_TOTAL_TOKENS,
+ self._span.set_attribute(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS,
input_tokens + output_tokens)
- self._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
+ self._span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST,
cost)
- self._span.set_attribute(SemanticConvetion.GEN_AI_SERVER_TBT,
+ self._span.set_attribute(SemanticConvention.GEN_AI_SERVER_TBT,
self._tbt)
- self._span.set_attribute(SemanticConvetion.GEN_AI_SERVER_TTFT,
+ self._span.set_attribute(SemanticConvention.GEN_AI_SERVER_TTFT,
self._ttft)
- self._span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
+ self._span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION,
version)
if capture_message_content:
self._span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_PROMPT: prompt,
+ SemanticConvention.GEN_AI_CONTENT_PROMPT: prompt,
},
)
self._span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_COMPLETION_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_COMPLETION_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_COMPLETION: self._llmresponse,
+ SemanticConvention.GEN_AI_CONTENT_COMPLETION: self._llmresponse,
},
)
self._span.set_status(Status(StatusCode.OK))
@@ -236,8 +236,8 @@ def acompletion(version, environment, application_name,
attributes = create_metrics_attributes(
service_name=application_name,
deployment_environment=environment,
- operation=SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT,
- system=SemanticConvetion.GEN_AI_SYSTEM_LITELLM,
+ operation=SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
+ system=SemanticConvention.GEN_AI_SYSTEM_LITELLM,
request_model=request_model,
server_address=self._server_address,
server_port=self._server_port,
@@ -290,7 +290,7 @@ def acompletion(version, environment, application_name,
server_address, server_port = 'NOT_FOUND', 'NOT_FOUND'
request_model = kwargs.get('model', 'openai/gpt-4o')
- span_name = f'{SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT} {request_model}'
+ span_name = f'{SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT} {request_model}'
# pylint: disable=no-else-return
if streaming:
@@ -339,41 +339,41 @@ def acompletion(version, environment, application_name,
# Set base span attribues (OTel Semconv)
span.set_attribute(TELEMETRY_SDK_NAME, 'openlit')
- span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
- SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT)
- span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
- SemanticConvetion.GEN_AI_SYSTEM_LITELLM)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT)
+ span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
+ SemanticConvention.GEN_AI_SYSTEM_LITELLM)
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
request_model)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_SEED,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_SEED,
kwargs.get('seed', ''))
- span.set_attribute(SemanticConvetion.SERVER_PORT,
+ span.set_attribute(SemanticConvention.SERVER_PORT,
server_port)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_FREQUENCY_PENALTY,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_FREQUENCY_PENALTY,
kwargs.get('frequency_penalty', 0.0))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MAX_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS,
kwargs.get('max_tokens', -1))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_PRESENCE_PENALTY,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_PRESENCE_PENALTY,
kwargs.get('presence_penalty', 0.0))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_STOP_SEQUENCES,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_STOP_SEQUENCES,
kwargs.get('stop', []))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TEMPERATURE,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TEMPERATURE,
kwargs.get('temperature', 1.0))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TOP_P,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TOP_P,
kwargs.get('top_p', 1.0))
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_ID,
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_ID,
response_dict.get('id'))
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL,
response_dict.get('model'))
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_INPUT_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS,
input_tokens)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_OUTPUT_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS,
output_tokens)
- span.set_attribute(SemanticConvetion.SERVER_ADDRESS,
+ span.set_attribute(SemanticConvention.SERVER_ADDRESS,
server_address)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_SERVICE_TIER,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_SERVICE_TIER,
kwargs.get('service_tier', 'auto'))
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_SYSTEM_FINGERPRINT,
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_SYSTEM_FINGERPRINT,
str(response_dict.get('system_fingerprint')))
# Set base span attribues (Extras)
@@ -381,46 +381,46 @@ def acompletion(version, environment, application_name,
environment)
span.set_attribute(SERVICE_NAME,
application_name)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_USER,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_USER,
kwargs.get('user', ''))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IS_STREAM,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM,
False)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_TOTAL_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS,
input_tokens + output_tokens)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST,
cost)
- span.set_attribute(SemanticConvetion.GEN_AI_SERVER_TTFT,
+ span.set_attribute(SemanticConvention.GEN_AI_SERVER_TTFT,
end_time - start_time)
- span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
+ span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION,
version)
if capture_message_content:
span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_PROMPT: prompt,
+ SemanticConvention.GEN_AI_CONTENT_PROMPT: prompt,
},
)
for i in range(kwargs.get('n',1)):
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_FINISH_REASON,
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON,
[response_dict.get('choices')[i].get('finish_reason')])
if capture_message_content:
span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_COMPLETION_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_COMPLETION_EVENT,
attributes={
# pylint: disable=line-too-long
- SemanticConvetion.GEN_AI_CONTENT_COMPLETION: str(response_dict.get('choices')[i].get('message').get('content')),
+ SemanticConvention.GEN_AI_CONTENT_COMPLETION: str(response_dict.get('choices')[i].get('message').get('content')),
},
)
if kwargs.get('tools'):
- span.set_attribute(SemanticConvetion.GEN_AI_TOOL_CALLS,
+ span.set_attribute(SemanticConvention.GEN_AI_TOOL_CALLS,
str(response_dict.get('choices')[i].get('message').get('tool_calls')))
if isinstance(response_dict.get('choices')[i].get('message').get('content'), str):
- span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
+ span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
'text')
elif response_dict.get('choices')[i].get('message').get('content') is not None:
- span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
+ span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
'json')
span.set_status(Status(StatusCode.OK))
@@ -429,8 +429,8 @@ def acompletion(version, environment, application_name,
attributes = create_metrics_attributes(
service_name=application_name,
deployment_environment=environment,
- operation=SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT,
- system=SemanticConvetion.GEN_AI_SYSTEM_LITELLM,
+ operation=SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
+ system=SemanticConvention.GEN_AI_SYSTEM_LITELLM,
request_model=request_model,
server_address=server_address,
server_port=server_port,
@@ -500,7 +500,7 @@ def aembedding(version, environment, application_name,
server_address, server_port = 'NOT_FOUND', 'NOT_FOUND'
request_model = kwargs.get('model', 'text-embedding-ada-002')
- span_name = f'{SemanticConvetion.GEN_AI_OPERATION_TYPE_EMBEDDING} {request_model}'
+ span_name = f'{SemanticConvention.GEN_AI_OPERATION_TYPE_EMBEDDING} {request_model}'
with tracer.start_as_current_span(span_name, kind= SpanKind.CLIENT) as span:
start_time = time.time()
@@ -517,21 +517,21 @@ def aembedding(version, environment, application_name,
# Set Span attributes (OTel Semconv)
span.set_attribute(TELEMETRY_SDK_NAME, 'openlit')
- span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
- SemanticConvetion.GEN_AI_OPERATION_TYPE_EMBEDDING)
- span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
- SemanticConvetion.GEN_AI_SYSTEM_LITELLM)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_EMBEDDING)
+ span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
+ SemanticConvention.GEN_AI_SYSTEM_LITELLM)
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
request_model)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_ENCODING_FORMATS,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_ENCODING_FORMATS,
[kwargs.get('encoding_format', 'float')])
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL,
response_dict.get('model'))
- span.set_attribute(SemanticConvetion.SERVER_ADDRESS,
+ span.set_attribute(SemanticConvention.SERVER_ADDRESS,
server_address)
- span.set_attribute(SemanticConvetion.SERVER_PORT,
+ span.set_attribute(SemanticConvention.SERVER_PORT,
server_port)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_INPUT_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS,
input_tokens)
# Set Span attributes (Extras)
@@ -539,20 +539,20 @@ def aembedding(version, environment, application_name,
environment)
span.set_attribute(SERVICE_NAME,
application_name)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_USER,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_USER,
kwargs.get('user', ''))
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_TOTAL_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS,
input_tokens)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST,
cost)
- span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
+ span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION,
version)
if capture_message_content:
span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_PROMPT: str(kwargs.get('input', '')),
+ SemanticConvention.GEN_AI_CONTENT_PROMPT: str(kwargs.get('input', '')),
},
)
@@ -562,8 +562,8 @@ def aembedding(version, environment, application_name,
attributes = create_metrics_attributes(
service_name=application_name,
deployment_environment=environment,
- operation=SemanticConvetion.GEN_AI_OPERATION_TYPE_EMBEDDING,
- system=SemanticConvetion.GEN_AI_SYSTEM_LITELLM,
+ operation=SemanticConvention.GEN_AI_OPERATION_TYPE_EMBEDDING,
+ system=SemanticConvention.GEN_AI_SYSTEM_LITELLM,
request_model=request_model,
server_address=server_address,
server_port=server_port,
diff --git a/sdk/python/src/openlit/instrumentation/litellm/litellm.py b/sdk/python/src/openlit/instrumentation/litellm/litellm.py
index 120eeb41..54be0640 100644
--- a/sdk/python/src/openlit/instrumentation/litellm/litellm.py
+++ b/sdk/python/src/openlit/instrumentation/litellm/litellm.py
@@ -16,7 +16,7 @@ from openlit.__helpers import (
calculate_tbt,
create_metrics_attributes,
)
-from openlit.semcov import SemanticConvetion
+from openlit.semcov import SemanticConvention
# Initialize logger for logging potential issues and operations
logger = logging.getLogger(__name__)
@@ -151,51 +151,51 @@ def completion(version, environment, application_name,
# Set Span attributes (OTel Semconv)
self._span.set_attribute(TELEMETRY_SDK_NAME, 'openlit')
- self._span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
- SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT)
- self._span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
- SemanticConvetion.GEN_AI_SYSTEM_LITELLM)
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
+ self._span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT)
+ self._span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
+ SemanticConvention.GEN_AI_SYSTEM_LITELLM)
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
request_model)
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_SEED,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_SEED,
self._kwargs.get('seed', ''))
- self._span.set_attribute(SemanticConvetion.SERVER_PORT,
+ self._span.set_attribute(SemanticConvention.SERVER_PORT,
self._server_port)
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_FREQUENCY_PENALTY,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_FREQUENCY_PENALTY,
self._kwargs.get('frequency_penalty', 0.0))
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MAX_TOKENS,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS,
self._kwargs.get('max_tokens', -1))
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_PRESENCE_PENALTY,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_PRESENCE_PENALTY,
self._kwargs.get('presence_penalty', 0.0))
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_STOP_SEQUENCES,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_STOP_SEQUENCES,
self._kwargs.get('stop', []))
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TEMPERATURE,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TEMPERATURE,
self._kwargs.get('temperature', 1.0))
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TOP_P,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TOP_P,
self._kwargs.get('top_p', 1.0))
- self._span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_FINISH_REASON,
+ self._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON,
[self._finish_reason])
- self._span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_ID,
+ self._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_ID,
self._response_id)
- self._span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_MODEL,
+ self._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL,
self._response_model)
- self._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_INPUT_TOKENS,
+ self._span.set_attribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS,
input_tokens)
- self._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_OUTPUT_TOKENS,
+ self._span.set_attribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS,
output_tokens)
- self._span.set_attribute(SemanticConvetion.SERVER_ADDRESS,
+ self._span.set_attribute(SemanticConvention.SERVER_ADDRESS,
self._server_address)
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_SERVICE_TIER,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_SERVICE_TIER,
self._kwargs.get('service_tier', 'auto'))
- self._span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_SERVICE_TIER,
+ self._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_SERVICE_TIER,
self._response_service_tier)
- self._span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_SYSTEM_FINGERPRINT,
+ self._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_SYSTEM_FINGERPRINT,
self._response_service_tier)
if isinstance(self._llmresponse, str):
- self._span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
+ self._span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
'text')
else:
- self._span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
+ self._span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
'json')
# Set Span attributes (Extra)
@@ -203,31 +203,31 @@ def completion(version, environment, application_name,
environment)
self._span.set_attribute(SERVICE_NAME,
application_name)
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_USER,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_USER,
self._kwargs.get('user', ''))
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IS_STREAM,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM,
True)
- self._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_TOTAL_TOKENS,
+ self._span.set_attribute(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS,
input_tokens + output_tokens)
- self._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
+ self._span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST,
cost)
- self._span.set_attribute(SemanticConvetion.GEN_AI_SERVER_TBT,
+ self._span.set_attribute(SemanticConvention.GEN_AI_SERVER_TBT,
self._tbt)
- self._span.set_attribute(SemanticConvetion.GEN_AI_SERVER_TTFT,
+ self._span.set_attribute(SemanticConvention.GEN_AI_SERVER_TTFT,
self._ttft)
- self._span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
+ self._span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION,
version)
if capture_message_content:
self._span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_PROMPT: prompt,
+ SemanticConvention.GEN_AI_CONTENT_PROMPT: prompt,
},
)
self._span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_COMPLETION_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_COMPLETION_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_COMPLETION: self._llmresponse,
+ SemanticConvention.GEN_AI_CONTENT_COMPLETION: self._llmresponse,
},
)
self._span.set_status(Status(StatusCode.OK))
@@ -236,8 +236,8 @@ def completion(version, environment, application_name,
attributes = create_metrics_attributes(
service_name=application_name,
deployment_environment=environment,
- operation=SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT,
- system=SemanticConvetion.GEN_AI_SYSTEM_LITELLM,
+ operation=SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
+ system=SemanticConvention.GEN_AI_SYSTEM_LITELLM,
request_model=request_model,
server_address=self._server_address,
server_port=self._server_port,
@@ -290,7 +290,7 @@ def completion(version, environment, application_name,
server_address, server_port = 'NOT_FOUND', 'NOT_FOUND'
request_model = kwargs.get('model', 'openai/gpt-4o')
- span_name = f'{SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT} {request_model}'
+ span_name = f'{SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT} {request_model}'
# pylint: disable=no-else-return
if streaming:
@@ -339,41 +339,41 @@ def completion(version, environment, application_name,
# Set base span attribues (OTel Semconv)
span.set_attribute(TELEMETRY_SDK_NAME, 'openlit')
- span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
- SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT)
- span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
- SemanticConvetion.GEN_AI_SYSTEM_LITELLM)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT)
+ span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
+ SemanticConvention.GEN_AI_SYSTEM_LITELLM)
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
request_model)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_SEED,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_SEED,
kwargs.get('seed', ''))
- span.set_attribute(SemanticConvetion.SERVER_PORT,
+ span.set_attribute(SemanticConvention.SERVER_PORT,
server_port)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_FREQUENCY_PENALTY,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_FREQUENCY_PENALTY,
kwargs.get('frequency_penalty', 0.0))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MAX_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS,
kwargs.get('max_tokens', -1))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_PRESENCE_PENALTY,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_PRESENCE_PENALTY,
kwargs.get('presence_penalty', 0.0))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_STOP_SEQUENCES,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_STOP_SEQUENCES,
kwargs.get('stop', []))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TEMPERATURE,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TEMPERATURE,
kwargs.get('temperature', 1.0))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TOP_P,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TOP_P,
kwargs.get('top_p', 1.0))
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_ID,
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_ID,
response_dict.get('id'))
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL,
response_dict.get('model'))
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_INPUT_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS,
input_tokens)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_OUTPUT_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS,
output_tokens)
- span.set_attribute(SemanticConvetion.SERVER_ADDRESS,
+ span.set_attribute(SemanticConvention.SERVER_ADDRESS,
server_address)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_SERVICE_TIER,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_SERVICE_TIER,
kwargs.get('service_tier', 'auto'))
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_SYSTEM_FINGERPRINT,
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_SYSTEM_FINGERPRINT,
str(response_dict.get('system_fingerprint')))
# Set base span attribues (Extras)
@@ -381,46 +381,46 @@ def completion(version, environment, application_name,
environment)
span.set_attribute(SERVICE_NAME,
application_name)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_USER,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_USER,
kwargs.get('user', ''))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IS_STREAM,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM,
False)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_TOTAL_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS,
input_tokens + output_tokens)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST,
cost)
- span.set_attribute(SemanticConvetion.GEN_AI_SERVER_TTFT,
+ span.set_attribute(SemanticConvention.GEN_AI_SERVER_TTFT,
end_time - start_time)
- span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
+ span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION,
version)
if capture_message_content:
span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_PROMPT: prompt,
+ SemanticConvention.GEN_AI_CONTENT_PROMPT: prompt,
},
)
for i in range(kwargs.get('n',1)):
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_FINISH_REASON,
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON,
[response_dict.get('choices')[i].get('finish_reason')])
if capture_message_content:
span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_COMPLETION_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_COMPLETION_EVENT,
attributes={
# pylint: disable=line-too-long
- SemanticConvetion.GEN_AI_CONTENT_COMPLETION: str(response_dict.get('choices')[i].get('message').get('content')),
+ SemanticConvention.GEN_AI_CONTENT_COMPLETION: str(response_dict.get('choices')[i].get('message').get('content')),
},
)
if kwargs.get('tools'):
- span.set_attribute(SemanticConvetion.GEN_AI_TOOL_CALLS,
+ span.set_attribute(SemanticConvention.GEN_AI_TOOL_CALLS,
str(response_dict.get('choices')[i].get('message').get('tool_calls')))
if isinstance(response_dict.get('choices')[i].get('message').get('content'), str):
- span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
+ span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
'text')
elif response_dict.get('choices')[i].get('message').get('content') is not None:
- span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
+ span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
'json')
span.set_status(Status(StatusCode.OK))
@@ -429,8 +429,8 @@ def completion(version, environment, application_name,
attributes = create_metrics_attributes(
service_name=application_name,
deployment_environment=environment,
- operation=SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT,
- system=SemanticConvetion.GEN_AI_SYSTEM_LITELLM,
+ operation=SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
+ system=SemanticConvention.GEN_AI_SYSTEM_LITELLM,
request_model=request_model,
server_address=server_address,
server_port=server_port,
@@ -500,7 +500,7 @@ def embedding(version, environment, application_name,
server_address, server_port = 'NOT_FOUND', 'NOT_FOUND'
request_model = kwargs.get('model', 'text-embedding-ada-002')
- span_name = f'{SemanticConvetion.GEN_AI_OPERATION_TYPE_EMBEDDING} {request_model}'
+ span_name = f'{SemanticConvention.GEN_AI_OPERATION_TYPE_EMBEDDING} {request_model}'
with tracer.start_as_current_span(span_name, kind= SpanKind.CLIENT) as span:
start_time = time.time()
@@ -517,21 +517,21 @@ def embedding(version, environment, application_name,
# Set Span attributes (OTel Semconv)
span.set_attribute(TELEMETRY_SDK_NAME, 'openlit')
- span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
- SemanticConvetion.GEN_AI_OPERATION_TYPE_EMBEDDING)
- span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
- SemanticConvetion.GEN_AI_SYSTEM_LITELLM)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_EMBEDDING)
+ span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
+ SemanticConvention.GEN_AI_SYSTEM_LITELLM)
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
request_model)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_ENCODING_FORMATS,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_ENCODING_FORMATS,
[kwargs.get('encoding_format', 'float')])
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL,
response_dict.get('model'))
- span.set_attribute(SemanticConvetion.SERVER_ADDRESS,
+ span.set_attribute(SemanticConvention.SERVER_ADDRESS,
server_address)
- span.set_attribute(SemanticConvetion.SERVER_PORT,
+ span.set_attribute(SemanticConvention.SERVER_PORT,
server_port)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_INPUT_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS,
input_tokens)
# Set Span attributes (Extras)
@@ -539,20 +539,20 @@ def embedding(version, environment, application_name,
environment)
span.set_attribute(SERVICE_NAME,
application_name)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_USER,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_USER,
kwargs.get('user', ''))
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_TOTAL_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS,
input_tokens)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST,
cost)
- span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
+ span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION,
version)
if capture_message_content:
span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_PROMPT: str(kwargs.get('input', '')),
+ SemanticConvention.GEN_AI_CONTENT_PROMPT: str(kwargs.get('input', '')),
},
)
@@ -562,8 +562,8 @@ def embedding(version, environment, application_name,
attributes = create_metrics_attributes(
service_name=application_name,
deployment_environment=environment,
- operation=SemanticConvetion.GEN_AI_OPERATION_TYPE_EMBEDDING,
- system=SemanticConvetion.GEN_AI_SYSTEM_LITELLM,
+ operation=SemanticConvention.GEN_AI_OPERATION_TYPE_EMBEDDING,
+ system=SemanticConvention.GEN_AI_SYSTEM_LITELLM,
request_model=request_model,
server_address=server_address,
server_port=server_port,
diff --git a/sdk/python/src/openlit/instrumentation/llamaindex/llamaindex.py b/sdk/python/src/openlit/instrumentation/llamaindex/llamaindex.py
index 3098a30a..570f4671 100644
--- a/sdk/python/src/openlit/instrumentation/llamaindex/llamaindex.py
+++ b/sdk/python/src/openlit/instrumentation/llamaindex/llamaindex.py
@@ -7,7 +7,7 @@ import logging
from opentelemetry.trace import SpanKind, Status, StatusCode
from opentelemetry.sdk.resources import SERVICE_NAME, TELEMETRY_SDK_NAME, DEPLOYMENT_ENVIRONMENT
from openlit.__helpers import handle_exception
-from openlit.semcov import SemanticConvetion
+from openlit.semcov import SemanticConvention
# Initialize logger for logging potential issues and operations
logger = logging.getLogger(__name__)
@@ -59,17 +59,17 @@ def load_data(gen_ai_endpoint, version, environment, application_name,
try:
span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
- span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
- SemanticConvetion.GEN_AI_SYSTEM_LLAMAINDEX)
- span.set_attribute(SemanticConvetion.GEN_AI_ENDPOINT,
+ span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
+ SemanticConvention.GEN_AI_SYSTEM_LLAMAINDEX)
+ span.set_attribute(SemanticConvention.GEN_AI_ENDPOINT,
gen_ai_endpoint)
span.set_attribute(DEPLOYMENT_ENVIRONMENT,
environment)
- span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
- SemanticConvetion.GEN_AI_OPERATION_TYPE_FRAMEWORK)
+ span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_FRAMEWORK)
span.set_attribute(SERVICE_NAME,
application_name)
- span.set_attribute(SemanticConvetion.GEN_AI_RETRIEVAL_SOURCE,
+ span.set_attribute(SemanticConvention.GEN_AI_RETRIEVAL_SOURCE,
response[0].metadata["file_path"])
span.set_status(Status(StatusCode.OK))
diff --git a/sdk/python/src/openlit/instrumentation/mem0/mem0.py b/sdk/python/src/openlit/instrumentation/mem0/mem0.py
index 0c2a26dd..df7a4d22 100644
--- a/sdk/python/src/openlit/instrumentation/mem0/mem0.py
+++ b/sdk/python/src/openlit/instrumentation/mem0/mem0.py
@@ -7,7 +7,7 @@ import logging
from opentelemetry.trace import SpanKind, Status, StatusCode
from opentelemetry.sdk.resources import SERVICE_NAME, TELEMETRY_SDK_NAME, DEPLOYMENT_ENVIRONMENT
from openlit.__helpers import handle_exception
-from openlit.semcov import SemanticConvetion
+from openlit.semcov import SemanticConvention
# Initialize logger for logging potential issues and operations
logger = logging.getLogger(__name__)
@@ -59,44 +59,44 @@ def mem0_wrap(gen_ai_endpoint, version, environment, application_name,
try:
span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
- span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
- SemanticConvetion.GEN_AI_SYSTEM_MEM0)
- span.set_attribute(SemanticConvetion.GEN_AI_ENDPOINT,
+ span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
+ SemanticConvention.GEN_AI_SYSTEM_MEM0)
+ span.set_attribute(SemanticConvention.GEN_AI_ENDPOINT,
gen_ai_endpoint)
span.set_attribute(DEPLOYMENT_ENVIRONMENT,
environment)
- span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
- SemanticConvetion.GEN_AI_OPERATION_TYPE_FRAMEWORK)
+ span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_FRAMEWORK)
span.set_attribute(SERVICE_NAME,
application_name)
if gen_ai_endpoint == "mem0.memory_add":
- span.set_attribute(SemanticConvetion.DB_METADATA,
+ span.set_attribute(SemanticConvention.DB_METADATA,
str(kwargs.get('metadata', '')))
if response:
- span.set_attribute(SemanticConvetion.GEN_AI_DATA_SOURCES,
+ span.set_attribute(SemanticConvention.GEN_AI_DATA_SOURCES,
len(response))
elif gen_ai_endpoint == "mem0.memory_get_all":
if response:
- span.set_attribute(SemanticConvetion.GEN_AI_DATA_SOURCES,
+ span.set_attribute(SemanticConvention.GEN_AI_DATA_SOURCES,
len(response))
elif gen_ai_endpoint == "mem0.memory_get":
if response:
- span.set_attribute(SemanticConvetion.GEN_AI_DATA_SOURCES,
+ span.set_attribute(SemanticConvention.GEN_AI_DATA_SOURCES,
len(response))
elif gen_ai_endpoint == "mem0.memory_search":
- span.set_attribute(SemanticConvetion.DB_STATEMENT,
+ span.set_attribute(SemanticConvention.DB_STATEMENT,
kwargs.get("query", ""))
elif gen_ai_endpoint == "mem0.memory_update":
- span.set_attribute(SemanticConvetion.DB_UPDATE_ID,
+ span.set_attribute(SemanticConvention.DB_UPDATE_ID,
kwargs.get("memory_id", ""))
elif gen_ai_endpoint == "mem0.memory_delete":
- span.set_attribute(SemanticConvetion.DB_DELETE_ID,
+ span.set_attribute(SemanticConvention.DB_DELETE_ID,
kwargs.get("memory_id", ""))
diff --git a/sdk/python/src/openlit/instrumentation/milvus/milvus.py b/sdk/python/src/openlit/instrumentation/milvus/milvus.py
index ad870a03..226281fd 100644
--- a/sdk/python/src/openlit/instrumentation/milvus/milvus.py
+++ b/sdk/python/src/openlit/instrumentation/milvus/milvus.py
@@ -7,7 +7,7 @@ import logging
from opentelemetry.trace import SpanKind, Status, StatusCode
from opentelemetry.sdk.resources import SERVICE_NAME, TELEMETRY_SDK_NAME, DEPLOYMENT_ENVIRONMENT
from openlit.__helpers import handle_exception
-from openlit.semcov import SemanticConvetion
+from openlit.semcov import SemanticConvention
# Initialize logger for logging potential issues and operations
logger = logging.getLogger(__name__)
@@ -71,80 +71,80 @@ def general_wrap(gen_ai_endpoint, version, environment, application_name,
try:
span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
- span.set_attribute(SemanticConvetion.GEN_AI_ENDPOINT,
+ span.set_attribute(SemanticConvention.GEN_AI_ENDPOINT,
gen_ai_endpoint)
span.set_attribute(DEPLOYMENT_ENVIRONMENT,
environment)
span.set_attribute(SERVICE_NAME,
application_name)
- span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
- SemanticConvetion.GEN_AI_OPERATION_TYPE_VECTORDB)
- span.set_attribute(SemanticConvetion.DB_SYSTEM_NAME,
- SemanticConvetion.DB_SYSTEM_MILVUS)
+ span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_VECTORDB)
+ span.set_attribute(SemanticConvention.DB_SYSTEM_NAME,
+ SemanticConvention.DB_SYSTEM_MILVUS)
if gen_ai_endpoint == "milvus.create_collection":
- db_operation = SemanticConvetion.DB_OPERATION_CREATE_COLLECTION
- span.set_attribute(SemanticConvetion.DB_OPERATION_NAME,
- SemanticConvetion.DB_OPERATION_CREATE_COLLECTION)
- span.set_attribute(SemanticConvetion.DB_COLLECTION_NAME,
+ db_operation = SemanticConvention.DB_OPERATION_CREATE_COLLECTION
+ span.set_attribute(SemanticConvention.DB_OPERATION_NAME,
+ SemanticConvention.DB_OPERATION_CREATE_COLLECTION)
+ span.set_attribute(SemanticConvention.DB_COLLECTION_NAME,
kwargs.get("collection_name", ""))
- span.set_attribute(SemanticConvetion.DB_COLLECTION_DIMENSION,
+ span.set_attribute(SemanticConvention.DB_COLLECTION_DIMENSION,
kwargs.get("dimension", ""))
elif gen_ai_endpoint == "milvus.drop_collection":
- db_operation = SemanticConvetion.DB_OPERATION_DELETE_COLLECTION
- span.set_attribute(SemanticConvetion.DB_OPERATION_NAME,
- SemanticConvetion.DB_OPERATION_DELETE_COLLECTION)
- span.set_attribute(SemanticConvetion.DB_COLLECTION_NAME,
+ db_operation = SemanticConvention.DB_OPERATION_DELETE_COLLECTION
+ span.set_attribute(SemanticConvention.DB_OPERATION_NAME,
+ SemanticConvention.DB_OPERATION_DELETE_COLLECTION)
+ span.set_attribute(SemanticConvention.DB_COLLECTION_NAME,
kwargs.get("collection_name", ""))
elif gen_ai_endpoint == "milvus.insert":
- db_operation = SemanticConvetion.DB_OPERATION_ADD
- span.set_attribute(SemanticConvetion.DB_OPERATION_NAME,
- SemanticConvetion.DB_OPERATION_ADD)
- span.set_attribute(SemanticConvetion.DB_COLLECTION_NAME,
+ db_operation = SemanticConvention.DB_OPERATION_ADD
+ span.set_attribute(SemanticConvention.DB_OPERATION_NAME,
+ SemanticConvention.DB_OPERATION_ADD)
+ span.set_attribute(SemanticConvention.DB_COLLECTION_NAME,
kwargs.get("collection_name", ""))
- span.set_attribute(SemanticConvetion.DB_VECTOR_COUNT,
+ span.set_attribute(SemanticConvention.DB_VECTOR_COUNT,
object_count(kwargs.get("data")))
- span.set_attribute(SemanticConvetion.DB_OPERATION_COST,
+ span.set_attribute(SemanticConvention.DB_OPERATION_COST,
response["cost"])
elif gen_ai_endpoint == "milvus.search":
- db_operation = SemanticConvetion.DB_OPERATION_QUERY
- span.set_attribute(SemanticConvetion.DB_OPERATION_NAME,
- SemanticConvetion.DB_OPERATION_QUERY)
- span.set_attribute(SemanticConvetion.DB_COLLECTION_NAME,
+ db_operation = SemanticConvention.DB_OPERATION_QUERY
+ span.set_attribute(SemanticConvention.DB_OPERATION_NAME,
+ SemanticConvention.DB_OPERATION_QUERY)
+ span.set_attribute(SemanticConvention.DB_COLLECTION_NAME,
kwargs.get("collection_name", ""))
- span.set_attribute(SemanticConvetion.DB_STATEMENT,
+ span.set_attribute(SemanticConvention.DB_STATEMENT,
str(kwargs.get("data")))
elif gen_ai_endpoint in ["milvus.query", "milvus.get"]:
- db_operation = SemanticConvetion.DB_OPERATION_QUERY
- span.set_attribute(SemanticConvetion.DB_OPERATION_NAME,
- SemanticConvetion.DB_OPERATION_QUERY)
- span.set_attribute(SemanticConvetion.DB_COLLECTION_NAME,
+ db_operation = SemanticConvention.DB_OPERATION_QUERY
+ span.set_attribute(SemanticConvention.DB_OPERATION_NAME,
+ SemanticConvention.DB_OPERATION_QUERY)
+ span.set_attribute(SemanticConvention.DB_COLLECTION_NAME,
kwargs.get("collection_name", ""))
- span.set_attribute(SemanticConvetion.DB_STATEMENT,
+ span.set_attribute(SemanticConvention.DB_STATEMENT,
str(kwargs.get("output_fields")))
elif gen_ai_endpoint == "milvus.upsert":
- db_operation = SemanticConvetion.DB_OPERATION_ADD
- span.set_attribute(SemanticConvetion.DB_OPERATION_NAME,
- SemanticConvetion.DB_OPERATION_UPSERT)
- span.set_attribute(SemanticConvetion.DB_COLLECTION_NAME,
+ db_operation = SemanticConvention.DB_OPERATION_ADD
+ span.set_attribute(SemanticConvention.DB_OPERATION_NAME,
+ SemanticConvention.DB_OPERATION_UPSERT)
+ span.set_attribute(SemanticConvention.DB_COLLECTION_NAME,
kwargs.get("collection_name", ""))
- span.set_attribute(SemanticConvetion.DB_VECTOR_COUNT,
+ span.set_attribute(SemanticConvention.DB_VECTOR_COUNT,
object_count(kwargs.get("data")))
- span.set_attribute(SemanticConvetion.DB_OPERATION_COST,
+ span.set_attribute(SemanticConvention.DB_OPERATION_COST,
response["cost"])
elif gen_ai_endpoint == "milvus.delete":
- db_operation = SemanticConvetion.DB_OPERATION_DELETE
- span.set_attribute(SemanticConvetion.DB_OPERATION_NAME,
- SemanticConvetion.DB_OPERATION_DELETE)
- span.set_attribute(SemanticConvetion.DB_COLLECTION_NAME,
+ db_operation = SemanticConvention.DB_OPERATION_DELETE
+ span.set_attribute(SemanticConvention.DB_OPERATION_NAME,
+ SemanticConvention.DB_OPERATION_DELETE)
+ span.set_attribute(SemanticConvention.DB_COLLECTION_NAME,
kwargs.get("collection_name", ""))
- span.set_attribute(SemanticConvetion.DB_FILTER,
+ span.set_attribute(SemanticConvention.DB_FILTER,
str(kwargs.get("filter", "")))
span.set_status(Status(StatusCode.OK))
@@ -155,13 +155,13 @@ def general_wrap(gen_ai_endpoint, version, environment, application_name,
"openlit",
SERVICE_NAME:
application_name,
- SemanticConvetion.DB_SYSTEM_NAME:
- SemanticConvetion.DB_SYSTEM_MILVUS,
+ SemanticConvention.DB_SYSTEM_NAME:
+ SemanticConvention.DB_SYSTEM_MILVUS,
DEPLOYMENT_ENVIRONMENT:
environment,
- SemanticConvetion.GEN_AI_OPERATION:
- SemanticConvetion.GEN_AI_OPERATION_TYPE_VECTORDB,
- SemanticConvetion.DB_OPERATION_NAME:
+ SemanticConvention.GEN_AI_OPERATION:
+ SemanticConvention.GEN_AI_OPERATION_TYPE_VECTORDB,
+ SemanticConvention.DB_OPERATION_NAME:
db_operation
}
diff --git a/sdk/python/src/openlit/instrumentation/mistral/async_mistral.py b/sdk/python/src/openlit/instrumentation/mistral/async_mistral.py
index ff32ab52..1ec656fb 100644
--- a/sdk/python/src/openlit/instrumentation/mistral/async_mistral.py
+++ b/sdk/python/src/openlit/instrumentation/mistral/async_mistral.py
@@ -16,7 +16,7 @@ from openlit.__helpers import (
create_metrics_attributes,
set_server_address_and_port
)
-from openlit.semcov import SemanticConvetion
+from openlit.semcov import SemanticConvention
# Initialize logger for logging potential issues and operations
logger = logging.getLogger(__name__)
@@ -58,7 +58,7 @@ def async_chat(version, environment, application_name, tracer,
server_address, server_port = set_server_address_and_port(instance, 'api.mistral.ai', 443)
request_model = kwargs.get('model', 'mistral-small-latest')
- span_name = f'{SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT} {request_model}'
+ span_name = f'{SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT} {request_model}'
with tracer.start_as_current_span(span_name, kind=SpanKind.CLIENT) as span:
start_time = time.time()
@@ -96,37 +96,37 @@ def async_chat(version, environment, application_name, tracer,
# Set base span attribues (OTel Semconv)
span.set_attribute(TELEMETRY_SDK_NAME, 'openlit')
- span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
- SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT)
- span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
- SemanticConvetion.GEN_AI_SYSTEM_MISTRAL)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT)
+ span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
+ SemanticConvention.GEN_AI_SYSTEM_MISTRAL)
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
request_model)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_SEED,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_SEED,
kwargs.get('seed', ''))
- span.set_attribute(SemanticConvetion.SERVER_PORT,
+ span.set_attribute(SemanticConvention.SERVER_PORT,
server_port)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_FREQUENCY_PENALTY,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_FREQUENCY_PENALTY,
kwargs.get('frequency_penalty', 0.0))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MAX_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS,
kwargs.get('max_tokens', -1))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_PRESENCE_PENALTY,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_PRESENCE_PENALTY,
kwargs.get('presence_penalty', 0.0))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_STOP_SEQUENCES,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_STOP_SEQUENCES,
kwargs.get('stop', []))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TEMPERATURE,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TEMPERATURE,
kwargs.get('temperature', 1.0))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TOP_P,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TOP_P,
kwargs.get('top_p', 1.0))
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_ID,
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_ID,
response_dict.get('id'))
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL,
response_dict.get('model'))
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_INPUT_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS,
input_tokens)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_OUTPUT_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS,
output_tokens)
- span.set_attribute(SemanticConvetion.SERVER_ADDRESS,
+ span.set_attribute(SemanticConvention.SERVER_ADDRESS,
server_address)
# Set base span attribues (Extras)
@@ -134,44 +134,44 @@ def async_chat(version, environment, application_name, tracer,
environment)
span.set_attribute(SERVICE_NAME,
application_name)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IS_STREAM,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM,
False)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_TOTAL_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS,
input_tokens + output_tokens)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST,
cost)
- span.set_attribute(SemanticConvetion.GEN_AI_SERVER_TTFT,
+ span.set_attribute(SemanticConvention.GEN_AI_SERVER_TTFT,
end_time - start_time)
- span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
+ span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION,
version)
if capture_message_content:
span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_PROMPT: prompt,
+ SemanticConvention.GEN_AI_CONTENT_PROMPT: prompt,
},
)
for i in range(kwargs.get('n',1)):
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_FINISH_REASON,
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON,
[response_dict.get('choices')[i].get('finish_reason')])
if capture_message_content:
span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_COMPLETION_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_COMPLETION_EVENT,
attributes={
# pylint: disable=line-too-long
- SemanticConvetion.GEN_AI_CONTENT_COMPLETION: str(response_dict.get('choices')[i].get('message').get('content')),
+ SemanticConvention.GEN_AI_CONTENT_COMPLETION: str(response_dict.get('choices')[i].get('message').get('content')),
},
)
if kwargs.get('tools'):
- span.set_attribute(SemanticConvetion.GEN_AI_TOOL_CALLS,
+ span.set_attribute(SemanticConvention.GEN_AI_TOOL_CALLS,
str(response_dict.get('choices')[i].get('message').get('tool_calls')))
if isinstance(response_dict.get('choices')[i].get('message').get('content'), str):
- span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
+ span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
'text')
elif response_dict.get('choices')[i].get('message').get('content') is not None:
- span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
+ span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
'json')
span.set_status(Status(StatusCode.OK))
@@ -180,8 +180,8 @@ def async_chat(version, environment, application_name, tracer,
attributes = create_metrics_attributes(
service_name=application_name,
deployment_environment=environment,
- operation=SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT,
- system=SemanticConvetion.GEN_AI_SYSTEM_MISTRAL,
+ operation=SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
+ system=SemanticConvention.GEN_AI_SYSTEM_MISTRAL,
request_model=request_model,
server_address=server_address,
server_port=server_port,
@@ -361,48 +361,48 @@ def async_chat_stream(version, environment, application_name,
# Set Span attributes (OTel Semconv)
self._span.set_attribute(TELEMETRY_SDK_NAME, 'openlit')
- self._span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
- SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT)
- self._span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
- SemanticConvetion.GEN_AI_SYSTEM_MISTRAL)
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
+ self._span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT)
+ self._span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
+ SemanticConvention.GEN_AI_SYSTEM_MISTRAL)
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
request_model)
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_SEED,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_SEED,
self._kwargs.get('seed', ''))
- self._span.set_attribute(SemanticConvetion.SERVER_PORT,
+ self._span.set_attribute(SemanticConvention.SERVER_PORT,
self._server_port)
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_FREQUENCY_PENALTY,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_FREQUENCY_PENALTY,
self._kwargs.get('frequency_penalty', 0.0))
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MAX_TOKENS,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS,
self._kwargs.get('max_tokens', -1))
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_PRESENCE_PENALTY,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_PRESENCE_PENALTY,
self._kwargs.get('presence_penalty', 0.0))
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_STOP_SEQUENCES,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_STOP_SEQUENCES,
self._kwargs.get('stop_sequences', []))
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TEMPERATURE,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TEMPERATURE,
self._kwargs.get('temperature', 0.3))
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TOP_K,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TOP_K,
self._kwargs.get('k', 1.0))
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TOP_P,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TOP_P,
self._kwargs.get('p', 1.0))
- self._span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_FINISH_REASON,
+ self._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON,
[self._finish_reason])
- self._span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_ID,
+ self._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_ID,
self._response_id)
- self._span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_MODEL,
+ self._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL,
self._response_model)
- self._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_INPUT_TOKENS,
+ self._span.set_attribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS,
self._input_tokens)
- self._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_OUTPUT_TOKENS,
+ self._span.set_attribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS,
self._output_tokens)
- self._span.set_attribute(SemanticConvetion.SERVER_ADDRESS,
+ self._span.set_attribute(SemanticConvention.SERVER_ADDRESS,
self._server_address)
if isinstance(self._llmresponse, str):
- self._span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
+ self._span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
'text')
else:
- self._span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
+ self._span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
'json')
# Set Span attributes (Extra)
@@ -410,29 +410,29 @@ def async_chat_stream(version, environment, application_name,
environment)
self._span.set_attribute(SERVICE_NAME,
application_name)
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IS_STREAM,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM,
True)
- self._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_TOTAL_TOKENS,
+ self._span.set_attribute(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS,
self._input_tokens + self._output_tokens)
- self._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
+ self._span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST,
cost)
- self._span.set_attribute(SemanticConvetion.GEN_AI_SERVER_TBT,
+ self._span.set_attribute(SemanticConvention.GEN_AI_SERVER_TBT,
self._tbt)
- self._span.set_attribute(SemanticConvetion.GEN_AI_SERVER_TTFT,
+ self._span.set_attribute(SemanticConvention.GEN_AI_SERVER_TTFT,
self._ttft)
- self._span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
+ self._span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION,
version)
if capture_message_content:
self._span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_PROMPT: prompt,
+ SemanticConvention.GEN_AI_CONTENT_PROMPT: prompt,
},
)
self._span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_COMPLETION_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_COMPLETION_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_COMPLETION: self._llmresponse,
+ SemanticConvention.GEN_AI_CONTENT_COMPLETION: self._llmresponse,
},
)
self._span.set_status(Status(StatusCode.OK))
@@ -441,8 +441,8 @@ def async_chat_stream(version, environment, application_name,
attributes = create_metrics_attributes(
service_name=application_name,
deployment_environment=environment,
- operation=SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT,
- system=SemanticConvetion.GEN_AI_SYSTEM_MISTRAL,
+ operation=SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
+ system=SemanticConvention.GEN_AI_SYSTEM_MISTRAL,
request_model=request_model,
server_address=self._server_address,
server_port=self._server_port,
@@ -476,7 +476,7 @@ def async_chat_stream(version, environment, application_name,
server_address, server_port = set_server_address_and_port(instance, 'api.mistral.ai', 443)
request_model = kwargs.get('model', 'mistral-small-latest')
- span_name = f'{SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT} {request_model}'
+ span_name = f'{SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT} {request_model}'
awaited_wrapped = await wrapped(*args, **kwargs)
span = tracer.start_span(span_name, kind=SpanKind.CLIENT)
@@ -521,7 +521,7 @@ def async_embeddings(version, environment, application_name,
server_address, server_port = set_server_address_and_port(instance, 'api.mistral.ai', 443)
request_model = kwargs.get('model', 'mistral-embed')
- span_name = f'{SemanticConvetion.GEN_AI_OPERATION_TYPE_EMBEDDING} {request_model}'
+ span_name = f'{SemanticConvention.GEN_AI_OPERATION_TYPE_EMBEDDING} {request_model}'
with tracer.start_as_current_span(span_name, kind= SpanKind.CLIENT) as span:
start_time = time.time()
@@ -538,21 +538,21 @@ def async_embeddings(version, environment, application_name,
# Set Span attributes (OTel Semconv)
span.set_attribute(TELEMETRY_SDK_NAME, 'openlit')
- span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
- SemanticConvetion.GEN_AI_OPERATION_TYPE_EMBEDDING)
- span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
- SemanticConvetion.GEN_AI_SYSTEM_MISTRAL)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_EMBEDDING)
+ span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
+ SemanticConvention.GEN_AI_SYSTEM_MISTRAL)
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
request_model)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_ENCODING_FORMATS,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_ENCODING_FORMATS,
[kwargs.get('encoding_format', 'float')])
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL,
response_dict.get('model'))
- span.set_attribute(SemanticConvetion.SERVER_ADDRESS,
+ span.set_attribute(SemanticConvention.SERVER_ADDRESS,
server_address)
- span.set_attribute(SemanticConvetion.SERVER_PORT,
+ span.set_attribute(SemanticConvention.SERVER_PORT,
server_port)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_INPUT_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS,
input_tokens)
# Set Span attributes (Extras)
@@ -560,18 +560,18 @@ def async_embeddings(version, environment, application_name,
environment)
span.set_attribute(SERVICE_NAME,
application_name)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_TOTAL_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS,
input_tokens)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST,
cost)
- span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
+ span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION,
version)
if capture_message_content:
span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_PROMPT: str(kwargs.get('inputs', '')),
+ SemanticConvention.GEN_AI_CONTENT_PROMPT: str(kwargs.get('inputs', '')),
},
)
@@ -581,8 +581,8 @@ def async_embeddings(version, environment, application_name,
attributes = create_metrics_attributes(
service_name=application_name,
deployment_environment=environment,
- operation=SemanticConvetion.GEN_AI_OPERATION_TYPE_EMBEDDING,
- system=SemanticConvetion.GEN_AI_SYSTEM_MISTRAL,
+ operation=SemanticConvention.GEN_AI_OPERATION_TYPE_EMBEDDING,
+ system=SemanticConvention.GEN_AI_SYSTEM_MISTRAL,
request_model=request_model,
server_address=server_address,
server_port=server_port,
diff --git a/sdk/python/src/openlit/instrumentation/mistral/mistral.py b/sdk/python/src/openlit/instrumentation/mistral/mistral.py
index 5bbf9041..923bd839 100644
--- a/sdk/python/src/openlit/instrumentation/mistral/mistral.py
+++ b/sdk/python/src/openlit/instrumentation/mistral/mistral.py
@@ -16,7 +16,7 @@ from openlit.__helpers import (
create_metrics_attributes,
set_server_address_and_port
)
-from openlit.semcov import SemanticConvetion
+from openlit.semcov import SemanticConvention
# Initialize logger for logging potential issues and operations
logger = logging.getLogger(__name__)
@@ -58,7 +58,7 @@ def chat(version, environment, application_name, tracer,
server_address, server_port = set_server_address_and_port(instance, 'api.mistral.ai', 443)
request_model = kwargs.get('model', 'mistral-small-latest')
- span_name = f'{SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT} {request_model}'
+ span_name = f'{SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT} {request_model}'
with tracer.start_as_current_span(span_name, kind=SpanKind.CLIENT) as span:
start_time = time.time()
@@ -96,37 +96,37 @@ def chat(version, environment, application_name, tracer,
# Set base span attribues (OTel Semconv)
span.set_attribute(TELEMETRY_SDK_NAME, 'openlit')
- span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
- SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT)
- span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
- SemanticConvetion.GEN_AI_SYSTEM_MISTRAL)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT)
+ span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
+ SemanticConvention.GEN_AI_SYSTEM_MISTRAL)
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
request_model)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_SEED,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_SEED,
kwargs.get('seed', ''))
- span.set_attribute(SemanticConvetion.SERVER_PORT,
+ span.set_attribute(SemanticConvention.SERVER_PORT,
server_port)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_FREQUENCY_PENALTY,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_FREQUENCY_PENALTY,
kwargs.get('frequency_penalty', 0.0))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MAX_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS,
kwargs.get('max_tokens', -1))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_PRESENCE_PENALTY,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_PRESENCE_PENALTY,
kwargs.get('presence_penalty', 0.0))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_STOP_SEQUENCES,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_STOP_SEQUENCES,
kwargs.get('stop', []))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TEMPERATURE,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TEMPERATURE,
kwargs.get('temperature', 1.0))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TOP_P,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TOP_P,
kwargs.get('top_p', 1.0))
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_ID,
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_ID,
response_dict.get('id'))
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL,
response_dict.get('model'))
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_INPUT_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS,
input_tokens)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_OUTPUT_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS,
output_tokens)
- span.set_attribute(SemanticConvetion.SERVER_ADDRESS,
+ span.set_attribute(SemanticConvention.SERVER_ADDRESS,
server_address)
# Set base span attribues (Extras)
@@ -134,44 +134,44 @@ def chat(version, environment, application_name, tracer,
environment)
span.set_attribute(SERVICE_NAME,
application_name)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IS_STREAM,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM,
False)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_TOTAL_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS,
input_tokens + output_tokens)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST,
cost)
- span.set_attribute(SemanticConvetion.GEN_AI_SERVER_TTFT,
+ span.set_attribute(SemanticConvention.GEN_AI_SERVER_TTFT,
end_time - start_time)
- span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
+ span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION,
version)
if capture_message_content:
span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_PROMPT: prompt,
+ SemanticConvention.GEN_AI_CONTENT_PROMPT: prompt,
},
)
for i in range(kwargs.get('n',1)):
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_FINISH_REASON,
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON,
[response_dict.get('choices')[i].get('finish_reason')])
if capture_message_content:
span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_COMPLETION_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_COMPLETION_EVENT,
attributes={
# pylint: disable=line-too-long
- SemanticConvetion.GEN_AI_CONTENT_COMPLETION: str(response_dict.get('choices')[i].get('message').get('content')),
+ SemanticConvention.GEN_AI_CONTENT_COMPLETION: str(response_dict.get('choices')[i].get('message').get('content')),
},
)
if kwargs.get('tools'):
- span.set_attribute(SemanticConvetion.GEN_AI_TOOL_CALLS,
+ span.set_attribute(SemanticConvention.GEN_AI_TOOL_CALLS,
str(response_dict.get('choices')[i].get('message').get('tool_calls')))
if isinstance(response_dict.get('choices')[i].get('message').get('content'), str):
- span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
+ span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
'text')
elif response_dict.get('choices')[i].get('message').get('content') is not None:
- span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
+ span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
'json')
span.set_status(Status(StatusCode.OK))
@@ -180,8 +180,8 @@ def chat(version, environment, application_name, tracer,
attributes = create_metrics_attributes(
service_name=application_name,
deployment_environment=environment,
- operation=SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT,
- system=SemanticConvetion.GEN_AI_SYSTEM_MISTRAL,
+ operation=SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
+ system=SemanticConvention.GEN_AI_SYSTEM_MISTRAL,
request_model=request_model,
server_address=server_address,
server_port=server_port,
@@ -361,48 +361,48 @@ def chat_stream(version, environment, application_name,
# Set Span attributes (OTel Semconv)
self._span.set_attribute(TELEMETRY_SDK_NAME, 'openlit')
- self._span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
- SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT)
- self._span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
- SemanticConvetion.GEN_AI_SYSTEM_MISTRAL)
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
+ self._span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT)
+ self._span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
+ SemanticConvention.GEN_AI_SYSTEM_MISTRAL)
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
request_model)
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_SEED,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_SEED,
self._kwargs.get('seed', ''))
- self._span.set_attribute(SemanticConvetion.SERVER_PORT,
+ self._span.set_attribute(SemanticConvention.SERVER_PORT,
self._server_port)
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_FREQUENCY_PENALTY,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_FREQUENCY_PENALTY,
self._kwargs.get('frequency_penalty', 0.0))
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MAX_TOKENS,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS,
self._kwargs.get('max_tokens', -1))
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_PRESENCE_PENALTY,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_PRESENCE_PENALTY,
self._kwargs.get('presence_penalty', 0.0))
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_STOP_SEQUENCES,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_STOP_SEQUENCES,
self._kwargs.get('stop_sequences', []))
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TEMPERATURE,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TEMPERATURE,
self._kwargs.get('temperature', 0.3))
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TOP_K,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TOP_K,
self._kwargs.get('k', 1.0))
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TOP_P,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TOP_P,
self._kwargs.get('p', 1.0))
- self._span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_FINISH_REASON,
+ self._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON,
[self._finish_reason])
- self._span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_ID,
+ self._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_ID,
self._response_id)
- self._span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_MODEL,
+ self._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL,
self._response_model)
- self._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_INPUT_TOKENS,
+ self._span.set_attribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS,
self._input_tokens)
- self._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_OUTPUT_TOKENS,
+ self._span.set_attribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS,
self._output_tokens)
- self._span.set_attribute(SemanticConvetion.SERVER_ADDRESS,
+ self._span.set_attribute(SemanticConvention.SERVER_ADDRESS,
self._server_address)
if isinstance(self._llmresponse, str):
- self._span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
+ self._span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
'text')
else:
- self._span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
+ self._span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
'json')
# Set Span attributes (Extra)
@@ -410,29 +410,29 @@ def chat_stream(version, environment, application_name,
environment)
self._span.set_attribute(SERVICE_NAME,
application_name)
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IS_STREAM,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM,
True)
- self._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_TOTAL_TOKENS,
+ self._span.set_attribute(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS,
self._input_tokens + self._output_tokens)
- self._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
+ self._span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST,
cost)
- self._span.set_attribute(SemanticConvetion.GEN_AI_SERVER_TBT,
+ self._span.set_attribute(SemanticConvention.GEN_AI_SERVER_TBT,
self._tbt)
- self._span.set_attribute(SemanticConvetion.GEN_AI_SERVER_TTFT,
+ self._span.set_attribute(SemanticConvention.GEN_AI_SERVER_TTFT,
self._ttft)
- self._span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
+ self._span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION,
version)
if capture_message_content:
self._span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_PROMPT: prompt,
+ SemanticConvention.GEN_AI_CONTENT_PROMPT: prompt,
},
)
self._span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_COMPLETION_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_COMPLETION_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_COMPLETION: self._llmresponse,
+ SemanticConvention.GEN_AI_CONTENT_COMPLETION: self._llmresponse,
},
)
self._span.set_status(Status(StatusCode.OK))
@@ -441,8 +441,8 @@ def chat_stream(version, environment, application_name,
attributes = create_metrics_attributes(
service_name=application_name,
deployment_environment=environment,
- operation=SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT,
- system=SemanticConvetion.GEN_AI_SYSTEM_MISTRAL,
+ operation=SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
+ system=SemanticConvention.GEN_AI_SYSTEM_MISTRAL,
request_model=request_model,
server_address=self._server_address,
server_port=self._server_port,
@@ -476,7 +476,7 @@ def chat_stream(version, environment, application_name,
server_address, server_port = set_server_address_and_port(instance, 'api.mistral.ai', 443)
request_model = kwargs.get('model', 'mistral-small-latest')
- span_name = f'{SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT} {request_model}'
+ span_name = f'{SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT} {request_model}'
awaited_wrapped = wrapped(*args, **kwargs)
span = tracer.start_span(span_name, kind=SpanKind.CLIENT)
@@ -521,7 +521,7 @@ def embeddings(version, environment, application_name,
server_address, server_port = set_server_address_and_port(instance, 'api.mistral.ai', 443)
request_model = kwargs.get('model', 'mistral-embed')
- span_name = f'{SemanticConvetion.GEN_AI_OPERATION_TYPE_EMBEDDING} {request_model}'
+ span_name = f'{SemanticConvention.GEN_AI_OPERATION_TYPE_EMBEDDING} {request_model}'
with tracer.start_as_current_span(span_name, kind= SpanKind.CLIENT) as span:
start_time = time.time()
@@ -538,21 +538,21 @@ def embeddings(version, environment, application_name,
# Set Span attributes (OTel Semconv)
span.set_attribute(TELEMETRY_SDK_NAME, 'openlit')
- span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
- SemanticConvetion.GEN_AI_OPERATION_TYPE_EMBEDDING)
- span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
- SemanticConvetion.GEN_AI_SYSTEM_MISTRAL)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_EMBEDDING)
+ span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
+ SemanticConvention.GEN_AI_SYSTEM_MISTRAL)
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
request_model)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_ENCODING_FORMATS,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_ENCODING_FORMATS,
[kwargs.get('encoding_format', 'float')])
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL,
response_dict.get('model'))
- span.set_attribute(SemanticConvetion.SERVER_ADDRESS,
+ span.set_attribute(SemanticConvention.SERVER_ADDRESS,
server_address)
- span.set_attribute(SemanticConvetion.SERVER_PORT,
+ span.set_attribute(SemanticConvention.SERVER_PORT,
server_port)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_INPUT_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS,
input_tokens)
# Set Span attributes (Extras)
@@ -560,18 +560,18 @@ def embeddings(version, environment, application_name,
environment)
span.set_attribute(SERVICE_NAME,
application_name)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_TOTAL_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS,
input_tokens)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST,
cost)
- span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
+ span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION,
version)
if capture_message_content:
span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_PROMPT: str(kwargs.get('inputs', '')),
+ SemanticConvention.GEN_AI_CONTENT_PROMPT: str(kwargs.get('inputs', '')),
},
)
@@ -581,8 +581,8 @@ def embeddings(version, environment, application_name,
attributes = create_metrics_attributes(
service_name=application_name,
deployment_environment=environment,
- operation=SemanticConvetion.GEN_AI_OPERATION_TYPE_EMBEDDING,
- system=SemanticConvetion.GEN_AI_SYSTEM_MISTRAL,
+ operation=SemanticConvention.GEN_AI_OPERATION_TYPE_EMBEDDING,
+ system=SemanticConvention.GEN_AI_SYSTEM_MISTRAL,
request_model=request_model,
server_address=server_address,
server_port=server_port,
diff --git a/sdk/python/src/openlit/instrumentation/multion/async_multion.py b/sdk/python/src/openlit/instrumentation/multion/async_multion.py
index cff7bd9d..bdca033b 100644
--- a/sdk/python/src/openlit/instrumentation/multion/async_multion.py
+++ b/sdk/python/src/openlit/instrumentation/multion/async_multion.py
@@ -9,7 +9,7 @@ from opentelemetry.sdk.resources import SERVICE_NAME, TELEMETRY_SDK_NAME, DEPLOY
from openlit.__helpers import (
handle_exception,
)
-from openlit.semcov import SemanticConvetion
+from openlit.semcov import SemanticConvention
# Initialize logger for logging potential issues and operations
logger = logging.getLogger(__name__)
@@ -56,11 +56,11 @@ def async_multion_wrap(gen_ai_endpoint, version, environment, application_name,
try:
# Set base span attribues
span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
- span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
- SemanticConvetion.GEN_AI_SYSTEM_MULTION)
- span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
- SemanticConvetion.GEN_AI_OPERATION_TYPE_AGENT)
- span.set_attribute(SemanticConvetion.GEN_AI_ENDPOINT,
+ span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
+ SemanticConvention.GEN_AI_SYSTEM_MULTION)
+ span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_AGENT)
+ span.set_attribute(SemanticConvention.GEN_AI_ENDPOINT,
gen_ai_endpoint)
span.set_attribute(SERVICE_NAME,
application_name)
@@ -68,53 +68,53 @@ def async_multion_wrap(gen_ai_endpoint, version, environment, application_name,
environment)
if gen_ai_endpoint == "multion.browse":
- span.set_attribute(SemanticConvetion.GEN_AI_AGENT_BROWSE_URL,
+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_BROWSE_URL,
kwargs.get("url", ""))
- span.set_attribute(SemanticConvetion.GEN_AI_AGENT_STEP_COUNT,
+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_STEP_COUNT,
response.metadata.step_count)
- span.set_attribute(SemanticConvetion.GEN_AI_AGENT_RESPONSE_TIME,
+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_RESPONSE_TIME,
response.metadata.processing_time)
if capture_message_content:
span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_PROMPT: kwargs.get("cmd", ""),
+ SemanticConvention.GEN_AI_CONTENT_PROMPT: kwargs.get("cmd", ""),
},
)
span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_COMPLETION_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_COMPLETION_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_COMPLETION: response.message,
+ SemanticConvention.GEN_AI_CONTENT_COMPLETION: response.message,
},
)
elif gen_ai_endpoint == "multion.retrieve":
- span.set_attribute(SemanticConvetion.GEN_AI_AGENT_BROWSE_URL,
+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_BROWSE_URL,
kwargs.get("url", ""))
if capture_message_content:
span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_PROMPT: kwargs.get("cmd", ""),
+ SemanticConvention.GEN_AI_CONTENT_PROMPT: kwargs.get("cmd", ""),
},
)
span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_COMPLETION_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_COMPLETION_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_COMPLETION: response.message,
+ SemanticConvention.GEN_AI_CONTENT_COMPLETION: response.message,
},
)
elif gen_ai_endpoint == "multion.sessions.create":
- span.set_attribute(SemanticConvetion.GEN_AI_AGENT_BROWSE_URL,
+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_BROWSE_URL,
kwargs.get("url", ""))
if capture_message_content:
span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_COMPLETION_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_COMPLETION_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_COMPLETION: response.message,
+ SemanticConvention.GEN_AI_CONTENT_COMPLETION: response.message,
},
)
diff --git a/sdk/python/src/openlit/instrumentation/multion/multion.py b/sdk/python/src/openlit/instrumentation/multion/multion.py
index d6c34337..05c9fd27 100644
--- a/sdk/python/src/openlit/instrumentation/multion/multion.py
+++ b/sdk/python/src/openlit/instrumentation/multion/multion.py
@@ -9,7 +9,7 @@ from opentelemetry.sdk.resources import SERVICE_NAME, TELEMETRY_SDK_NAME, DEPLOY
from openlit.__helpers import (
handle_exception,
)
-from openlit.semcov import SemanticConvetion
+from openlit.semcov import SemanticConvention
# Initialize logger for logging potential issues and operations
logger = logging.getLogger(__name__)
@@ -56,11 +56,11 @@ def multion_wrap(gen_ai_endpoint, version, environment, application_name,
try:
# Set base span attribues
span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
- span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
- SemanticConvetion.GEN_AI_SYSTEM_MULTION)
- span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
- SemanticConvetion.GEN_AI_OPERATION_TYPE_AGENT)
- span.set_attribute(SemanticConvetion.GEN_AI_ENDPOINT,
+ span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
+ SemanticConvention.GEN_AI_SYSTEM_MULTION)
+ span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_AGENT)
+ span.set_attribute(SemanticConvention.GEN_AI_ENDPOINT,
gen_ai_endpoint)
span.set_attribute(SERVICE_NAME,
application_name)
@@ -68,53 +68,53 @@ def multion_wrap(gen_ai_endpoint, version, environment, application_name,
environment)
if gen_ai_endpoint == "multion.browse":
- span.set_attribute(SemanticConvetion.GEN_AI_AGENT_BROWSE_URL,
+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_BROWSE_URL,
kwargs.get("url", ""))
- span.set_attribute(SemanticConvetion.GEN_AI_AGENT_STEP_COUNT,
+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_STEP_COUNT,
response.metadata.step_count)
- span.set_attribute(SemanticConvetion.GEN_AI_AGENT_RESPONSE_TIME,
+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_RESPONSE_TIME,
response.metadata.processing_time)
if capture_message_content:
span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_PROMPT: kwargs.get("cmd", ""),
+ SemanticConvention.GEN_AI_CONTENT_PROMPT: kwargs.get("cmd", ""),
},
)
span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_COMPLETION_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_COMPLETION_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_COMPLETION: response.message,
+ SemanticConvention.GEN_AI_CONTENT_COMPLETION: response.message,
},
)
elif gen_ai_endpoint == "multion.retrieve":
- span.set_attribute(SemanticConvetion.GEN_AI_AGENT_BROWSE_URL,
+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_BROWSE_URL,
kwargs.get("url", ""))
if capture_message_content:
span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_PROMPT: kwargs.get("cmd", ""),
+ SemanticConvention.GEN_AI_CONTENT_PROMPT: kwargs.get("cmd", ""),
},
)
span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_COMPLETION_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_COMPLETION_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_COMPLETION: response.message,
+ SemanticConvention.GEN_AI_CONTENT_COMPLETION: response.message,
},
)
elif gen_ai_endpoint == "multion.sessions.create":
- span.set_attribute(SemanticConvetion.GEN_AI_AGENT_BROWSE_URL,
+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_BROWSE_URL,
kwargs.get("url", ""))
if capture_message_content:
span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_COMPLETION_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_COMPLETION_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_COMPLETION: response.message,
+ SemanticConvention.GEN_AI_CONTENT_COMPLETION: response.message,
},
)
diff --git a/sdk/python/src/openlit/instrumentation/ollama/async_ollama.py b/sdk/python/src/openlit/instrumentation/ollama/async_ollama.py
index 64367746..9d8af092 100644
--- a/sdk/python/src/openlit/instrumentation/ollama/async_ollama.py
+++ b/sdk/python/src/openlit/instrumentation/ollama/async_ollama.py
@@ -15,7 +15,7 @@ from openlit.instrumentation.ollama.utils import (
process_streaming_chat_response,
process_embedding_response
)
-from openlit.semcov import SemanticConvetion
+from openlit.semcov import SemanticConvention
logger = logging.getLogger(__name__)
@@ -108,7 +108,7 @@ def async_chat(version, environment, application_name,
server_address, server_port = set_server_address_and_port(instance, "127.0.0.1", 11434)
request_model = kwargs.get("model", "gpt-4o")
- span_name = f"{SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT} {request_model}"
+ span_name = f"{SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT} {request_model}"
# pylint: disable=no-else-return
if streaming:
@@ -156,7 +156,7 @@ def async_embeddings(version, environment, application_name,
server_address, server_port = set_server_address_and_port(instance, '127.0.0.1', 11434)
request_model = kwargs.get('model', 'all-minilm')
- span_name = f'{SemanticConvetion.GEN_AI_OPERATION_TYPE_EMBEDDING} {request_model}'
+ span_name = f'{SemanticConvention.GEN_AI_OPERATION_TYPE_EMBEDDING} {request_model}'
with tracer.start_as_current_span(span_name, kind= SpanKind.CLIENT) as span:
start_time = time.time()
diff --git a/sdk/python/src/openlit/instrumentation/ollama/ollama.py b/sdk/python/src/openlit/instrumentation/ollama/ollama.py
index 4bfcbe4b..5864a186 100644
--- a/sdk/python/src/openlit/instrumentation/ollama/ollama.py
+++ b/sdk/python/src/openlit/instrumentation/ollama/ollama.py
@@ -15,7 +15,7 @@ from openlit.instrumentation.ollama.utils import (
process_streaming_chat_response,
process_embedding_response
)
-from openlit.semcov import SemanticConvetion
+from openlit.semcov import SemanticConvention
logger = logging.getLogger(__name__)
@@ -108,7 +108,7 @@ def chat(version, environment, application_name,
server_address, server_port = set_server_address_and_port(instance, "127.0.0.1", 11434)
request_model = kwargs.get("model", "gpt-4o")
- span_name = f"{SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT} {request_model}"
+ span_name = f"{SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT} {request_model}"
# pylint: disable=no-else-return
if streaming:
@@ -156,7 +156,7 @@ def embeddings(version, environment, application_name,
server_address, server_port = set_server_address_and_port(instance, '127.0.0.1', 11434)
request_model = kwargs.get('model', 'all-minilm')
- span_name = f'{SemanticConvetion.GEN_AI_OPERATION_TYPE_EMBEDDING} {request_model}'
+ span_name = f'{SemanticConvention.GEN_AI_OPERATION_TYPE_EMBEDDING} {request_model}'
with tracer.start_as_current_span(span_name, kind= SpanKind.CLIENT) as span:
start_time = time.time()
diff --git a/sdk/python/src/openlit/instrumentation/ollama/utils.py b/sdk/python/src/openlit/instrumentation/ollama/utils.py
index 5d259573..c5606b05 100644
--- a/sdk/python/src/openlit/instrumentation/ollama/utils.py
+++ b/sdk/python/src/openlit/instrumentation/ollama/utils.py
@@ -19,7 +19,7 @@ from openlit.__helpers import (
otel_event,
concatenate_all_contents
)
-from openlit.semcov import SemanticConvetion
+from openlit.semcov import SemanticConvention
def process_chunk(self, chunk):
"""
@@ -64,20 +64,20 @@ def common_chat_logic(scope, pricing_info, environment, application_name, metric
# Set Span attributes (OTel Semconv)
scope._span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
- scope._span.set_attribute(SemanticConvetion.GEN_AI_OPERATION, SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT)
- scope._span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM, SemanticConvetion.GEN_AI_SYSTEM_OLLAMA)
- scope._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL, request_model)
- scope._span.set_attribute(SemanticConvetion.SERVER_PORT, scope._server_port)
+ scope._span.set_attribute(SemanticConvention.GEN_AI_OPERATION, SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT)
+ scope._span.set_attribute(SemanticConvention.GEN_AI_SYSTEM, SemanticConvention.GEN_AI_SYSTEM_OLLAMA)
+ scope._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL, request_model)
+ scope._span.set_attribute(SemanticConvention.SERVER_PORT, scope._server_port)
options = scope._kwargs.get('options', {})
attributes = [
- (SemanticConvetion.GEN_AI_REQUEST_FREQUENCY_PENALTY, 'repeat_penalty'),
- (SemanticConvetion.GEN_AI_REQUEST_MAX_TOKENS, 'max_tokens'),
- (SemanticConvetion.GEN_AI_REQUEST_SEED, 'seed'),
- (SemanticConvetion.GEN_AI_REQUEST_STOP_SEQUENCES, 'stop'),
- (SemanticConvetion.GEN_AI_REQUEST_TEMPERATURE, 'temperature'),
- (SemanticConvetion.GEN_AI_REQUEST_TOP_P, 'top_p'),
- (SemanticConvetion.GEN_AI_REQUEST_TOP_K, 'top_k'),
+ (SemanticConvention.GEN_AI_REQUEST_FREQUENCY_PENALTY, 'repeat_penalty'),
+ (SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS, 'max_tokens'),
+ (SemanticConvention.GEN_AI_REQUEST_SEED, 'seed'),
+ (SemanticConvention.GEN_AI_REQUEST_STOP_SEQUENCES, 'stop'),
+ (SemanticConvention.GEN_AI_REQUEST_TEMPERATURE, 'temperature'),
+ (SemanticConvention.GEN_AI_REQUEST_TOP_P, 'top_p'),
+ (SemanticConvention.GEN_AI_REQUEST_TOP_K, 'top_k'),
]
for attribute, key in attributes:
@@ -85,37 +85,37 @@ def common_chat_logic(scope, pricing_info, environment, application_name, metric
if value is not None:
scope._span.set_attribute(attribute, value)
- scope._span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_FINISH_REASON, [scope._finish_reason])
- scope._span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_MODEL, scope._response_model)
- scope._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_INPUT_TOKENS, scope._input_tokens)
- scope._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_OUTPUT_TOKENS, scope._output_tokens)
- scope._span.set_attribute(SemanticConvetion.SERVER_ADDRESS, scope._server_address)
+ scope._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON, [scope._finish_reason])
+ scope._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL, scope._response_model)
+ scope._span.set_attribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS, scope._input_tokens)
+ scope._span.set_attribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS, scope._output_tokens)
+ scope._span.set_attribute(SemanticConvention.SERVER_ADDRESS, scope._server_address)
- scope._span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
+ scope._span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
"text" if isinstance(scope._llmresponse, str) else "json")
scope._span.set_attribute(DEPLOYMENT_ENVIRONMENT, environment)
scope._span.set_attribute(SERVICE_NAME, application_name)
- scope._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IS_STREAM, is_stream)
- scope._span.set_attribute(SemanticConvetion.GEN_AI_CLIENT_TOKEN_USAGE, scope._input_tokens + scope._output_tokens)
- scope._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST, cost)
- scope._span.set_attribute(SemanticConvetion.GEN_AI_SERVER_TBT, scope._tbt)
- scope._span.set_attribute(SemanticConvetion.GEN_AI_SERVER_TTFT, scope._ttft)
- scope._span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION, version)
+ scope._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM, is_stream)
+ scope._span.set_attribute(SemanticConvention.GEN_AI_CLIENT_TOKEN_USAGE, scope._input_tokens + scope._output_tokens)
+ scope._span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST, cost)
+ scope._span.set_attribute(SemanticConvention.GEN_AI_SERVER_TBT, scope._tbt)
+ scope._span.set_attribute(SemanticConvention.GEN_AI_SERVER_TTFT, scope._ttft)
+ scope._span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION, version)
# To be removed one the change to log events (from span events) is complete
prompt = concatenate_all_contents(formatted_messages)
if capture_message_content:
scope._span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_PROMPT: prompt,
+ SemanticConvention.GEN_AI_CONTENT_PROMPT: prompt,
},
)
scope._span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_COMPLETION_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_COMPLETION_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_COMPLETION: scope._llmresponse,
+ SemanticConvention.GEN_AI_CONTENT_COMPLETION: scope._llmresponse,
},
)
@@ -145,9 +145,9 @@ def common_chat_logic(scope, pricing_info, environment, application_name, metric
for role in ['user', 'system', 'assistant', 'tool']:
if formatted_messages.get(role, {}).get('content', ''):
event = otel_event(
- name=getattr(SemanticConvetion, f'GEN_AI_{role.upper()}_MESSAGE'),
+ name=getattr(SemanticConvention, f'GEN_AI_{role.upper()}_MESSAGE'),
attributes={
- SemanticConvetion.GEN_AI_SYSTEM: SemanticConvetion.GEN_AI_SYSTEM_OLLAMA
+ SemanticConvention.GEN_AI_SYSTEM: SemanticConvention.GEN_AI_SYSTEM_OLLAMA
},
body = {
# pylint: disable=line-too-long
@@ -172,9 +172,9 @@ def common_chat_logic(scope, pricing_info, environment, application_name, metric
event_provider.emit(event)
choice_event = otel_event(
- name=SemanticConvetion.GEN_AI_CHOICE,
+ name=SemanticConvention.GEN_AI_CHOICE,
attributes={
- SemanticConvetion.GEN_AI_SYSTEM: SemanticConvetion.GEN_AI_SYSTEM_OLLAMA
+ SemanticConvention.GEN_AI_SYSTEM: SemanticConvention.GEN_AI_SYSTEM_OLLAMA
},
body=choice_event_body
)
@@ -186,8 +186,8 @@ def common_chat_logic(scope, pricing_info, environment, application_name, metric
metrics_attributes = create_metrics_attributes(
service_name=application_name,
deployment_environment=environment,
- operation=SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT,
- system=SemanticConvetion.GEN_AI_SYSTEM_OLLAMA,
+ operation=SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
+ system=SemanticConvention.GEN_AI_SYSTEM_OLLAMA,
request_model=request_model,
server_address=scope._server_address,
server_port=scope._server_port,
@@ -260,19 +260,19 @@ def process_embedding_response(response, request_model, pricing_info, server_por
# Set Span attributes (OTel Semconv)
span.set_attribute(TELEMETRY_SDK_NAME, 'openlit')
- span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
- SemanticConvetion.GEN_AI_OPERATION_TYPE_EMBEDDING)
- span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
- SemanticConvetion.GEN_AI_SYSTEM_OLLAMA)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_EMBEDDING)
+ span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
+ SemanticConvention.GEN_AI_SYSTEM_OLLAMA)
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
request_model)
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL,
request_model)
- span.set_attribute(SemanticConvetion.SERVER_ADDRESS,
+ span.set_attribute(SemanticConvention.SERVER_ADDRESS,
server_address)
- span.set_attribute(SemanticConvetion.SERVER_PORT,
+ span.set_attribute(SemanticConvention.SERVER_PORT,
server_port)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_INPUT_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS,
input_tokens)
# Set Span attributes (Extras)
@@ -280,17 +280,17 @@ def process_embedding_response(response, request_model, pricing_info, server_por
environment)
span.set_attribute(SERVICE_NAME,
application_name)
- span.set_attribute(SemanticConvetion.GEN_AI_CLIENT_TOKEN_USAGE,
+ span.set_attribute(SemanticConvention.GEN_AI_CLIENT_TOKEN_USAGE,
input_tokens)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST,
cost)
- span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
+ span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION,
version)
prompt_event = otel_event(
- name=SemanticConvetion.GEN_AI_USER_MESSAGE,
+ name=SemanticConvention.GEN_AI_USER_MESSAGE,
attributes={
- SemanticConvetion.GEN_AI_SYSTEM: SemanticConvetion.GEN_AI_SYSTEM_OLLAMA
+ SemanticConvention.GEN_AI_SYSTEM: SemanticConvention.GEN_AI_SYSTEM_OLLAMA
},
body={
**({"content": kwargs.get('prompt', '')} if capture_message_content else {}),
@@ -305,8 +305,8 @@ def process_embedding_response(response, request_model, pricing_info, server_por
attributes = create_metrics_attributes(
service_name=application_name,
deployment_environment=environment,
- operation=SemanticConvetion.GEN_AI_OPERATION_TYPE_EMBEDDING,
- system=SemanticConvetion.GEN_AI_SYSTEM_OLLAMA,
+ operation=SemanticConvention.GEN_AI_OPERATION_TYPE_EMBEDDING,
+ system=SemanticConvention.GEN_AI_SYSTEM_OLLAMA,
request_model=request_model,
server_address=server_address,
server_port=server_port,
diff --git a/sdk/python/src/openlit/instrumentation/openai/async_openai.py b/sdk/python/src/openlit/instrumentation/openai/async_openai.py
index 4dd8a885..f48138ba 100644
--- a/sdk/python/src/openlit/instrumentation/openai/async_openai.py
+++ b/sdk/python/src/openlit/instrumentation/openai/async_openai.py
@@ -21,7 +21,7 @@ from openlit.__helpers import (
create_metrics_attributes,
set_server_address_and_port
)
-from openlit.semcov import SemanticConvetion
+from openlit.semcov import SemanticConvention
# Initialize logger for logging potential issues and operations
logger = logging.getLogger(__name__)
@@ -141,41 +141,41 @@ def async_responses(version, environment, application_name,
# Set Span attributes (OTel Semconv)
self._span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
- self._span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
- SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT)
- self._span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
- SemanticConvetion.GEN_AI_SYSTEM_OPENAI)
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
+ self._span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT)
+ self._span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
+ SemanticConvention.GEN_AI_SYSTEM_OPENAI)
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
request_model)
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_SEED,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_SEED,
self._kwargs.get("seed", ""))
- self._span.set_attribute(SemanticConvetion.SERVER_PORT,
+ self._span.set_attribute(SemanticConvention.SERVER_PORT,
self._server_port)
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MAX_TOKENS,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS,
self._kwargs.get("max_output_tokens", -1))
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_STOP_SEQUENCES,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_STOP_SEQUENCES,
self._kwargs.get("stop", []))
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TEMPERATURE,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TEMPERATURE,
self._kwargs.get("temperature", 1.0))
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TOP_P,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TOP_P,
self._kwargs.get("top_p", 1.0))
- self._span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_FINISH_REASON,
+ self._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON,
[self._finish_reason])
- self._span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_ID,
+ self._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_ID,
self._response_id)
- self._span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_MODEL,
+ self._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL,
self._response_model)
- self._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_INPUT_TOKENS,
+ self._span.set_attribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS,
self._input_tokens)
- self._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_OUTPUT_TOKENS,
+ self._span.set_attribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS,
self._output_tokens)
- self._span.set_attribute(SemanticConvetion.SERVER_ADDRESS,
+ self._span.set_attribute(SemanticConvention.SERVER_ADDRESS,
self._server_address)
if isinstance(self._llmresponse, str):
- self._span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
+ self._span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
"text")
else:
- self._span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
+ self._span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
"json")
# Set Span attributes (Extra)
@@ -183,32 +183,32 @@ def async_responses(version, environment, application_name,
environment)
self._span.set_attribute(SERVICE_NAME,
application_name)
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_USER,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_USER,
self._kwargs.get("user", ""))
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IS_STREAM,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM,
True)
- self._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_TOTAL_TOKENS,
+ self._span.set_attribute(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS,
self._input_tokens + self._output_tokens)
- self._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
+ self._span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST,
cost)
- self._span.set_attribute(SemanticConvetion.GEN_AI_SERVER_TBT,
+ self._span.set_attribute(SemanticConvention.GEN_AI_SERVER_TBT,
self._tbt)
- self._span.set_attribute(SemanticConvetion.GEN_AI_SERVER_TTFT,
+ self._span.set_attribute(SemanticConvention.GEN_AI_SERVER_TTFT,
self._ttft)
- self._span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
+ self._span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION,
version)
if capture_message_content:
self._span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_PROMPT: prompt,
+ SemanticConvention.GEN_AI_CONTENT_PROMPT: prompt,
},
)
self._span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_COMPLETION_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_COMPLETION_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_COMPLETION: self._llmresponse,
+ SemanticConvention.GEN_AI_CONTENT_COMPLETION: self._llmresponse,
},
)
self._span.set_status(Status(StatusCode.OK))
@@ -217,8 +217,8 @@ def async_responses(version, environment, application_name,
attributes = create_metrics_attributes(
service_name=application_name,
deployment_environment=environment,
- operation=SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT,
- system=SemanticConvetion.GEN_AI_SYSTEM_OPENAI,
+ operation=SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
+ system=SemanticConvention.GEN_AI_SYSTEM_OPENAI,
request_model=request_model,
server_address=self._server_address,
server_port=self._server_port,
@@ -271,7 +271,7 @@ def async_responses(version, environment, application_name,
server_address, server_port = set_server_address_and_port(instance, "api.openai.com", 443)
request_model = kwargs.get("model", "gpt-4o")
- span_name = f"{SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT} {request_model}"
+ span_name = f"{SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT} {request_model}"
# pylint: disable=no-else-return
if streaming:
@@ -307,33 +307,33 @@ def async_responses(version, environment, application_name,
# Set base span attribues (OTel Semconv)
span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
- span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
- SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT)
- span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
- SemanticConvetion.GEN_AI_SYSTEM_OPENAI)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT)
+ span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
+ SemanticConvention.GEN_AI_SYSTEM_OPENAI)
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
request_model)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_SEED,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_SEED,
kwargs.get("seed", ""))
- span.set_attribute(SemanticConvetion.SERVER_PORT,
+ span.set_attribute(SemanticConvention.SERVER_PORT,
server_port)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MAX_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS,
kwargs.get("max_output_tokens", -1))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_STOP_SEQUENCES,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_STOP_SEQUENCES,
kwargs.get("stop", []))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TEMPERATURE,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TEMPERATURE,
str(response_dict.get("temperature", 1.0)))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TOP_P,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TOP_P,
str(response_dict.get("top_p", 1.0)))
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_ID,
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_ID,
response_dict.get("id"))
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL,
response_dict.get('model'))
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_INPUT_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS,
input_tokens)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_OUTPUT_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS,
output_tokens)
- span.set_attribute(SemanticConvetion.SERVER_ADDRESS,
+ span.set_attribute(SemanticConvention.SERVER_ADDRESS,
server_address)
# Set base span attribues (Extras)
@@ -341,29 +341,29 @@ def async_responses(version, environment, application_name,
environment)
span.set_attribute(SERVICE_NAME,
application_name)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_USER,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_USER,
kwargs.get("user", ""))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IS_STREAM,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM,
False)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_TOTAL_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS,
input_tokens + output_tokens)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST,
cost)
- span.set_attribute(SemanticConvetion.GEN_AI_SERVER_TTFT,
+ span.set_attribute(SemanticConvention.GEN_AI_SERVER_TTFT,
end_time - start_time)
- span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
+ span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION,
version)
if capture_message_content:
span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_PROMPT: prompt,
+ SemanticConvention.GEN_AI_CONTENT_PROMPT: prompt,
},
)
for i in range(kwargs.get('n',1)):
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_FINISH_REASON,
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON,
[response_dict.get('status')])
try:
llm_response = str(response_dict.get('output')[i].get('content')[0].get('text',''))
@@ -372,21 +372,21 @@ def async_responses(version, environment, application_name,
if capture_message_content:
span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_COMPLETION_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_COMPLETION_EVENT,
attributes={
# pylint: disable=line-too-long
- SemanticConvetion.GEN_AI_CONTENT_COMPLETION: llm_response,
+ SemanticConvention.GEN_AI_CONTENT_COMPLETION: llm_response,
},
)
if kwargs.get('tools'):
- span.set_attribute(SemanticConvetion.GEN_AI_TOOL_CALLS,
+ span.set_attribute(SemanticConvention.GEN_AI_TOOL_CALLS,
str(response_dict.get('tools')))
if isinstance(llm_response, str):
- span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
+ span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
"text")
elif llm_response is not None:
- span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
+ span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
"json")
span.set_status(Status(StatusCode.OK))
@@ -395,8 +395,8 @@ def async_responses(version, environment, application_name,
attributes = create_metrics_attributes(
service_name=application_name,
deployment_environment=environment,
- operation=SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT,
- system=SemanticConvetion.GEN_AI_SYSTEM_OPENAI,
+ operation=SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
+ system=SemanticConvention.GEN_AI_SYSTEM_OPENAI,
request_model=request_model,
server_address=server_address,
server_port=server_port,
@@ -566,51 +566,51 @@ def async_chat_completions(version, environment, application_name,
# Set Span attributes (OTel Semconv)
self._span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
- self._span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
- SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT)
- self._span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
- SemanticConvetion.GEN_AI_SYSTEM_OPENAI)
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
+ self._span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT)
+ self._span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
+ SemanticConvention.GEN_AI_SYSTEM_OPENAI)
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
request_model)
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_SEED,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_SEED,
self._kwargs.get("seed", ""))
- self._span.set_attribute(SemanticConvetion.SERVER_PORT,
+ self._span.set_attribute(SemanticConvention.SERVER_PORT,
self._server_port)
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_FREQUENCY_PENALTY,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_FREQUENCY_PENALTY,
self._kwargs.get("frequency_penalty", 0.0))
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MAX_TOKENS,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS,
self._kwargs.get("max_tokens", -1))
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_PRESENCE_PENALTY,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_PRESENCE_PENALTY,
self._kwargs.get("presence_penalty", 0.0))
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_STOP_SEQUENCES,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_STOP_SEQUENCES,
self._kwargs.get("stop", []))
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TEMPERATURE,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TEMPERATURE,
self._kwargs.get("temperature", 1.0))
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TOP_P,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TOP_P,
self._kwargs.get("top_p", 1.0))
- self._span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_FINISH_REASON,
+ self._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON,
[self._finish_reason])
- self._span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_ID,
+ self._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_ID,
self._response_id)
- self._span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_MODEL,
+ self._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL,
self._response_model)
- self._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_INPUT_TOKENS,
+ self._span.set_attribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS,
input_tokens)
- self._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_OUTPUT_TOKENS,
+ self._span.set_attribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS,
output_tokens)
- self._span.set_attribute(SemanticConvetion.SERVER_ADDRESS,
+ self._span.set_attribute(SemanticConvention.SERVER_ADDRESS,
self._server_address)
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_SERVICE_TIER,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_SERVICE_TIER,
self._kwargs.get("service_tier", "auto"))
- self._span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_SERVICE_TIER,
+ self._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_SERVICE_TIER,
self._openai_response_service_tier)
- self._span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_SYSTEM_FINGERPRINT,
+ self._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_SYSTEM_FINGERPRINT,
self._openai_system_fingerprint)
if isinstance(self._llmresponse, str):
- self._span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
+ self._span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
"text")
else:
- self._span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
+ self._span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
"json")
# Set Span attributes (Extra)
@@ -618,31 +618,31 @@ def async_chat_completions(version, environment, application_name,
environment)
self._span.set_attribute(SERVICE_NAME,
application_name)
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_USER,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_USER,
self._kwargs.get("user", ""))
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IS_STREAM,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM,
True)
- self._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_TOTAL_TOKENS,
+ self._span.set_attribute(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS,
input_tokens + output_tokens)
- self._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
+ self._span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST,
cost)
- self._span.set_attribute(SemanticConvetion.GEN_AI_SERVER_TBT,
+ self._span.set_attribute(SemanticConvention.GEN_AI_SERVER_TBT,
self._tbt)
- self._span.set_attribute(SemanticConvetion.GEN_AI_SERVER_TTFT,
+ self._span.set_attribute(SemanticConvention.GEN_AI_SERVER_TTFT,
self._ttft)
- self._span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
+ self._span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION,
version)
if capture_message_content:
self._span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_PROMPT: prompt,
+ SemanticConvention.GEN_AI_CONTENT_PROMPT: prompt,
},
)
self._span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_COMPLETION_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_COMPLETION_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_COMPLETION: self._llmresponse,
+ SemanticConvention.GEN_AI_CONTENT_COMPLETION: self._llmresponse,
},
)
self._span.set_status(Status(StatusCode.OK))
@@ -651,8 +651,8 @@ def async_chat_completions(version, environment, application_name,
attributes = create_metrics_attributes(
service_name=application_name,
deployment_environment=environment,
- operation=SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT,
- system=SemanticConvetion.GEN_AI_SYSTEM_OPENAI,
+ operation=SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
+ system=SemanticConvention.GEN_AI_SYSTEM_OPENAI,
request_model=request_model,
server_address=self._server_address,
server_port=self._server_port,
@@ -705,7 +705,7 @@ def async_chat_completions(version, environment, application_name,
server_address, server_port = set_server_address_and_port(instance, "api.openai.com", 443)
request_model = kwargs.get("model", "gpt-4o")
- span_name = f"{SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT} {request_model}"
+ span_name = f"{SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT} {request_model}"
# pylint: disable=no-else-return
if streaming:
@@ -753,43 +753,43 @@ def async_chat_completions(version, environment, application_name,
# Set base span attribues (OTel Semconv)
span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
- span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
- SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT)
- span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
- SemanticConvetion.GEN_AI_SYSTEM_OPENAI)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT)
+ span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
+ SemanticConvention.GEN_AI_SYSTEM_OPENAI)
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
request_model)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_SEED,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_SEED,
kwargs.get("seed", ""))
- span.set_attribute(SemanticConvetion.SERVER_PORT,
+ span.set_attribute(SemanticConvention.SERVER_PORT,
server_port)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_FREQUENCY_PENALTY,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_FREQUENCY_PENALTY,
kwargs.get("frequency_penalty", 0.0))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MAX_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS,
kwargs.get("max_tokens", -1))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_PRESENCE_PENALTY,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_PRESENCE_PENALTY,
kwargs.get("presence_penalty", 0.0))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_STOP_SEQUENCES,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_STOP_SEQUENCES,
kwargs.get("stop", []))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TEMPERATURE,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TEMPERATURE,
kwargs.get("temperature", 1.0))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TOP_P,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TOP_P,
kwargs.get("top_p", 1.0))
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_ID,
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_ID,
response_dict.get("id"))
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL,
response_dict.get('model'))
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_INPUT_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS,
input_tokens)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_OUTPUT_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS,
output_tokens)
- span.set_attribute(SemanticConvetion.SERVER_ADDRESS,
+ span.set_attribute(SemanticConvention.SERVER_ADDRESS,
server_address)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_SERVICE_TIER,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_SERVICE_TIER,
kwargs.get("service_tier", "auto"))
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_SERVICE_TIER,
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_SERVICE_TIER,
response_dict.get('service_tier', 'auto'))
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_SYSTEM_FINGERPRINT,
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_SYSTEM_FINGERPRINT,
response_dict.get('system_fingerprint', ''))
# Set base span attribues (Extras)
@@ -797,46 +797,46 @@ def async_chat_completions(version, environment, application_name,
environment)
span.set_attribute(SERVICE_NAME,
application_name)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_USER,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_USER,
kwargs.get("user", ""))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IS_STREAM,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM,
False)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_TOTAL_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS,
input_tokens + output_tokens)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST,
cost)
- span.set_attribute(SemanticConvetion.GEN_AI_SERVER_TTFT,
+ span.set_attribute(SemanticConvention.GEN_AI_SERVER_TTFT,
end_time - start_time)
- span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
+ span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION,
version)
if capture_message_content:
span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_PROMPT: prompt,
+ SemanticConvention.GEN_AI_CONTENT_PROMPT: prompt,
},
)
for i in range(kwargs.get('n',1)):
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_FINISH_REASON,
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON,
[response_dict.get('choices')[i].get('finish_reason')])
if capture_message_content:
span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_COMPLETION_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_COMPLETION_EVENT,
attributes={
# pylint: disable=line-too-long
- SemanticConvetion.GEN_AI_CONTENT_COMPLETION: str(response_dict.get('choices')[i].get('message').get('content')),
+ SemanticConvention.GEN_AI_CONTENT_COMPLETION: str(response_dict.get('choices')[i].get('message').get('content')),
},
)
if kwargs.get('tools'):
- span.set_attribute(SemanticConvetion.GEN_AI_TOOL_CALLS,
+ span.set_attribute(SemanticConvention.GEN_AI_TOOL_CALLS,
str(response_dict.get('choices')[i].get('message').get('tool_calls')))
if isinstance(response_dict.get('choices')[i].get('message').get('content'), str):
- span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
+ span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
"text")
elif response_dict.get('choices')[i].get('message').get('content') is not None:
- span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
+ span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
"json")
span.set_status(Status(StatusCode.OK))
@@ -845,8 +845,8 @@ def async_chat_completions(version, environment, application_name,
attributes = create_metrics_attributes(
service_name=application_name,
deployment_environment=environment,
- operation=SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT,
- system=SemanticConvetion.GEN_AI_SYSTEM_OPENAI,
+ operation=SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
+ system=SemanticConvention.GEN_AI_SYSTEM_OPENAI,
request_model=request_model,
server_address=server_address,
server_port=server_port,
@@ -916,7 +916,7 @@ def async_embedding(version, environment, application_name,
server_address, server_port = set_server_address_and_port(instance, "api.openai.com", 443)
request_model = kwargs.get("model", "text-embedding-ada-002")
- span_name = f"{SemanticConvetion.GEN_AI_OPERATION_TYPE_EMBEDDING} {request_model}"
+ span_name = f"{SemanticConvention.GEN_AI_OPERATION_TYPE_EMBEDDING} {request_model}"
with tracer.start_as_current_span(span_name, kind= SpanKind.CLIENT) as span:
start_time = time.time()
@@ -933,21 +933,21 @@ def async_embedding(version, environment, application_name,
# Set Span attributes (OTel Semconv)
span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
- span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
- SemanticConvetion.GEN_AI_OPERATION_TYPE_EMBEDDING)
- span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
- SemanticConvetion.GEN_AI_SYSTEM_OPENAI)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_EMBEDDING)
+ span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
+ SemanticConvention.GEN_AI_SYSTEM_OPENAI)
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
request_model)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_ENCODING_FORMATS,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_ENCODING_FORMATS,
[kwargs.get('encoding_format', 'float')])
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL,
request_model)
- span.set_attribute(SemanticConvetion.SERVER_ADDRESS,
+ span.set_attribute(SemanticConvention.SERVER_ADDRESS,
server_address)
- span.set_attribute(SemanticConvetion.SERVER_PORT,
+ span.set_attribute(SemanticConvention.SERVER_PORT,
server_port)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_INPUT_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS,
input_tokens)
# Set Span attributes (Extras)
@@ -955,20 +955,20 @@ def async_embedding(version, environment, application_name,
environment)
span.set_attribute(SERVICE_NAME,
application_name)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_USER,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_USER,
kwargs.get("user", ""))
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_TOTAL_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS,
input_tokens)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST,
cost)
- span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
+ span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION,
version)
if capture_message_content:
span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_PROMPT: str(kwargs.get("input", "")),
+ SemanticConvention.GEN_AI_CONTENT_PROMPT: str(kwargs.get("input", "")),
},
)
@@ -978,8 +978,8 @@ def async_embedding(version, environment, application_name,
attributes = create_metrics_attributes(
service_name=application_name,
deployment_environment=environment,
- operation=SemanticConvetion.GEN_AI_OPERATION_TYPE_EMBEDDING,
- system=SemanticConvetion.GEN_AI_SYSTEM_OPENAI,
+ operation=SemanticConvention.GEN_AI_OPERATION_TYPE_EMBEDDING,
+ system=SemanticConvention.GEN_AI_SYSTEM_OPENAI,
request_model=request_model,
server_address=server_address,
server_port=server_port,
@@ -1044,7 +1044,7 @@ def async_image_generate(version, environment, application_name,
server_address, server_port = set_server_address_and_port(instance, "api.openai.com", 443)
request_model = kwargs.get("model", "dall-e-2")
- span_name = f"{SemanticConvetion.GEN_AI_OPERATION_TYPE_IMAGE} {request_model}"
+ span_name = f"{SemanticConvention.GEN_AI_OPERATION_TYPE_IMAGE} {request_model}"
with tracer.start_as_current_span(span_name, kind= SpanKind.CLIENT) as span:
start_time = time.time()
@@ -1068,21 +1068,21 @@ def async_image_generate(version, environment, application_name,
for items in response.data:
# Set Span attributes (OTel Semconv)
span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
- span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
- SemanticConvetion.GEN_AI_OPERATION_TYPE_IMAGE)
- span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
- SemanticConvetion.GEN_AI_SYSTEM_OPENAI)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_IMAGE)
+ span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
+ SemanticConvention.GEN_AI_SYSTEM_OPENAI)
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
request_model)
- span.set_attribute(SemanticConvetion.SERVER_ADDRESS,
+ span.set_attribute(SemanticConvention.SERVER_ADDRESS,
server_address)
- span.set_attribute(SemanticConvetion.SERVER_PORT,
+ span.set_attribute(SemanticConvention.SERVER_PORT,
server_port)
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_ID,
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_ID,
response.created)
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL,
request_model)
- span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
+ span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
"image")
# Set Span attributes (Extras)
@@ -1090,37 +1090,37 @@ def async_image_generate(version, environment, application_name,
environment)
span.set_attribute(SERVICE_NAME,
application_name)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IMAGE_SIZE,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_IMAGE_SIZE,
kwargs.get("size", "1024x1024"))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IMAGE_QUALITY,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_IMAGE_QUALITY,
kwargs.get("quality", "standard"))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IMAGE_STYLE,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_IMAGE_STYLE,
kwargs.get("style", "vivid"))
- span.set_attribute(SemanticConvetion.GEN_AI_CONTENT_REVISED_PROMPT,
+ span.set_attribute(SemanticConvention.GEN_AI_CONTENT_REVISED_PROMPT,
items.revised_prompt if items.revised_prompt else "")
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_USER,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_USER,
kwargs.get("user", ""))
- span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
+ span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION,
version)
if capture_message_content:
span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_PROMPT: kwargs.get("prompt", ""),
+ SemanticConvention.GEN_AI_CONTENT_PROMPT: kwargs.get("prompt", ""),
},
)
- attribute_name = f"{SemanticConvetion.GEN_AI_RESPONSE_IMAGE}.{images_count}"
+ attribute_name = f"{SemanticConvention.GEN_AI_RESPONSE_IMAGE}.{images_count}"
span.add_event(
name=attribute_name,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_COMPLETION: getattr(items, image),
+ SemanticConvention.GEN_AI_CONTENT_COMPLETION: getattr(items, image),
},
)
images_count+=1
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST,
len(response.data) * cost)
span.set_status(Status(StatusCode.OK))
@@ -1128,8 +1128,8 @@ def async_image_generate(version, environment, application_name,
attributes = create_metrics_attributes(
service_name=application_name,
deployment_environment=environment,
- operation=SemanticConvetion.GEN_AI_OPERATION_TYPE_IMAGE,
- system=SemanticConvetion.GEN_AI_SYSTEM_OPENAI,
+ operation=SemanticConvention.GEN_AI_OPERATION_TYPE_IMAGE,
+ system=SemanticConvention.GEN_AI_SYSTEM_OPENAI,
request_model=request_model,
server_address=server_address,
server_port=server_port,
@@ -1191,7 +1191,7 @@ def async_image_variatons(version, environment, application_name,
server_address, server_port = set_server_address_and_port(instance, "api.openai.com", 443)
request_model = kwargs.get("model", "dall-e-2")
- span_name = f"{SemanticConvetion.GEN_AI_OPERATION_TYPE_IMAGE} {request_model}"
+ span_name = f"{SemanticConvention.GEN_AI_OPERATION_TYPE_IMAGE} {request_model}"
with tracer.start_as_current_span(span_name, kind= SpanKind.CLIENT) as span:
start_time = time.time()
@@ -1214,21 +1214,21 @@ def async_image_variatons(version, environment, application_name,
for items in response.data:
# Set Span attributes (OTel Semconv)
span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
- span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
- SemanticConvetion.GEN_AI_OPERATION_TYPE_IMAGE)
- span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
- SemanticConvetion.GEN_AI_SYSTEM_OPENAI)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_IMAGE)
+ span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
+ SemanticConvention.GEN_AI_SYSTEM_OPENAI)
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
request_model)
- span.set_attribute(SemanticConvetion.SERVER_ADDRESS,
+ span.set_attribute(SemanticConvention.SERVER_ADDRESS,
server_address)
- span.set_attribute(SemanticConvetion.SERVER_PORT,
+ span.set_attribute(SemanticConvention.SERVER_PORT,
server_port)
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_ID,
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_ID,
response.created)
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL,
request_model)
- span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
+ span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
"image")
# Set Span attributes (Extras)
@@ -1236,27 +1236,27 @@ def async_image_variatons(version, environment, application_name,
environment)
span.set_attribute(SERVICE_NAME,
application_name)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IMAGE_SIZE,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_IMAGE_SIZE,
kwargs.get("size", "1024x1024"))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IMAGE_QUALITY,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_IMAGE_QUALITY,
"standard")
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_USER,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_USER,
kwargs.get("user", ""))
- span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
+ span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION,
version)
if capture_message_content:
- attribute_name = f"{SemanticConvetion.GEN_AI_RESPONSE_IMAGE}.{images_count}"
+ attribute_name = f"{SemanticConvention.GEN_AI_RESPONSE_IMAGE}.{images_count}"
span.add_event(
name=attribute_name,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_COMPLETION: getattr(items, image),
+ SemanticConvention.GEN_AI_CONTENT_COMPLETION: getattr(items, image),
},
)
images_count+=1
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST,
len(response.data) * cost)
span.set_status(Status(StatusCode.OK))
@@ -1264,8 +1264,8 @@ def async_image_variatons(version, environment, application_name,
attributes = create_metrics_attributes(
service_name=application_name,
deployment_environment=environment,
- operation=SemanticConvetion.GEN_AI_OPERATION_TYPE_IMAGE,
- system=SemanticConvetion.GEN_AI_SYSTEM_OPENAI,
+ operation=SemanticConvention.GEN_AI_OPERATION_TYPE_IMAGE,
+ system=SemanticConvention.GEN_AI_SYSTEM_OPENAI,
request_model=request_model,
server_address=server_address,
server_port=server_port,
@@ -1327,7 +1327,7 @@ def async_audio_create(version, environment, application_name,
server_address, server_port = set_server_address_and_port(instance, "api.openai.com", 443)
request_model = kwargs.get("model", "tts-1")
- span_name = f"{SemanticConvetion.GEN_AI_OPERATION_TYPE_AUDIO} {request_model}"
+ span_name = f"{SemanticConvention.GEN_AI_OPERATION_TYPE_AUDIO} {request_model}"
with tracer.start_as_current_span(span_name, kind=SpanKind.CLIENT) as span:
start_time = time.time()
@@ -1341,40 +1341,40 @@ def async_audio_create(version, environment, application_name,
# Set Span attributes
span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
- span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
- SemanticConvetion.GEN_AI_OPERATION_TYPE_AUDIO)
- span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
- SemanticConvetion.GEN_AI_SYSTEM_OPENAI)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_AUDIO)
+ span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
+ SemanticConvention.GEN_AI_SYSTEM_OPENAI)
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
request_model)
- span.set_attribute(SemanticConvetion.SERVER_ADDRESS,
+ span.set_attribute(SemanticConvention.SERVER_ADDRESS,
server_address)
- span.set_attribute(SemanticConvetion.SERVER_PORT,
+ span.set_attribute(SemanticConvention.SERVER_PORT,
server_port)
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL,
request_model)
- span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
+ span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
"speech")
span.set_attribute(DEPLOYMENT_ENVIRONMENT,
environment)
span.set_attribute(SERVICE_NAME,
application_name)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_AUDIO_VOICE,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_AUDIO_VOICE,
kwargs.get("voice", "alloy"))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_AUDIO_RESPONSE_FORMAT,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_AUDIO_RESPONSE_FORMAT,
kwargs.get("response_format", "mp3"))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_AUDIO_SPEED,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_AUDIO_SPEED,
kwargs.get("speed", 1))
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST,
cost)
- span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
+ span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION,
version)
if capture_message_content:
span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_PROMPT: kwargs.get("input", ""),
+ SemanticConvention.GEN_AI_CONTENT_PROMPT: kwargs.get("input", ""),
},
)
@@ -1384,8 +1384,8 @@ def async_audio_create(version, environment, application_name,
attributes = create_metrics_attributes(
service_name=application_name,
deployment_environment=environment,
- operation=SemanticConvetion.GEN_AI_OPERATION_TYPE_AUDIO,
- system=SemanticConvetion.GEN_AI_SYSTEM_OPENAI,
+ operation=SemanticConvention.GEN_AI_OPERATION_TYPE_AUDIO,
+ system=SemanticConvention.GEN_AI_SYSTEM_OPENAI,
request_model=request_model,
server_address=server_address,
server_port=server_port,
diff --git a/sdk/python/src/openlit/instrumentation/openai/openai.py b/sdk/python/src/openlit/instrumentation/openai/openai.py
index 5e741bd5..573a9d8e 100644
--- a/sdk/python/src/openlit/instrumentation/openai/openai.py
+++ b/sdk/python/src/openlit/instrumentation/openai/openai.py
@@ -21,7 +21,7 @@ from openlit.__helpers import (
create_metrics_attributes,
set_server_address_and_port
)
-from openlit.semcov import SemanticConvetion
+from openlit.semcov import SemanticConvention
# Initialize logger for logging potential issues and operations
logger = logging.getLogger(__name__)
@@ -141,41 +141,41 @@ def responses(version, environment, application_name,
# Set Span attributes (OTel Semconv)
self._span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
- self._span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
- SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT)
- self._span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
- SemanticConvetion.GEN_AI_SYSTEM_OPENAI)
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
+ self._span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT)
+ self._span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
+ SemanticConvention.GEN_AI_SYSTEM_OPENAI)
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
request_model)
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_SEED,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_SEED,
self._kwargs.get("seed", ""))
- self._span.set_attribute(SemanticConvetion.SERVER_PORT,
+ self._span.set_attribute(SemanticConvention.SERVER_PORT,
self._server_port)
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MAX_TOKENS,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS,
self._kwargs.get("max_output_tokens", -1))
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_STOP_SEQUENCES,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_STOP_SEQUENCES,
self._kwargs.get("stop", []))
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TEMPERATURE,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TEMPERATURE,
self._kwargs.get("temperature", 1.0))
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TOP_P,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TOP_P,
self._kwargs.get("top_p", 1.0))
- self._span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_FINISH_REASON,
+ self._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON,
[self._finish_reason])
- self._span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_ID,
+ self._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_ID,
self._response_id)
- self._span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_MODEL,
+ self._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL,
self._response_model)
- self._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_INPUT_TOKENS,
+ self._span.set_attribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS,
self._input_tokens)
- self._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_OUTPUT_TOKENS,
+ self._span.set_attribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS,
self._output_tokens)
- self._span.set_attribute(SemanticConvetion.SERVER_ADDRESS,
+ self._span.set_attribute(SemanticConvention.SERVER_ADDRESS,
self._server_address)
if isinstance(self._llmresponse, str):
- self._span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
+ self._span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
"text")
else:
- self._span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
+ self._span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
"json")
# Set Span attributes (Extra)
@@ -183,32 +183,32 @@ def responses(version, environment, application_name,
environment)
self._span.set_attribute(SERVICE_NAME,
application_name)
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_USER,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_USER,
self._kwargs.get("user", ""))
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IS_STREAM,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM,
True)
- self._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_TOTAL_TOKENS,
+ self._span.set_attribute(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS,
self._input_tokens + self._output_tokens)
- self._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
+ self._span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST,
cost)
- self._span.set_attribute(SemanticConvetion.GEN_AI_SERVER_TBT,
+ self._span.set_attribute(SemanticConvention.GEN_AI_SERVER_TBT,
self._tbt)
- self._span.set_attribute(SemanticConvetion.GEN_AI_SERVER_TTFT,
+ self._span.set_attribute(SemanticConvention.GEN_AI_SERVER_TTFT,
self._ttft)
- self._span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
+ self._span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION,
version)
if capture_message_content:
self._span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_PROMPT: prompt,
+ SemanticConvention.GEN_AI_CONTENT_PROMPT: prompt,
},
)
self._span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_COMPLETION_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_COMPLETION_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_COMPLETION: self._llmresponse,
+ SemanticConvention.GEN_AI_CONTENT_COMPLETION: self._llmresponse,
},
)
self._span.set_status(Status(StatusCode.OK))
@@ -217,8 +217,8 @@ def responses(version, environment, application_name,
attributes = create_metrics_attributes(
service_name=application_name,
deployment_environment=environment,
- operation=SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT,
- system=SemanticConvetion.GEN_AI_SYSTEM_OPENAI,
+ operation=SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
+ system=SemanticConvention.GEN_AI_SYSTEM_OPENAI,
request_model=request_model,
server_address=self._server_address,
server_port=self._server_port,
@@ -271,7 +271,7 @@ def responses(version, environment, application_name,
server_address, server_port = set_server_address_and_port(instance, "api.openai.com", 443)
request_model = kwargs.get("model", "gpt-4o")
- span_name = f"{SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT} {request_model}"
+ span_name = f"{SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT} {request_model}"
# pylint: disable=no-else-return
if streaming:
@@ -307,33 +307,33 @@ def responses(version, environment, application_name,
# Set base span attribues (OTel Semconv)
span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
- span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
- SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT)
- span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
- SemanticConvetion.GEN_AI_SYSTEM_OPENAI)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT)
+ span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
+ SemanticConvention.GEN_AI_SYSTEM_OPENAI)
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
request_model)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_SEED,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_SEED,
kwargs.get("seed", ""))
- span.set_attribute(SemanticConvetion.SERVER_PORT,
+ span.set_attribute(SemanticConvention.SERVER_PORT,
server_port)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MAX_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS,
kwargs.get("max_output_tokens", -1))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_STOP_SEQUENCES,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_STOP_SEQUENCES,
kwargs.get("stop", []))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TEMPERATURE,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TEMPERATURE,
str(response_dict.get("temperature", 1.0)))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TOP_P,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TOP_P,
str(response_dict.get("top_p", 1.0)))
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_ID,
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_ID,
response_dict.get("id"))
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL,
response_dict.get('model'))
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_INPUT_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS,
input_tokens)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_OUTPUT_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS,
output_tokens)
- span.set_attribute(SemanticConvetion.SERVER_ADDRESS,
+ span.set_attribute(SemanticConvention.SERVER_ADDRESS,
server_address)
# Set base span attribues (Extras)
@@ -341,29 +341,29 @@ def responses(version, environment, application_name,
environment)
span.set_attribute(SERVICE_NAME,
application_name)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_USER,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_USER,
kwargs.get("user", ""))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IS_STREAM,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM,
False)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_TOTAL_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS,
input_tokens + output_tokens)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST,
cost)
- span.set_attribute(SemanticConvetion.GEN_AI_SERVER_TTFT,
+ span.set_attribute(SemanticConvention.GEN_AI_SERVER_TTFT,
end_time - start_time)
- span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
+ span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION,
version)
if capture_message_content:
span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_PROMPT: prompt,
+ SemanticConvention.GEN_AI_CONTENT_PROMPT: prompt,
},
)
for i in range(kwargs.get('n',1)):
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_FINISH_REASON,
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON,
[response_dict.get('status')])
try:
llm_response = response_dict.get('output')[i].get('content')[0].get('text','')
@@ -372,21 +372,21 @@ def responses(version, environment, application_name,
if capture_message_content:
span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_COMPLETION_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_COMPLETION_EVENT,
attributes={
# pylint: disable=line-too-long
- SemanticConvetion.GEN_AI_CONTENT_COMPLETION: llm_response,
+ SemanticConvention.GEN_AI_CONTENT_COMPLETION: llm_response,
},
)
if kwargs.get('tools'):
- span.set_attribute(SemanticConvetion.GEN_AI_TOOL_CALLS,
+ span.set_attribute(SemanticConvention.GEN_AI_TOOL_CALLS,
str(response_dict.get('tools')))
if isinstance(llm_response, str):
- span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
+ span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
"text")
elif llm_response is not None:
- span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
+ span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
"json")
span.set_status(Status(StatusCode.OK))
@@ -395,8 +395,8 @@ def responses(version, environment, application_name,
attributes = create_metrics_attributes(
service_name=application_name,
deployment_environment=environment,
- operation=SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT,
- system=SemanticConvetion.GEN_AI_SYSTEM_OPENAI,
+ operation=SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
+ system=SemanticConvention.GEN_AI_SYSTEM_OPENAI,
request_model=request_model,
server_address=server_address,
server_port=server_port,
@@ -566,51 +566,51 @@ def chat_completions(version, environment, application_name,
# Set Span attributes (OTel Semconv)
self._span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
- self._span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
- SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT)
- self._span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
- SemanticConvetion.GEN_AI_SYSTEM_OPENAI)
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
+ self._span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT)
+ self._span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
+ SemanticConvention.GEN_AI_SYSTEM_OPENAI)
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
request_model)
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_SEED,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_SEED,
self._kwargs.get("seed", ""))
- self._span.set_attribute(SemanticConvetion.SERVER_PORT,
+ self._span.set_attribute(SemanticConvention.SERVER_PORT,
self._server_port)
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_FREQUENCY_PENALTY,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_FREQUENCY_PENALTY,
self._kwargs.get("frequency_penalty", 0.0))
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MAX_TOKENS,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS,
self._kwargs.get("max_tokens", -1))
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_PRESENCE_PENALTY,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_PRESENCE_PENALTY,
self._kwargs.get("presence_penalty", 0.0))
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_STOP_SEQUENCES,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_STOP_SEQUENCES,
self._kwargs.get("stop", []))
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TEMPERATURE,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TEMPERATURE,
self._kwargs.get("temperature", 1.0))
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TOP_P,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TOP_P,
self._kwargs.get("top_p", 1.0))
- self._span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_FINISH_REASON,
+ self._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON,
[self._finish_reason])
- self._span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_ID,
+ self._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_ID,
self._response_id)
- self._span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_MODEL,
+ self._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL,
self._response_model)
- self._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_INPUT_TOKENS,
+ self._span.set_attribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS,
input_tokens)
- self._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_OUTPUT_TOKENS,
+ self._span.set_attribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS,
output_tokens)
- self._span.set_attribute(SemanticConvetion.SERVER_ADDRESS,
+ self._span.set_attribute(SemanticConvention.SERVER_ADDRESS,
self._server_address)
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_SERVICE_TIER,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_SERVICE_TIER,
self._kwargs.get("service_tier", "auto"))
- self._span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_SERVICE_TIER,
+ self._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_SERVICE_TIER,
self._openai_response_service_tier)
- self._span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_SYSTEM_FINGERPRINT,
+ self._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_SYSTEM_FINGERPRINT,
self._openai_system_fingerprint)
if isinstance(self._llmresponse, str):
- self._span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
+ self._span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
"text")
else:
- self._span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
+ self._span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
"json")
# Set Span attributes (Extra)
@@ -618,31 +618,31 @@ def chat_completions(version, environment, application_name,
environment)
self._span.set_attribute(SERVICE_NAME,
application_name)
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_USER,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_USER,
self._kwargs.get("user", ""))
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IS_STREAM,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM,
True)
- self._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_TOTAL_TOKENS,
+ self._span.set_attribute(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS,
input_tokens + output_tokens)
- self._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
+ self._span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST,
cost)
- self._span.set_attribute(SemanticConvetion.GEN_AI_SERVER_TBT,
+ self._span.set_attribute(SemanticConvention.GEN_AI_SERVER_TBT,
self._tbt)
- self._span.set_attribute(SemanticConvetion.GEN_AI_SERVER_TTFT,
+ self._span.set_attribute(SemanticConvention.GEN_AI_SERVER_TTFT,
self._ttft)
- self._span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
+ self._span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION,
version)
if capture_message_content:
self._span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_PROMPT: prompt,
+ SemanticConvention.GEN_AI_CONTENT_PROMPT: prompt,
},
)
self._span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_COMPLETION_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_COMPLETION_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_COMPLETION: self._llmresponse,
+ SemanticConvention.GEN_AI_CONTENT_COMPLETION: self._llmresponse,
},
)
self._span.set_status(Status(StatusCode.OK))
@@ -651,8 +651,8 @@ def chat_completions(version, environment, application_name,
attributes = create_metrics_attributes(
service_name=application_name,
deployment_environment=environment,
- operation=SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT,
- system=SemanticConvetion.GEN_AI_SYSTEM_OPENAI,
+ operation=SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
+ system=SemanticConvention.GEN_AI_SYSTEM_OPENAI,
request_model=request_model,
server_address=self._server_address,
server_port=self._server_port,
@@ -705,7 +705,7 @@ def chat_completions(version, environment, application_name,
server_address, server_port = set_server_address_and_port(instance, "api.openai.com", 443)
request_model = kwargs.get("model", "gpt-4o")
- span_name = f"{SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT} {request_model}"
+ span_name = f"{SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT} {request_model}"
# pylint: disable=no-else-return
if streaming:
@@ -753,43 +753,43 @@ def chat_completions(version, environment, application_name,
# Set base span attribues (OTel Semconv)
span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
- span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
- SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT)
- span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
- SemanticConvetion.GEN_AI_SYSTEM_OPENAI)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT)
+ span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
+ SemanticConvention.GEN_AI_SYSTEM_OPENAI)
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
request_model)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_SEED,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_SEED,
kwargs.get("seed", ""))
- span.set_attribute(SemanticConvetion.SERVER_PORT,
+ span.set_attribute(SemanticConvention.SERVER_PORT,
server_port)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_FREQUENCY_PENALTY,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_FREQUENCY_PENALTY,
kwargs.get("frequency_penalty", 0.0))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MAX_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS,
kwargs.get("max_tokens", -1))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_PRESENCE_PENALTY,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_PRESENCE_PENALTY,
kwargs.get("presence_penalty", 0.0))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_STOP_SEQUENCES,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_STOP_SEQUENCES,
kwargs.get("stop", []))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TEMPERATURE,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TEMPERATURE,
kwargs.get("temperature", 1.0))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TOP_P,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TOP_P,
kwargs.get("top_p", 1.0))
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_ID,
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_ID,
response_dict.get("id"))
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL,
response_dict.get('model'))
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_INPUT_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS,
input_tokens)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_OUTPUT_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS,
output_tokens)
- span.set_attribute(SemanticConvetion.SERVER_ADDRESS,
+ span.set_attribute(SemanticConvention.SERVER_ADDRESS,
server_address)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_SERVICE_TIER,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_SERVICE_TIER,
kwargs.get("service_tier", "auto"))
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_SERVICE_TIER,
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_SERVICE_TIER,
response_dict.get('service_tier', 'auto'))
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_SYSTEM_FINGERPRINT,
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_SYSTEM_FINGERPRINT,
str(response_dict.get('system_fingerprint', '')))
# Set base span attribues (Extras)
@@ -797,46 +797,46 @@ def chat_completions(version, environment, application_name,
environment)
span.set_attribute(SERVICE_NAME,
application_name)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_USER,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_USER,
kwargs.get("user", ""))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IS_STREAM,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM,
False)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_TOTAL_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS,
input_tokens + output_tokens)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST,
cost)
- span.set_attribute(SemanticConvetion.GEN_AI_SERVER_TTFT,
+ span.set_attribute(SemanticConvention.GEN_AI_SERVER_TTFT,
end_time - start_time)
- span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
+ span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION,
version)
if capture_message_content:
span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_PROMPT: prompt,
+ SemanticConvention.GEN_AI_CONTENT_PROMPT: prompt,
},
)
for i in range(kwargs.get('n',1)):
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_FINISH_REASON,
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON,
[response_dict.get('choices')[i].get('finish_reason')])
if capture_message_content:
span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_COMPLETION_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_COMPLETION_EVENT,
attributes={
# pylint: disable=line-too-long
- SemanticConvetion.GEN_AI_CONTENT_COMPLETION: str(response_dict.get('choices')[i].get('message').get('content')),
+ SemanticConvention.GEN_AI_CONTENT_COMPLETION: str(response_dict.get('choices')[i].get('message').get('content')),
},
)
if kwargs.get('tools'):
- span.set_attribute(SemanticConvetion.GEN_AI_TOOL_CALLS,
+ span.set_attribute(SemanticConvention.GEN_AI_TOOL_CALLS,
str(response_dict.get('choices')[i].get('message').get('tool_calls')))
if isinstance(response_dict.get('choices')[i].get('message').get('content'), str):
- span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
+ span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
"text")
elif response_dict.get('choices')[i].get('message').get('content') is not None:
- span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
+ span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
"json")
span.set_status(Status(StatusCode.OK))
@@ -845,8 +845,8 @@ def chat_completions(version, environment, application_name,
attributes = create_metrics_attributes(
service_name=application_name,
deployment_environment=environment,
- operation=SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT,
- system=SemanticConvetion.GEN_AI_SYSTEM_OPENAI,
+ operation=SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
+ system=SemanticConvention.GEN_AI_SYSTEM_OPENAI,
request_model=request_model,
server_address=server_address,
server_port=server_port,
@@ -916,7 +916,7 @@ def embedding(version, environment, application_name,
server_address, server_port = set_server_address_and_port(instance, "api.openai.com", 443)
request_model = kwargs.get("model", "text-embedding-ada-002")
- span_name = f"{SemanticConvetion.GEN_AI_OPERATION_TYPE_EMBEDDING} {request_model}"
+ span_name = f"{SemanticConvention.GEN_AI_OPERATION_TYPE_EMBEDDING} {request_model}"
with tracer.start_as_current_span(span_name, kind= SpanKind.CLIENT) as span:
start_time = time.time()
@@ -933,21 +933,21 @@ def embedding(version, environment, application_name,
# Set Span attributes (OTel Semconv)
span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
- span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
- SemanticConvetion.GEN_AI_OPERATION_TYPE_EMBEDDING)
- span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
- SemanticConvetion.GEN_AI_SYSTEM_OPENAI)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_EMBEDDING)
+ span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
+ SemanticConvention.GEN_AI_SYSTEM_OPENAI)
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
request_model)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_ENCODING_FORMATS,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_ENCODING_FORMATS,
[kwargs.get('encoding_format', 'float')])
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL,
request_model)
- span.set_attribute(SemanticConvetion.SERVER_ADDRESS,
+ span.set_attribute(SemanticConvention.SERVER_ADDRESS,
server_address)
- span.set_attribute(SemanticConvetion.SERVER_PORT,
+ span.set_attribute(SemanticConvention.SERVER_PORT,
server_port)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_INPUT_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS,
input_tokens)
# Set Span attributes (Extras)
@@ -955,20 +955,20 @@ def embedding(version, environment, application_name,
environment)
span.set_attribute(SERVICE_NAME,
application_name)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_USER,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_USER,
kwargs.get("user", ""))
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_TOTAL_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS,
input_tokens)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST,
cost)
- span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
+ span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION,
version)
if capture_message_content:
span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_PROMPT: str(kwargs.get("input", "")),
+ SemanticConvention.GEN_AI_CONTENT_PROMPT: str(kwargs.get("input", "")),
},
)
@@ -978,8 +978,8 @@ def embedding(version, environment, application_name,
attributes = create_metrics_attributes(
service_name=application_name,
deployment_environment=environment,
- operation=SemanticConvetion.GEN_AI_OPERATION_TYPE_EMBEDDING,
- system=SemanticConvetion.GEN_AI_SYSTEM_OPENAI,
+ operation=SemanticConvention.GEN_AI_OPERATION_TYPE_EMBEDDING,
+ system=SemanticConvention.GEN_AI_SYSTEM_OPENAI,
request_model=request_model,
server_address=server_address,
server_port=server_port,
@@ -1044,7 +1044,7 @@ def image_generate(version, environment, application_name,
server_address, server_port = set_server_address_and_port(instance, "api.openai.com", 443)
request_model = kwargs.get("model", "dall-e-2")
- span_name = f"{SemanticConvetion.GEN_AI_OPERATION_TYPE_IMAGE} {request_model}"
+ span_name = f"{SemanticConvention.GEN_AI_OPERATION_TYPE_IMAGE} {request_model}"
with tracer.start_as_current_span(span_name, kind= SpanKind.CLIENT) as span:
start_time = time.time()
@@ -1068,21 +1068,21 @@ def image_generate(version, environment, application_name,
for items in response.data:
# Set Span attributes (OTel Semconv)
span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
- span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
- SemanticConvetion.GEN_AI_OPERATION_TYPE_IMAGE)
- span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
- SemanticConvetion.GEN_AI_SYSTEM_OPENAI)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_IMAGE)
+ span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
+ SemanticConvention.GEN_AI_SYSTEM_OPENAI)
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
request_model)
- span.set_attribute(SemanticConvetion.SERVER_ADDRESS,
+ span.set_attribute(SemanticConvention.SERVER_ADDRESS,
server_address)
- span.set_attribute(SemanticConvetion.SERVER_PORT,
+ span.set_attribute(SemanticConvention.SERVER_PORT,
server_port)
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_ID,
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_ID,
response.created)
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL,
request_model)
- span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
+ span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
"image")
# Set Span attributes (Extras)
@@ -1090,37 +1090,37 @@ def image_generate(version, environment, application_name,
environment)
span.set_attribute(SERVICE_NAME,
application_name)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IMAGE_SIZE,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_IMAGE_SIZE,
kwargs.get("size", "1024x1024"))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IMAGE_QUALITY,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_IMAGE_QUALITY,
kwargs.get("quality", "standard"))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IMAGE_STYLE,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_IMAGE_STYLE,
kwargs.get("style", "vivid"))
- span.set_attribute(SemanticConvetion.GEN_AI_CONTENT_REVISED_PROMPT,
+ span.set_attribute(SemanticConvention.GEN_AI_CONTENT_REVISED_PROMPT,
items.revised_prompt if items.revised_prompt else "")
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_USER,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_USER,
kwargs.get("user", ""))
- span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
+ span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION,
version)
if capture_message_content:
span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_PROMPT: kwargs.get("prompt", ""),
+ SemanticConvention.GEN_AI_CONTENT_PROMPT: kwargs.get("prompt", ""),
},
)
- attribute_name = f"{SemanticConvetion.GEN_AI_RESPONSE_IMAGE}.{images_count}"
+ attribute_name = f"{SemanticConvention.GEN_AI_RESPONSE_IMAGE}.{images_count}"
span.add_event(
name=attribute_name,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_COMPLETION: getattr(items, image),
+ SemanticConvention.GEN_AI_CONTENT_COMPLETION: getattr(items, image),
},
)
images_count+=1
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST,
len(response.data) * cost)
span.set_status(Status(StatusCode.OK))
@@ -1128,8 +1128,8 @@ def image_generate(version, environment, application_name,
attributes = create_metrics_attributes(
service_name=application_name,
deployment_environment=environment,
- operation=SemanticConvetion.GEN_AI_OPERATION_TYPE_IMAGE,
- system=SemanticConvetion.GEN_AI_SYSTEM_OPENAI,
+ operation=SemanticConvention.GEN_AI_OPERATION_TYPE_IMAGE,
+ system=SemanticConvention.GEN_AI_SYSTEM_OPENAI,
request_model=request_model,
server_address=server_address,
server_port=server_port,
@@ -1191,7 +1191,7 @@ def image_variatons(version, environment, application_name,
server_address, server_port = set_server_address_and_port(instance, "api.openai.com", 443)
request_model = kwargs.get("model", "dall-e-2")
- span_name = f"{SemanticConvetion.GEN_AI_OPERATION_TYPE_IMAGE} {request_model}"
+ span_name = f"{SemanticConvention.GEN_AI_OPERATION_TYPE_IMAGE} {request_model}"
with tracer.start_as_current_span(span_name, kind= SpanKind.CLIENT) as span:
start_time = time.time()
@@ -1214,21 +1214,21 @@ def image_variatons(version, environment, application_name,
for items in response.data:
# Set Span attributes (OTel Semconv)
span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
- span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
- SemanticConvetion.GEN_AI_OPERATION_TYPE_IMAGE)
- span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
- SemanticConvetion.GEN_AI_SYSTEM_OPENAI)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_IMAGE)
+ span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
+ SemanticConvention.GEN_AI_SYSTEM_OPENAI)
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
request_model)
- span.set_attribute(SemanticConvetion.SERVER_ADDRESS,
+ span.set_attribute(SemanticConvention.SERVER_ADDRESS,
server_address)
- span.set_attribute(SemanticConvetion.SERVER_PORT,
+ span.set_attribute(SemanticConvention.SERVER_PORT,
server_port)
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_ID,
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_ID,
response.created)
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL,
request_model)
- span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
+ span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
"image")
# Set Span attributes (Extras)
@@ -1236,27 +1236,27 @@ def image_variatons(version, environment, application_name,
environment)
span.set_attribute(SERVICE_NAME,
application_name)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IMAGE_SIZE,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_IMAGE_SIZE,
kwargs.get("size", "1024x1024"))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IMAGE_QUALITY,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_IMAGE_QUALITY,
"standard")
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_USER,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_USER,
kwargs.get("user", ""))
- span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
+ span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION,
version)
if capture_message_content:
- attribute_name = f"{SemanticConvetion.GEN_AI_RESPONSE_IMAGE}.{images_count}"
+ attribute_name = f"{SemanticConvention.GEN_AI_RESPONSE_IMAGE}.{images_count}"
span.add_event(
name=attribute_name,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_COMPLETION: getattr(items, image),
+ SemanticConvention.GEN_AI_CONTENT_COMPLETION: getattr(items, image),
},
)
images_count+=1
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST,
len(response.data) * cost)
span.set_status(Status(StatusCode.OK))
@@ -1264,8 +1264,8 @@ def image_variatons(version, environment, application_name,
attributes = create_metrics_attributes(
service_name=application_name,
deployment_environment=environment,
- operation=SemanticConvetion.GEN_AI_OPERATION_TYPE_IMAGE,
- system=SemanticConvetion.GEN_AI_SYSTEM_OPENAI,
+ operation=SemanticConvention.GEN_AI_OPERATION_TYPE_IMAGE,
+ system=SemanticConvention.GEN_AI_SYSTEM_OPENAI,
request_model=request_model,
server_address=server_address,
server_port=server_port,
@@ -1327,7 +1327,7 @@ def audio_create(version, environment, application_name,
server_address, server_port = set_server_address_and_port(instance, "api.openai.com", 443)
request_model = kwargs.get("model", "tts-1")
- span_name = f"{SemanticConvetion.GEN_AI_OPERATION_TYPE_AUDIO} {request_model}"
+ span_name = f"{SemanticConvention.GEN_AI_OPERATION_TYPE_AUDIO} {request_model}"
with tracer.start_as_current_span(span_name, kind=SpanKind.CLIENT) as span:
start_time = time.time()
@@ -1341,40 +1341,40 @@ def audio_create(version, environment, application_name,
# Set Span attributes
span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
- span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
- SemanticConvetion.GEN_AI_OPERATION_TYPE_AUDIO)
- span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
- SemanticConvetion.GEN_AI_SYSTEM_OPENAI)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_AUDIO)
+ span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
+ SemanticConvention.GEN_AI_SYSTEM_OPENAI)
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
request_model)
- span.set_attribute(SemanticConvetion.SERVER_ADDRESS,
+ span.set_attribute(SemanticConvention.SERVER_ADDRESS,
server_address)
- span.set_attribute(SemanticConvetion.SERVER_PORT,
+ span.set_attribute(SemanticConvention.SERVER_PORT,
server_port)
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL,
request_model)
- span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
+ span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
"speech")
span.set_attribute(DEPLOYMENT_ENVIRONMENT,
environment)
span.set_attribute(SERVICE_NAME,
application_name)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_AUDIO_VOICE,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_AUDIO_VOICE,
kwargs.get("voice", "alloy"))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_AUDIO_RESPONSE_FORMAT,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_AUDIO_RESPONSE_FORMAT,
kwargs.get("response_format", "mp3"))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_AUDIO_SPEED,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_AUDIO_SPEED,
kwargs.get("speed", 1))
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST,
cost)
- span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
+ span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION,
version)
if capture_message_content:
span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_PROMPT: kwargs.get("input", ""),
+ SemanticConvention.GEN_AI_CONTENT_PROMPT: kwargs.get("input", ""),
},
)
@@ -1384,8 +1384,8 @@ def audio_create(version, environment, application_name,
attributes = create_metrics_attributes(
service_name=application_name,
deployment_environment=environment,
- operation=SemanticConvetion.GEN_AI_OPERATION_TYPE_AUDIO,
- system=SemanticConvetion.GEN_AI_SYSTEM_OPENAI,
+ operation=SemanticConvention.GEN_AI_OPERATION_TYPE_AUDIO,
+ system=SemanticConvention.GEN_AI_SYSTEM_OPENAI,
request_model=request_model,
server_address=server_address,
server_port=server_port,
diff --git a/sdk/python/src/openlit/instrumentation/openai_agents/openai_agents.py b/sdk/python/src/openlit/instrumentation/openai_agents/openai_agents.py
index 33dd0372..7090bc75 100644
--- a/sdk/python/src/openlit/instrumentation/openai_agents/openai_agents.py
+++ b/sdk/python/src/openlit/instrumentation/openai_agents/openai_agents.py
@@ -8,7 +8,7 @@ from opentelemetry.sdk.resources import SERVICE_NAME, TELEMETRY_SDK_NAME, DEPLOY
from openlit.__helpers import (
handle_exception,
)
-from openlit.semcov import SemanticConvetion
+from openlit.semcov import SemanticConvention
# Initialize logger for logging potential issues and operations
logger = logging.getLogger(__name__)
@@ -21,16 +21,16 @@ def set_span_attributes(span, version, operation_name, environment,
# Set Span attributes (OTel Semconv)
span.set_attribute(TELEMETRY_SDK_NAME, 'openlit')
- span.set_attribute(SemanticConvetion.GEN_AI_OPERATION, operation_name)
- span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM, SemanticConvetion.GEN_AI_SYSTEM_AG2)
- span.set_attribute(SemanticConvetion.SERVER_ADDRESS, server_address)
- span.set_attribute(SemanticConvetion.SERVER_PORT, server_port)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL, request_model)
+ span.set_attribute(SemanticConvention.GEN_AI_OPERATION, operation_name)
+ span.set_attribute(SemanticConvention.GEN_AI_SYSTEM, SemanticConvention.GEN_AI_SYSTEM_AG2)
+ span.set_attribute(SemanticConvention.SERVER_ADDRESS, server_address)
+ span.set_attribute(SemanticConvention.SERVER_PORT, server_port)
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL, request_model)
# Set Span attributes (Extras)
span.set_attribute(DEPLOYMENT_ENVIRONMENT, environment)
span.set_attribute(SERVICE_NAME, application_name)
- span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION, version)
+ span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION, version)
def create_agent(version, environment, application_name,
tracer, event_provider, pricing_info, capture_message_content, metrics, disable_metrics):
@@ -41,17 +41,17 @@ def create_agent(version, environment, application_name,
server_address, server_port = '127.0.0.1', 80
agent_name = kwargs.get('name', 'openai_agent')
- span_name = f'{SemanticConvetion.GEN_AI_OPERATION_TYPE_CREATE_AGENT} {agent_name}'
+ span_name = f'{SemanticConvention.GEN_AI_OPERATION_TYPE_CREATE_AGENT} {agent_name}'
with tracer.start_as_current_span(span_name, kind=SpanKind.CLIENT) as span:
try:
response = wrapped(*args, **kwargs)
- set_span_attributes(span, version, SemanticConvetion.GEN_AI_OPERATION_TYPE_CREATE_AGENT,
+ set_span_attributes(span, version, SemanticConvention.GEN_AI_OPERATION_TYPE_CREATE_AGENT,
environment, application_name, server_address, server_port, kwargs.get('model', 'gpt-4o'))
- span.set_attribute(SemanticConvetion.GEN_AI_AGENT_NAME, agent_name)
+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_NAME, agent_name)
- span.set_attribute(SemanticConvetion.GEN_AI_AGENT_DESCRIPTION, kwargs.get('instructions', ''))
+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_DESCRIPTION, kwargs.get('instructions', ''))
span.set_status(Status(StatusCode.OK))
diff --git a/sdk/python/src/openlit/instrumentation/phidata/phidata.py b/sdk/python/src/openlit/instrumentation/phidata/phidata.py
index 17443a22..8bafaf94 100644
--- a/sdk/python/src/openlit/instrumentation/phidata/phidata.py
+++ b/sdk/python/src/openlit/instrumentation/phidata/phidata.py
@@ -9,7 +9,7 @@ from opentelemetry.sdk.resources import SERVICE_NAME, TELEMETRY_SDK_NAME, DEPLOY
from openlit.__helpers import (
handle_exception,
)
-from openlit.semcov import SemanticConvetion
+from openlit.semcov import SemanticConvention
# Initialize logger for logging potential issues and operations
logger = logging.getLogger(__name__)
@@ -56,33 +56,33 @@ def phidata_wrap(gen_ai_endpoint, version, environment, application_name,
try:
# Set base span attribues
span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
- span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
- SemanticConvetion.GEN_AI_SYSTEM_PHIDATA)
- span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
- SemanticConvetion.GEN_AI_OPERATION_TYPE_AGENT)
- span.set_attribute(SemanticConvetion.GEN_AI_ENDPOINT,
+ span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
+ SemanticConvention.GEN_AI_SYSTEM_PHIDATA)
+ span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_AGENT)
+ span.set_attribute(SemanticConvention.GEN_AI_ENDPOINT,
gen_ai_endpoint)
span.set_attribute(SERVICE_NAME,
application_name)
span.set_attribute(DEPLOYMENT_ENVIRONMENT,
environment)
- span.set_attribute(SemanticConvetion.GEN_AI_AGENT_ID,
+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_ID,
getattr(instance, 'agent_id', '') or '')
- span.set_attribute(SemanticConvetion.GEN_AI_AGENT_ROLE,
+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_ROLE,
getattr(instance, 'name', '') or '')
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
getattr(getattr(instance, 'model', None), 'id', '') or '')
- span.set_attribute(SemanticConvetion.GEN_AI_AGENT_TOOLS,
+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_TOOLS,
str(getattr(instance, 'tools', '')) or '')
- span.set_attribute(SemanticConvetion.GEN_AI_AGENT_CONTEXT,
+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_CONTEXT,
str(getattr(instance, 'knowledge', '')) or '')
- span.set_attribute(SemanticConvetion.GEN_AI_AGENT_TASK,
+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_TASK,
str(getattr(instance, 'task', '')) or '')
- span.set_attribute(SemanticConvetion.GEN_AI_AGENT_INSTRUCTIONS,
+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_INSTRUCTIONS,
str(getattr(instance, 'instructions', '')) or '')
- span.set_attribute(SemanticConvetion.GEN_AI_AGENT_STORAGE,
+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_STORAGE,
str(getattr(instance, 'storage', '')) or '')
- span.set_attribute(SemanticConvetion.GEN_AI_AGENT_ENABLE_HISTORY,
+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_ENABLE_HISTORY,
str(getattr(instance, 'add_history_to_messages', '')) or '')
span.set_status(Status(StatusCode.OK))
diff --git a/sdk/python/src/openlit/instrumentation/pinecone/pinecone.py b/sdk/python/src/openlit/instrumentation/pinecone/pinecone.py
index 3fe6f846..f647ccdd 100644
--- a/sdk/python/src/openlit/instrumentation/pinecone/pinecone.py
+++ b/sdk/python/src/openlit/instrumentation/pinecone/pinecone.py
@@ -7,7 +7,7 @@ import logging
from opentelemetry.trace import SpanKind, Status, StatusCode
from opentelemetry.sdk.resources import SERVICE_NAME, TELEMETRY_SDK_NAME, DEPLOYMENT_ENVIRONMENT
from openlit.__helpers import handle_exception
-from openlit.semcov import SemanticConvetion
+from openlit.semcov import SemanticConvention
# Initialize logger for logging potential issues and operations
logger = logging.getLogger(__name__)
@@ -70,74 +70,74 @@ def general_wrap(gen_ai_endpoint, version, environment, application_name,
try:
span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
- span.set_attribute(SemanticConvetion.GEN_AI_ENDPOINT,
+ span.set_attribute(SemanticConvention.GEN_AI_ENDPOINT,
gen_ai_endpoint)
span.set_attribute(DEPLOYMENT_ENVIRONMENT,
environment)
span.set_attribute(SERVICE_NAME,
application_name)
- span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
- SemanticConvetion.GEN_AI_OPERATION_TYPE_VECTORDB)
- span.set_attribute(SemanticConvetion.DB_SYSTEM_NAME,
- SemanticConvetion.DB_SYSTEM_PINECONE)
+ span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_VECTORDB)
+ span.set_attribute(SemanticConvention.DB_SYSTEM_NAME,
+ SemanticConvention.DB_SYSTEM_PINECONE)
if gen_ai_endpoint == "pinecone.create_index":
- db_operation = SemanticConvetion.DB_OPERATION_CREATE_INDEX
- span.set_attribute(SemanticConvetion.DB_OPERATION_NAME,
- SemanticConvetion.DB_OPERATION_CREATE_INDEX)
- span.set_attribute(SemanticConvetion.DB_INDEX_NAME,
+ db_operation = SemanticConvention.DB_OPERATION_CREATE_INDEX
+ span.set_attribute(SemanticConvention.DB_OPERATION_NAME,
+ SemanticConvention.DB_OPERATION_CREATE_INDEX)
+ span.set_attribute(SemanticConvention.DB_INDEX_NAME,
kwargs.get("name", ""))
- span.set_attribute(SemanticConvetion.DB_INDEX_DIMENSION,
+ span.set_attribute(SemanticConvention.DB_INDEX_DIMENSION,
kwargs.get("dimensions", ""))
- span.set_attribute(SemanticConvetion.DB_INDEX_METRIC,
+ span.set_attribute(SemanticConvention.DB_INDEX_METRIC,
kwargs.get("metric", ""))
- span.set_attribute(SemanticConvetion.DB_INDEX_SPEC,
+ span.set_attribute(SemanticConvention.DB_INDEX_SPEC,
str(kwargs.get("spec", "")))
elif gen_ai_endpoint == "pinecone.query":
- db_operation = SemanticConvetion.DB_OPERATION_QUERY
- span.set_attribute(SemanticConvetion.DB_OPERATION_NAME,
- SemanticConvetion.DB_OPERATION_QUERY)
- span.set_attribute(SemanticConvetion.DB_STATEMENT,
+ db_operation = SemanticConvention.DB_OPERATION_QUERY
+ span.set_attribute(SemanticConvention.DB_OPERATION_NAME,
+ SemanticConvention.DB_OPERATION_QUERY)
+ span.set_attribute(SemanticConvention.DB_STATEMENT,
str(kwargs.get("vector")))
- span.set_attribute(SemanticConvetion.DB_N_RESULTS,
+ span.set_attribute(SemanticConvention.DB_N_RESULTS,
kwargs.get("top_k", ""))
- span.set_attribute(SemanticConvetion.DB_FILTER,
+ span.set_attribute(SemanticConvention.DB_FILTER,
str(kwargs.get("filter", "")))
- span.set_attribute(SemanticConvetion.DB_NAMESPACE,
+ span.set_attribute(SemanticConvention.DB_NAMESPACE,
str(kwargs.get("namespace", "")))
elif gen_ai_endpoint == "pinecone.update":
- db_operation = SemanticConvetion.DB_OPERATION_UPDATE
- span.set_attribute(SemanticConvetion.DB_OPERATION_NAME,
- SemanticConvetion.DB_OPERATION_UPDATE)
- span.set_attribute(SemanticConvetion.DB_UPDATE_ID,
+ db_operation = SemanticConvention.DB_OPERATION_UPDATE
+ span.set_attribute(SemanticConvention.DB_OPERATION_NAME,
+ SemanticConvention.DB_OPERATION_UPDATE)
+ span.set_attribute(SemanticConvention.DB_UPDATE_ID,
kwargs.get("id",""))
- span.set_attribute(SemanticConvetion.DB_UPDATE_VALUES,
+ span.set_attribute(SemanticConvention.DB_UPDATE_VALUES,
str(kwargs.get("values",[])))
- span.set_attribute(SemanticConvetion.DB_NAMESPACE,
+ span.set_attribute(SemanticConvention.DB_NAMESPACE,
str(kwargs.get("namespace", "")))
- span.set_attribute(SemanticConvetion.DB_UPDATE_METADATA,
+ span.set_attribute(SemanticConvention.DB_UPDATE_METADATA,
str(kwargs.get("set_metadata", "")))
elif gen_ai_endpoint == "pinecone.upsert":
- db_operation = SemanticConvetion.DB_OPERATION_UPSERT
- span.set_attribute(SemanticConvetion.DB_OPERATION_NAME,
- SemanticConvetion.DB_OPERATION_UPSERT)
- span.set_attribute(SemanticConvetion.DB_VECTOR_COUNT,
+ db_operation = SemanticConvention.DB_OPERATION_UPSERT
+ span.set_attribute(SemanticConvention.DB_OPERATION_NAME,
+ SemanticConvention.DB_OPERATION_UPSERT)
+ span.set_attribute(SemanticConvention.DB_VECTOR_COUNT,
object_count(kwargs.get("vectors")))
elif gen_ai_endpoint == "pinecone.delete":
- db_operation = SemanticConvetion.DB_OPERATION_DELETE
- span.set_attribute(SemanticConvetion.DB_OPERATION_NAME,
- SemanticConvetion.DB_OPERATION_DELETE)
- span.set_attribute(SemanticConvetion.DB_ID_COUNT,
+ db_operation = SemanticConvention.DB_OPERATION_DELETE
+ span.set_attribute(SemanticConvention.DB_OPERATION_NAME,
+ SemanticConvention.DB_OPERATION_DELETE)
+ span.set_attribute(SemanticConvention.DB_ID_COUNT,
object_count(kwargs.get("ids")))
- span.set_attribute(SemanticConvetion.DB_FILTER,
+ span.set_attribute(SemanticConvention.DB_FILTER,
str(kwargs.get("filter", "")))
- span.set_attribute(SemanticConvetion.DB_DELETE_ALL,
+ span.set_attribute(SemanticConvention.DB_DELETE_ALL,
kwargs.get("delete_all", False))
- span.set_attribute(SemanticConvetion.DB_NAMESPACE,
+ span.set_attribute(SemanticConvention.DB_NAMESPACE,
kwargs.get("namespace", ""))
span.set_status(Status(StatusCode.OK))
@@ -148,13 +148,13 @@ def general_wrap(gen_ai_endpoint, version, environment, application_name,
"openlit",
SERVICE_NAME:
application_name,
- SemanticConvetion.DB_SYSTEM_NAME:
- SemanticConvetion.DB_SYSTEM_PINECONE,
+ SemanticConvention.DB_SYSTEM_NAME:
+ SemanticConvention.DB_SYSTEM_PINECONE,
DEPLOYMENT_ENVIRONMENT:
environment,
- SemanticConvetion.GEN_AI_OPERATION:
- SemanticConvetion.GEN_AI_OPERATION_TYPE_VECTORDB,
- SemanticConvetion.DB_OPERATION_NAME:
+ SemanticConvention.GEN_AI_OPERATION:
+ SemanticConvention.GEN_AI_OPERATION_TYPE_VECTORDB,
+ SemanticConvention.DB_OPERATION_NAME:
db_operation
}
diff --git a/sdk/python/src/openlit/instrumentation/premai/premai.py b/sdk/python/src/openlit/instrumentation/premai/premai.py
index 955532a7..b8a24890 100644
--- a/sdk/python/src/openlit/instrumentation/premai/premai.py
+++ b/sdk/python/src/openlit/instrumentation/premai/premai.py
@@ -16,7 +16,7 @@ from openlit.__helpers import (
create_metrics_attributes,
set_server_address_and_port
)
-from openlit.semcov import SemanticConvetion
+from openlit.semcov import SemanticConvention
# Initialize logger for logging potential issues and operations
logger = logging.getLogger(__name__)
@@ -139,45 +139,45 @@ def chat(version, environment, application_name,
# Set Span attributes (OTel Semconv)
self._span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
- self._span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
- SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT)
- self._span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
- SemanticConvetion.GEN_AI_SYSTEM_PREMAI)
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
+ self._span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT)
+ self._span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
+ SemanticConvention.GEN_AI_SYSTEM_PREMAI)
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
request_model)
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_SEED,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_SEED,
self._kwargs.get("seed", ""))
- self._span.set_attribute(SemanticConvetion.SERVER_PORT,
+ self._span.set_attribute(SemanticConvention.SERVER_PORT,
self._server_port)
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_FREQUENCY_PENALTY,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_FREQUENCY_PENALTY,
self._kwargs.get("frequency_penalty", 0.0))
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MAX_TOKENS,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS,
self._kwargs.get("max_tokens", -1))
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_PRESENCE_PENALTY,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_PRESENCE_PENALTY,
self._kwargs.get("presence_penalty", 0.0))
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_STOP_SEQUENCES,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_STOP_SEQUENCES,
self._kwargs.get("stop", []))
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TEMPERATURE,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TEMPERATURE,
self._kwargs.get("temperature", 1.0))
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TOP_P,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TOP_P,
self._kwargs.get("top_p", 1.0))
- self._span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_FINISH_REASON,
+ self._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON,
[self._finish_reason])
- self._span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_ID,
+ self._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_ID,
self._response_id)
- self._span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_MODEL,
+ self._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL,
self._response_model)
- self._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_INPUT_TOKENS,
+ self._span.set_attribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS,
input_tokens)
- self._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_OUTPUT_TOKENS,
+ self._span.set_attribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS,
output_tokens)
- self._span.set_attribute(SemanticConvetion.SERVER_ADDRESS,
+ self._span.set_attribute(SemanticConvention.SERVER_ADDRESS,
self._server_address)
if isinstance(self._llmresponse, str):
- self._span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
+ self._span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
"text")
else:
- self._span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
+ self._span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
"json")
# Set Span attributes (Extra)
@@ -185,31 +185,31 @@ def chat(version, environment, application_name,
environment)
self._span.set_attribute(SERVICE_NAME,
application_name)
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_USER,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_USER,
self._kwargs.get("user", ""))
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IS_STREAM,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM,
True)
- self._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_TOTAL_TOKENS,
+ self._span.set_attribute(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS,
input_tokens + output_tokens)
- self._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
+ self._span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST,
cost)
- self._span.set_attribute(SemanticConvetion.GEN_AI_SERVER_TBT,
+ self._span.set_attribute(SemanticConvention.GEN_AI_SERVER_TBT,
self._tbt)
- self._span.set_attribute(SemanticConvetion.GEN_AI_SERVER_TTFT,
+ self._span.set_attribute(SemanticConvention.GEN_AI_SERVER_TTFT,
self._ttft)
- self._span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
+ self._span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION,
version)
if capture_message_content:
self._span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_PROMPT: prompt,
+ SemanticConvention.GEN_AI_CONTENT_PROMPT: prompt,
},
)
self._span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_COMPLETION_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_COMPLETION_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_COMPLETION: self._llmresponse,
+ SemanticConvention.GEN_AI_CONTENT_COMPLETION: self._llmresponse,
},
)
self._span.set_status(Status(StatusCode.OK))
@@ -218,8 +218,8 @@ def chat(version, environment, application_name,
attributes = create_metrics_attributes(
service_name=application_name,
deployment_environment=environment,
- operation=SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT,
- system=SemanticConvetion.GEN_AI_SYSTEM_PREMAI,
+ operation=SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
+ system=SemanticConvention.GEN_AI_SYSTEM_PREMAI,
request_model=request_model,
server_address=self._server_address,
server_port=self._server_port,
@@ -271,7 +271,7 @@ def chat(version, environment, application_name,
server_address, server_port = set_server_address_and_port(instance, "app.premai.io", 443)
request_model = kwargs.get("model", "gpt-4o-mini")
- span_name = f"{SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT} {request_model}"
+ span_name = f"{SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT} {request_model}"
# pylint: disable=no-else-return
if streaming:
@@ -317,35 +317,35 @@ def chat(version, environment, application_name,
# Set base span attribues (OTel Semconv)
span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
- span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
- SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT)
- span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
- SemanticConvetion.GEN_AI_SYSTEM_PREMAI)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT)
+ span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
+ SemanticConvention.GEN_AI_SYSTEM_PREMAI)
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
request_model)
- span.set_attribute(SemanticConvetion.SERVER_PORT,
+ span.set_attribute(SemanticConvention.SERVER_PORT,
server_port)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_FREQUENCY_PENALTY,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_FREQUENCY_PENALTY,
kwargs.get("frequency_penalty", 0.0))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MAX_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS,
kwargs.get("max_tokens", -1))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_PRESENCE_PENALTY,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_PRESENCE_PENALTY,
kwargs.get("presence_penalty", 0.0))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_STOP_SEQUENCES,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_STOP_SEQUENCES,
kwargs.get("stop", []))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TEMPERATURE,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TEMPERATURE,
kwargs.get("temperature", 1.0))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TOP_P,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TOP_P,
kwargs.get("top_p", 1.0))
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_ID,
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_ID,
response.additional_properties.get('id'))
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL,
response.model)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_INPUT_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS,
input_tokens)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_OUTPUT_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS,
output_tokens)
- span.set_attribute(SemanticConvetion.SERVER_ADDRESS,
+ span.set_attribute(SemanticConvention.SERVER_ADDRESS,
server_address)
# Set base span attribues (Extras)
@@ -353,39 +353,39 @@ def chat(version, environment, application_name,
environment)
span.set_attribute(SERVICE_NAME,
application_name)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IS_STREAM,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM,
False)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_TOTAL_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS,
input_tokens + output_tokens)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST,
cost)
- span.set_attribute(SemanticConvetion.GEN_AI_SERVER_TTFT,
+ span.set_attribute(SemanticConvention.GEN_AI_SERVER_TTFT,
end_time - start_time)
- span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
+ span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION,
version)
if capture_message_content:
span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_PROMPT: prompt,
+ SemanticConvention.GEN_AI_CONTENT_PROMPT: prompt,
},
)
span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_COMPLETION_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_COMPLETION_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_COMPLETION: str(response.choices[0].message.content),
+ SemanticConvention.GEN_AI_CONTENT_COMPLETION: str(response.choices[0].message.content),
},
)
if kwargs.get('tools'):
- span.set_attribute(SemanticConvetion.GEN_AI_TOOL_CALLS,
+ span.set_attribute(SemanticConvention.GEN_AI_TOOL_CALLS,
str(response.choices[0].message.tool_calls))
if kwargs.get('response_format', '') != '':
- span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
+ span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
"json")
else:
- span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
+ span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
"text")
span.set_status(Status(StatusCode.OK))
@@ -394,8 +394,8 @@ def chat(version, environment, application_name,
attributes = create_metrics_attributes(
service_name=application_name,
deployment_environment=environment,
- operation=SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT,
- system=SemanticConvetion.GEN_AI_SYSTEM_PREMAI,
+ operation=SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
+ system=SemanticConvention.GEN_AI_SYSTEM_PREMAI,
request_model=request_model,
server_address=server_address,
server_port=server_port,
@@ -465,7 +465,7 @@ def embedding(version, environment, application_name,
server_address, server_port = set_server_address_and_port(instance, "app.premai.io", 443)
request_model = kwargs.get("model", "text-embedding-ada-002")
- span_name = f"{SemanticConvetion.GEN_AI_OPERATION_TYPE_EMBEDDING} {request_model}"
+ span_name = f"{SemanticConvention.GEN_AI_OPERATION_TYPE_EMBEDDING} {request_model}"
with tracer.start_as_current_span(span_name, kind= SpanKind.CLIENT) as span:
start_time = time.time()
@@ -481,21 +481,21 @@ def embedding(version, environment, application_name,
# Set Span attributes (OTel Semconv)
span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
- span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
- SemanticConvetion.GEN_AI_OPERATION_TYPE_EMBEDDING)
- span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
- SemanticConvetion.GEN_AI_SYSTEM_PREMAI)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_EMBEDDING)
+ span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
+ SemanticConvention.GEN_AI_SYSTEM_PREMAI)
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
request_model)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_ENCODING_FORMATS,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_ENCODING_FORMATS,
[kwargs.get('encoding_format', 'float')])
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL,
response.model)
- span.set_attribute(SemanticConvetion.SERVER_ADDRESS,
+ span.set_attribute(SemanticConvention.SERVER_ADDRESS,
server_address)
- span.set_attribute(SemanticConvetion.SERVER_PORT,
+ span.set_attribute(SemanticConvention.SERVER_PORT,
server_port)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_INPUT_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS,
input_tokens)
# Set Span attributes (Extras)
@@ -503,20 +503,20 @@ def embedding(version, environment, application_name,
environment)
span.set_attribute(SERVICE_NAME,
application_name)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_USER,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_USER,
kwargs.get("user", ""))
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_TOTAL_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS,
input_tokens)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST,
cost)
- span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
+ span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION,
version)
if capture_message_content:
span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_PROMPT: str(kwargs.get("input", "")),
+ SemanticConvention.GEN_AI_CONTENT_PROMPT: str(kwargs.get("input", "")),
},
)
@@ -526,8 +526,8 @@ def embedding(version, environment, application_name,
attributes = create_metrics_attributes(
service_name=application_name,
deployment_environment=environment,
- operation=SemanticConvetion.GEN_AI_OPERATION_TYPE_EMBEDDING,
- system=SemanticConvetion.GEN_AI_SYSTEM_PREMAI,
+ operation=SemanticConvention.GEN_AI_OPERATION_TYPE_EMBEDDING,
+ system=SemanticConvention.GEN_AI_SYSTEM_PREMAI,
request_model=request_model,
server_address=server_address,
server_port=server_port,
diff --git a/sdk/python/src/openlit/instrumentation/qdrant/async_qdrant.py b/sdk/python/src/openlit/instrumentation/qdrant/async_qdrant.py
index 2b09798a..dfb2c653 100644
--- a/sdk/python/src/openlit/instrumentation/qdrant/async_qdrant.py
+++ b/sdk/python/src/openlit/instrumentation/qdrant/async_qdrant.py
@@ -7,7 +7,7 @@ import logging
from opentelemetry.trace import SpanKind, Status, StatusCode
from opentelemetry.sdk.resources import SERVICE_NAME, TELEMETRY_SDK_NAME, DEPLOYMENT_ENVIRONMENT
from openlit.__helpers import handle_exception
-from openlit.semcov import SemanticConvetion
+from openlit.semcov import SemanticConvention
# Initialize logger for logging potential issues and operations
logger = logging.getLogger(__name__)
@@ -71,168 +71,168 @@ def async_general_wrap(gen_ai_endpoint, version, environment, application_name,
try:
span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
- span.set_attribute(SemanticConvetion.GEN_AI_ENDPOINT,
+ span.set_attribute(SemanticConvention.GEN_AI_ENDPOINT,
gen_ai_endpoint)
span.set_attribute(DEPLOYMENT_ENVIRONMENT,
environment)
span.set_attribute(SERVICE_NAME,
application_name)
- span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
- SemanticConvetion.GEN_AI_OPERATION_TYPE_VECTORDB)
- span.set_attribute(SemanticConvetion.DB_SYSTEM_NAME,
- SemanticConvetion.DB_SYSTEM_QDRANT)
+ span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_VECTORDB)
+ span.set_attribute(SemanticConvention.DB_SYSTEM_NAME,
+ SemanticConvention.DB_SYSTEM_QDRANT)
if gen_ai_endpoint == "qdrant.create_collection":
- db_operation = SemanticConvetion.DB_OPERATION_CREATE_COLLECTION
- span.set_attribute(SemanticConvetion.DB_OPERATION_NAME,
- SemanticConvetion.DB_OPERATION_CREATE_COLLECTION)
- span.set_attribute(SemanticConvetion.DB_COLLECTION_NAME,
+ db_operation = SemanticConvention.DB_OPERATION_CREATE_COLLECTION
+ span.set_attribute(SemanticConvention.DB_OPERATION_NAME,
+ SemanticConvention.DB_OPERATION_CREATE_COLLECTION)
+ span.set_attribute(SemanticConvention.DB_COLLECTION_NAME,
kwargs.get("collection_name", ""))
elif gen_ai_endpoint == "qdrant.upload_collection":
- db_operation = SemanticConvetion.DB_OPERATION_CREATE_COLLECTION
- span.set_attribute(SemanticConvetion.DB_OPERATION_NAME,
- SemanticConvetion.DB_OPERATION_CREATE_COLLECTION)
- span.set_attribute(SemanticConvetion.DB_COLLECTION_NAME,
+ db_operation = SemanticConvention.DB_OPERATION_CREATE_COLLECTION
+ span.set_attribute(SemanticConvention.DB_OPERATION_NAME,
+ SemanticConvention.DB_OPERATION_CREATE_COLLECTION)
+ span.set_attribute(SemanticConvention.DB_COLLECTION_NAME,
kwargs.get("collection_name", ""))
elif gen_ai_endpoint == "qdrant.delete_collection":
- db_operation = SemanticConvetion.DB_OPERATION_DELETE_COLLECTION
- span.set_attribute(SemanticConvetion.DB_OPERATION_NAME,
- SemanticConvetion.DB_OPERATION_DELETE_COLLECTION)
- span.set_attribute(SemanticConvetion.DB_COLLECTION_NAME,
+ db_operation = SemanticConvention.DB_OPERATION_DELETE_COLLECTION
+ span.set_attribute(SemanticConvention.DB_OPERATION_NAME,
+ SemanticConvention.DB_OPERATION_DELETE_COLLECTION)
+ span.set_attribute(SemanticConvention.DB_COLLECTION_NAME,
kwargs.get("collection_name", ""))
elif gen_ai_endpoint == "qdrant.update_collection":
- db_operation = SemanticConvetion.DB_OPERATION_UPDATE_COLLECTION
- span.set_attribute(SemanticConvetion.DB_OPERATION_NAME,
- SemanticConvetion.DB_OPERATION_UPDATE_COLLECTION)
- span.set_attribute(SemanticConvetion.DB_COLLECTION_NAME,
+ db_operation = SemanticConvention.DB_OPERATION_UPDATE_COLLECTION
+ span.set_attribute(SemanticConvention.DB_OPERATION_NAME,
+ SemanticConvention.DB_OPERATION_UPDATE_COLLECTION)
+ span.set_attribute(SemanticConvention.DB_COLLECTION_NAME,
kwargs.get("collection_name", ""))
elif gen_ai_endpoint == "qdrant.set_payload":
- db_operation = SemanticConvetion.DB_OPERATION_ADD
- span.set_attribute(SemanticConvetion.DB_OPERATION_NAME,
- SemanticConvetion.DB_OPERATION_ADD)
- span.set_attribute(SemanticConvetion.DB_COLLECTION_NAME,
+ db_operation = SemanticConvention.DB_OPERATION_ADD
+ span.set_attribute(SemanticConvention.DB_OPERATION_NAME,
+ SemanticConvention.DB_OPERATION_ADD)
+ span.set_attribute(SemanticConvention.DB_COLLECTION_NAME,
kwargs.get("collection_name", ""))
- span.set_attribute(SemanticConvetion.DB_OPERATION_STATUS,
+ span.set_attribute(SemanticConvention.DB_OPERATION_STATUS,
response.status)
- span.set_attribute(SemanticConvetion.DB_VECTOR_COUNT,
+ span.set_attribute(SemanticConvention.DB_VECTOR_COUNT,
object_count(kwargs.get("points", [])))
- span.set_attribute(SemanticConvetion.DB_PAYLOAD_COUNT,
+ span.set_attribute(SemanticConvention.DB_PAYLOAD_COUNT,
object_count(kwargs.get("payload", [])))
elif gen_ai_endpoint == "qdrant.retrieve":
- db_operation = SemanticConvetion.DB_OPERATION_QUERY
- span.set_attribute(SemanticConvetion.DB_OPERATION_NAME,
- SemanticConvetion.DB_OPERATION_QUERY)
- span.set_attribute(SemanticConvetion.DB_COLLECTION_NAME,
+ db_operation = SemanticConvention.DB_OPERATION_QUERY
+ span.set_attribute(SemanticConvention.DB_OPERATION_NAME,
+ SemanticConvention.DB_OPERATION_QUERY)
+ span.set_attribute(SemanticConvention.DB_COLLECTION_NAME,
kwargs.get("collection_name", ""))
- span.set_attribute(SemanticConvetion.DB_STATEMENT,
+ span.set_attribute(SemanticConvention.DB_STATEMENT,
str(kwargs.get("ids", "")))
elif gen_ai_endpoint == "qdrant.scroll":
- db_operation = SemanticConvetion.DB_OPERATION_QUERY
- span.set_attribute(SemanticConvetion.DB_OPERATION_NAME,
- SemanticConvetion.DB_OPERATION_QUERY)
- span.set_attribute(SemanticConvetion.DB_COLLECTION_NAME,
+ db_operation = SemanticConvention.DB_OPERATION_QUERY
+ span.set_attribute(SemanticConvention.DB_OPERATION_NAME,
+ SemanticConvention.DB_OPERATION_QUERY)
+ span.set_attribute(SemanticConvention.DB_COLLECTION_NAME,
kwargs.get("collection_name", ""))
- span.set_attribute(SemanticConvetion.DB_STATEMENT,
+ span.set_attribute(SemanticConvention.DB_STATEMENT,
str(kwargs.get("scroll_filter", "")))
elif gen_ai_endpoint in ["qdrant.search", "qdrant.search_groups"]:
- db_operation = SemanticConvetion.DB_OPERATION_QUERY
- span.set_attribute(SemanticConvetion.DB_OPERATION_NAME,
- SemanticConvetion.DB_OPERATION_QUERY)
- span.set_attribute(SemanticConvetion.DB_COLLECTION_NAME,
+ db_operation = SemanticConvention.DB_OPERATION_QUERY
+ span.set_attribute(SemanticConvention.DB_OPERATION_NAME,
+ SemanticConvention.DB_OPERATION_QUERY)
+ span.set_attribute(SemanticConvention.DB_COLLECTION_NAME,
kwargs.get("collection_name", ""))
- span.set_attribute(SemanticConvetion.DB_STATEMENT,
+ span.set_attribute(SemanticConvention.DB_STATEMENT,
str(kwargs.get("query_vector", "")))
elif gen_ai_endpoint == "qdrant.recommend":
- db_operation = SemanticConvetion.DB_OPERATION_QUERY
- span.set_attribute(SemanticConvetion.DB_OPERATION_NAME,
- SemanticConvetion.DB_OPERATION_QUERY)
- span.set_attribute(SemanticConvetion.DB_COLLECTION_NAME,
+ db_operation = SemanticConvention.DB_OPERATION_QUERY
+ span.set_attribute(SemanticConvention.DB_OPERATION_NAME,
+ SemanticConvention.DB_OPERATION_QUERY)
+ span.set_attribute(SemanticConvention.DB_COLLECTION_NAME,
kwargs.get("collection_name", ""))
- span.set_attribute(SemanticConvetion.DB_STATEMENT,
+ span.set_attribute(SemanticConvention.DB_STATEMENT,
"positive:" + str(kwargs.get("positive", "")) +
" negative:" + str(kwargs.get("negative", "")))
elif gen_ai_endpoint == "qdrant.upload_points":
- db_operation = SemanticConvetion.DB_OPERATION_ADD
- span.set_attribute(SemanticConvetion.DB_OPERATION_NAME,
- SemanticConvetion.DB_OPERATION_ADD)
- span.set_attribute(SemanticConvetion.DB_COLLECTION_NAME,
+ db_operation = SemanticConvention.DB_OPERATION_ADD
+ span.set_attribute(SemanticConvention.DB_OPERATION_NAME,
+ SemanticConvention.DB_OPERATION_ADD)
+ span.set_attribute(SemanticConvention.DB_COLLECTION_NAME,
kwargs.get("collection_name", ""))
- span.set_attribute(SemanticConvetion.DB_VECTOR_COUNT,
+ span.set_attribute(SemanticConvention.DB_VECTOR_COUNT,
object_count(kwargs.get("points")))
elif gen_ai_endpoint == "qdrant.update_vectors":
- db_operation = SemanticConvetion.DB_OPERATION_UPDATE
- span.set_attribute(SemanticConvetion.DB_OPERATION_NAME,
- SemanticConvetion.DB_OPERATION_UPDATE)
- span.set_attribute(SemanticConvetion.DB_COLLECTION_NAME,
+ db_operation = SemanticConvention.DB_OPERATION_UPDATE
+ span.set_attribute(SemanticConvention.DB_OPERATION_NAME,
+ SemanticConvention.DB_OPERATION_UPDATE)
+ span.set_attribute(SemanticConvention.DB_COLLECTION_NAME,
kwargs.get("collection_name", ""))
- span.set_attribute(SemanticConvetion.DB_OPERATION_STATUS,
+ span.set_attribute(SemanticConvention.DB_OPERATION_STATUS,
response.status)
- span.set_attribute(SemanticConvetion.DB_VECTOR_COUNT,
+ span.set_attribute(SemanticConvention.DB_VECTOR_COUNT,
object_count(kwargs.get("points")))
elif gen_ai_endpoint == "qdrant.overwrite_payload":
- db_operation = SemanticConvetion.DB_OPERATION_UPDATE
- span.set_attribute(SemanticConvetion.DB_OPERATION_NAME,
- SemanticConvetion.DB_OPERATION_UPDATE)
- span.set_attribute(SemanticConvetion.DB_COLLECTION_NAME,
+ db_operation = SemanticConvention.DB_OPERATION_UPDATE
+ span.set_attribute(SemanticConvention.DB_OPERATION_NAME,
+ SemanticConvention.DB_OPERATION_UPDATE)
+ span.set_attribute(SemanticConvention.DB_COLLECTION_NAME,
kwargs.get("collection_name", ""))
- span.set_attribute(SemanticConvetion.DB_OPERATION_STATUS,
+ span.set_attribute(SemanticConvention.DB_OPERATION_STATUS,
response.status)
- span.set_attribute(SemanticConvetion.DB_VECTOR_COUNT,
+ span.set_attribute(SemanticConvention.DB_VECTOR_COUNT,
object_count(kwargs.get("points")))
- span.set_attribute(SemanticConvetion.DB_PAYLOAD_COUNT,
+ span.set_attribute(SemanticConvention.DB_PAYLOAD_COUNT,
object_count(kwargs.get("payload")))
elif gen_ai_endpoint == "qdrant.upsert":
- db_operation = SemanticConvetion.DB_OPERATION_UPSERT
- span.set_attribute(SemanticConvetion.DB_COLLECTION_NAME,
+ db_operation = SemanticConvention.DB_OPERATION_UPSERT
+ span.set_attribute(SemanticConvention.DB_COLLECTION_NAME,
kwargs.get("collection_name", ""))
- span.set_attribute(SemanticConvetion.DB_OPERATION_NAME,
- SemanticConvetion.DB_OPERATION_UPSERT)
- span.set_attribute(SemanticConvetion.DB_OPERATION_STATUS,
+ span.set_attribute(SemanticConvention.DB_OPERATION_NAME,
+ SemanticConvention.DB_OPERATION_UPSERT)
+ span.set_attribute(SemanticConvention.DB_OPERATION_STATUS,
response.status)
- span.set_attribute(SemanticConvetion.DB_VECTOR_COUNT,
+ span.set_attribute(SemanticConvention.DB_VECTOR_COUNT,
object_count(kwargs.get("points")))
elif gen_ai_endpoint in ["qdrant.delete_payload", "qdrant.delete_vectors"]:
- db_operation = SemanticConvetion.DB_OPERATION_DELETE
- span.set_attribute(SemanticConvetion.DB_OPERATION_NAME,
- SemanticConvetion.DB_OPERATION_DELETE)
- span.set_attribute(SemanticConvetion.DB_COLLECTION_NAME,
+ db_operation = SemanticConvention.DB_OPERATION_DELETE
+ span.set_attribute(SemanticConvention.DB_OPERATION_NAME,
+ SemanticConvention.DB_OPERATION_DELETE)
+ span.set_attribute(SemanticConvention.DB_COLLECTION_NAME,
kwargs.get("collection_name", ""))
- span.set_attribute(SemanticConvetion.DB_OPERATION_STATUS,
+ span.set_attribute(SemanticConvention.DB_OPERATION_STATUS,
response.status)
- span.set_attribute(SemanticConvetion.DB_VECTOR_COUNT,
+ span.set_attribute(SemanticConvention.DB_VECTOR_COUNT,
object_count(kwargs.get("points")))
elif gen_ai_endpoint in ["qdrant.clear_payload", "qdrant.delete"]:
- db_operation = SemanticConvetion.DB_OPERATION_DELETE
- span.set_attribute(SemanticConvetion.DB_OPERATION_NAME,
- SemanticConvetion.DB_OPERATION_DELETE)
- span.set_attribute(SemanticConvetion.DB_COLLECTION_NAME,
+ db_operation = SemanticConvention.DB_OPERATION_DELETE
+ span.set_attribute(SemanticConvention.DB_OPERATION_NAME,
+ SemanticConvention.DB_OPERATION_DELETE)
+ span.set_attribute(SemanticConvention.DB_COLLECTION_NAME,
kwargs.get("collection_name", ""))
- span.set_attribute(SemanticConvetion.DB_OPERATION_STATUS,
+ span.set_attribute(SemanticConvention.DB_OPERATION_STATUS,
response.status)
- span.set_attribute(SemanticConvetion.DB_VECTOR_COUNT,
+ span.set_attribute(SemanticConvention.DB_VECTOR_COUNT,
object_count(kwargs.get("points_selector")))
elif gen_ai_endpoint == "qdrant.create_payload_index":
- db_operation = SemanticConvetion.DB_OPERATION_CREATE_INDEX
- span.set_attribute(SemanticConvetion.DB_OPERATION_NAME,
- SemanticConvetion.DB_OPERATION_CREATE_INDEX)
- span.set_attribute(SemanticConvetion.DB_COLLECTION_NAME,
+ db_operation = SemanticConvention.DB_OPERATION_CREATE_INDEX
+ span.set_attribute(SemanticConvention.DB_OPERATION_NAME,
+ SemanticConvention.DB_OPERATION_CREATE_INDEX)
+ span.set_attribute(SemanticConvention.DB_COLLECTION_NAME,
kwargs.get("collection_name", ""))
- span.set_attribute(SemanticConvetion.DB_STATEMENT,
+ span.set_attribute(SemanticConvention.DB_STATEMENT,
str(kwargs.get("query", "")))
span.set_status(Status(StatusCode.OK))
@@ -243,13 +243,13 @@ def async_general_wrap(gen_ai_endpoint, version, environment, application_name,
"openlit",
SERVICE_NAME:
application_name,
- SemanticConvetion.DB_SYSTEM_NAME:
- SemanticConvetion.DB_SYSTEM_QDRANT,
+ SemanticConvention.DB_SYSTEM_NAME:
+ SemanticConvention.DB_SYSTEM_QDRANT,
DEPLOYMENT_ENVIRONMENT:
environment,
- SemanticConvetion.GEN_AI_OPERATION:
- SemanticConvetion.GEN_AI_OPERATION_TYPE_VECTORDB,
- SemanticConvetion.DB_OPERATION_NAME:
+ SemanticConvention.GEN_AI_OPERATION:
+ SemanticConvention.GEN_AI_OPERATION_TYPE_VECTORDB,
+ SemanticConvention.DB_OPERATION_NAME:
db_operation
}
diff --git a/sdk/python/src/openlit/instrumentation/qdrant/qdrant.py b/sdk/python/src/openlit/instrumentation/qdrant/qdrant.py
index dda9b178..203423bb 100644
--- a/sdk/python/src/openlit/instrumentation/qdrant/qdrant.py
+++ b/sdk/python/src/openlit/instrumentation/qdrant/qdrant.py
@@ -7,7 +7,7 @@ import logging
from opentelemetry.trace import SpanKind, Status, StatusCode
from opentelemetry.sdk.resources import SERVICE_NAME, TELEMETRY_SDK_NAME, DEPLOYMENT_ENVIRONMENT
from openlit.__helpers import handle_exception
-from openlit.semcov import SemanticConvetion
+from openlit.semcov import SemanticConvention
# Initialize logger for logging potential issues and operations
logger = logging.getLogger(__name__)
@@ -71,175 +71,175 @@ def general_wrap(gen_ai_endpoint, version, environment, application_name,
try:
span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
- span.set_attribute(SemanticConvetion.GEN_AI_ENDPOINT,
+ span.set_attribute(SemanticConvention.GEN_AI_ENDPOINT,
gen_ai_endpoint)
span.set_attribute(DEPLOYMENT_ENVIRONMENT,
environment)
span.set_attribute(SERVICE_NAME,
application_name)
- span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
- SemanticConvetion.GEN_AI_OPERATION_TYPE_VECTORDB)
- span.set_attribute(SemanticConvetion.DB_SYSTEM_NAME,
- SemanticConvetion.DB_SYSTEM_QDRANT)
+ span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_VECTORDB)
+ span.set_attribute(SemanticConvention.DB_SYSTEM_NAME,
+ SemanticConvention.DB_SYSTEM_QDRANT)
if gen_ai_endpoint == "qdrant.create_collection":
- db_operation = SemanticConvetion.DB_OPERATION_CREATE_COLLECTION
- span.set_attribute(SemanticConvetion.DB_OPERATION_NAME,
- SemanticConvetion.DB_OPERATION_CREATE_COLLECTION)
- span.set_attribute(SemanticConvetion.DB_COLLECTION_NAME,
+ db_operation = SemanticConvention.DB_OPERATION_CREATE_COLLECTION
+ span.set_attribute(SemanticConvention.DB_OPERATION_NAME,
+ SemanticConvention.DB_OPERATION_CREATE_COLLECTION)
+ span.set_attribute(SemanticConvention.DB_COLLECTION_NAME,
kwargs.get("collection_name", ""))
elif gen_ai_endpoint == "qdrant.upload_collection":
- db_operation = SemanticConvetion.DB_OPERATION_CREATE_COLLECTION
- span.set_attribute(SemanticConvetion.DB_OPERATION_NAME,
- SemanticConvetion.DB_OPERATION_CREATE_COLLECTION)
- span.set_attribute(SemanticConvetion.DB_COLLECTION_NAME,
+ db_operation = SemanticConvention.DB_OPERATION_CREATE_COLLECTION
+ span.set_attribute(SemanticConvention.DB_OPERATION_NAME,
+ SemanticConvention.DB_OPERATION_CREATE_COLLECTION)
+ span.set_attribute(SemanticConvention.DB_COLLECTION_NAME,
kwargs.get("collection_name", ""))
elif gen_ai_endpoint == "qdrant.delete_collection":
- db_operation = SemanticConvetion.DB_OPERATION_DELETE_COLLECTION
- span.set_attribute(SemanticConvetion.DB_OPERATION_NAME,
- SemanticConvetion.DB_OPERATION_DELETE_COLLECTION)
- span.set_attribute(SemanticConvetion.DB_COLLECTION_NAME,
+ db_operation = SemanticConvention.DB_OPERATION_DELETE_COLLECTION
+ span.set_attribute(SemanticConvention.DB_OPERATION_NAME,
+ SemanticConvention.DB_OPERATION_DELETE_COLLECTION)
+ span.set_attribute(SemanticConvention.DB_COLLECTION_NAME,
kwargs.get("collection_name", ""))
elif gen_ai_endpoint == "qdrant.update_collection":
- db_operation = SemanticConvetion.DB_OPERATION_UPDATE_COLLECTION
- span.set_attribute(SemanticConvetion.DB_OPERATION_NAME,
- SemanticConvetion.DB_OPERATION_UPDATE_COLLECTION)
- span.set_attribute(SemanticConvetion.DB_COLLECTION_NAME,
+ db_operation = SemanticConvention.DB_OPERATION_UPDATE_COLLECTION
+ span.set_attribute(SemanticConvention.DB_OPERATION_NAME,
+ SemanticConvention.DB_OPERATION_UPDATE_COLLECTION)
+ span.set_attribute(SemanticConvention.DB_COLLECTION_NAME,
kwargs.get("collection_name", ""))
elif gen_ai_endpoint == "qdrant.set_payload":
- db_operation = SemanticConvetion.DB_OPERATION_ADD
- span.set_attribute(SemanticConvetion.DB_OPERATION_NAME,
- SemanticConvetion.DB_OPERATION_ADD)
- span.set_attribute(SemanticConvetion.DB_COLLECTION_NAME,
+ db_operation = SemanticConvention.DB_OPERATION_ADD
+ span.set_attribute(SemanticConvention.DB_OPERATION_NAME,
+ SemanticConvention.DB_OPERATION_ADD)
+ span.set_attribute(SemanticConvention.DB_COLLECTION_NAME,
kwargs.get("collection_name", ""))
- span.set_attribute(SemanticConvetion.DB_OPERATION_STATUS,
+ span.set_attribute(SemanticConvention.DB_OPERATION_STATUS,
response.status)
- span.set_attribute(SemanticConvetion.DB_VECTOR_COUNT,
+ span.set_attribute(SemanticConvention.DB_VECTOR_COUNT,
object_count(kwargs.get("points", [])))
- span.set_attribute(SemanticConvetion.DB_PAYLOAD_COUNT,
+ span.set_attribute(SemanticConvention.DB_PAYLOAD_COUNT,
object_count(kwargs.get("payload", [])))
elif gen_ai_endpoint == "qdrant.retrieve":
- db_operation = SemanticConvetion.DB_OPERATION_QUERY
- span.set_attribute(SemanticConvetion.DB_OPERATION_NAME,
- SemanticConvetion.DB_OPERATION_QUERY)
- span.set_attribute(SemanticConvetion.DB_COLLECTION_NAME,
+ db_operation = SemanticConvention.DB_OPERATION_QUERY
+ span.set_attribute(SemanticConvention.DB_OPERATION_NAME,
+ SemanticConvention.DB_OPERATION_QUERY)
+ span.set_attribute(SemanticConvention.DB_COLLECTION_NAME,
kwargs.get("collection_name", ""))
- span.set_attribute(SemanticConvetion.DB_STATEMENT,
+ span.set_attribute(SemanticConvention.DB_STATEMENT,
str(kwargs.get("ids", "")))
elif gen_ai_endpoint == "qdrant.scroll":
- db_operation = SemanticConvetion.DB_OPERATION_QUERY
- span.set_attribute(SemanticConvetion.DB_OPERATION_NAME,
- SemanticConvetion.DB_OPERATION_QUERY)
- span.set_attribute(SemanticConvetion.DB_COLLECTION_NAME,
+ db_operation = SemanticConvention.DB_OPERATION_QUERY
+ span.set_attribute(SemanticConvention.DB_OPERATION_NAME,
+ SemanticConvention.DB_OPERATION_QUERY)
+ span.set_attribute(SemanticConvention.DB_COLLECTION_NAME,
kwargs.get("collection_name", ""))
- span.set_attribute(SemanticConvetion.DB_STATEMENT,
+ span.set_attribute(SemanticConvention.DB_STATEMENT,
str(kwargs.get("scroll_filter", "")))
elif gen_ai_endpoint in ["qdrant.search", "qdrant.search_groups"]:
- db_operation = SemanticConvetion.DB_OPERATION_QUERY
- span.set_attribute(SemanticConvetion.DB_OPERATION_NAME,
- SemanticConvetion.DB_OPERATION_QUERY)
- span.set_attribute(SemanticConvetion.DB_COLLECTION_NAME,
+ db_operation = SemanticConvention.DB_OPERATION_QUERY
+ span.set_attribute(SemanticConvention.DB_OPERATION_NAME,
+ SemanticConvention.DB_OPERATION_QUERY)
+ span.set_attribute(SemanticConvention.DB_COLLECTION_NAME,
kwargs.get("collection_name", ""))
- span.set_attribute(SemanticConvetion.DB_STATEMENT,
+ span.set_attribute(SemanticConvention.DB_STATEMENT,
str(kwargs.get("query_vector", "")))
elif gen_ai_endpoint == "qdrant.recommend":
- db_operation = SemanticConvetion.DB_OPERATION_QUERY
- span.set_attribute(SemanticConvetion.DB_OPERATION_NAME,
- SemanticConvetion.DB_OPERATION_QUERY)
- span.set_attribute(SemanticConvetion.DB_COLLECTION_NAME,
+ db_operation = SemanticConvention.DB_OPERATION_QUERY
+ span.set_attribute(SemanticConvention.DB_OPERATION_NAME,
+ SemanticConvention.DB_OPERATION_QUERY)
+ span.set_attribute(SemanticConvention.DB_COLLECTION_NAME,
kwargs.get("collection_name", ""))
- span.set_attribute(SemanticConvetion.DB_STATEMENT,
+ span.set_attribute(SemanticConvention.DB_STATEMENT,
"positive:" + str(kwargs.get("positive", "")) +
" negative:" + str(kwargs.get("negative", "")))
elif gen_ai_endpoint == "qdrant.upload_points":
- db_operation = SemanticConvetion.DB_OPERATION_ADD
- span.set_attribute(SemanticConvetion.DB_OPERATION_NAME,
- SemanticConvetion.DB_OPERATION_ADD)
- span.set_attribute(SemanticConvetion.DB_COLLECTION_NAME,
+ db_operation = SemanticConvention.DB_OPERATION_ADD
+ span.set_attribute(SemanticConvention.DB_OPERATION_NAME,
+ SemanticConvention.DB_OPERATION_ADD)
+ span.set_attribute(SemanticConvention.DB_COLLECTION_NAME,
kwargs.get("collection_name", ""))
- span.set_attribute(SemanticConvetion.DB_VECTOR_COUNT,
+ span.set_attribute(SemanticConvention.DB_VECTOR_COUNT,
object_count(kwargs.get("points")))
elif gen_ai_endpoint == "qdrant.update_vectors":
- db_operation = SemanticConvetion.DB_OPERATION_UPDATE
- span.set_attribute(SemanticConvetion.DB_OPERATION_NAME,
- SemanticConvetion.DB_OPERATION_UPDATE)
- span.set_attribute(SemanticConvetion.DB_COLLECTION_NAME,
+ db_operation = SemanticConvention.DB_OPERATION_UPDATE
+ span.set_attribute(SemanticConvention.DB_OPERATION_NAME,
+ SemanticConvention.DB_OPERATION_UPDATE)
+ span.set_attribute(SemanticConvention.DB_COLLECTION_NAME,
kwargs.get("collection_name", ""))
- span.set_attribute(SemanticConvetion.DB_OPERATION_STATUS,
+ span.set_attribute(SemanticConvention.DB_OPERATION_STATUS,
response.status)
- span.set_attribute(SemanticConvetion.DB_VECTOR_COUNT,
+ span.set_attribute(SemanticConvention.DB_VECTOR_COUNT,
object_count(kwargs.get("points")))
elif gen_ai_endpoint == "qdrant.overwrite_payload":
- db_operation = SemanticConvetion.DB_OPERATION_UPDATE
- span.set_attribute(SemanticConvetion.DB_OPERATION_NAME,
- SemanticConvetion.DB_OPERATION_UPDATE)
- span.set_attribute(SemanticConvetion.DB_COLLECTION_NAME,
+ db_operation = SemanticConvention.DB_OPERATION_UPDATE
+ span.set_attribute(SemanticConvention.DB_OPERATION_NAME,
+ SemanticConvention.DB_OPERATION_UPDATE)
+ span.set_attribute(SemanticConvention.DB_COLLECTION_NAME,
kwargs.get("collection_name", ""))
- span.set_attribute(SemanticConvetion.DB_OPERATION_STATUS,
+ span.set_attribute(SemanticConvention.DB_OPERATION_STATUS,
response.status)
- span.set_attribute(SemanticConvetion.DB_VECTOR_COUNT,
+ span.set_attribute(SemanticConvention.DB_VECTOR_COUNT,
object_count(kwargs.get("points")))
- span.set_attribute(SemanticConvetion.DB_PAYLOAD_COUNT,
+ span.set_attribute(SemanticConvention.DB_PAYLOAD_COUNT,
object_count(kwargs.get("payload")))
elif gen_ai_endpoint == "qdrant.upsert":
- db_operation = SemanticConvetion.DB_OPERATION_UPSERT
- span.set_attribute(SemanticConvetion.DB_COLLECTION_NAME,
+ db_operation = SemanticConvention.DB_OPERATION_UPSERT
+ span.set_attribute(SemanticConvention.DB_COLLECTION_NAME,
kwargs.get("collection_name", ""))
- span.set_attribute(SemanticConvetion.DB_OPERATION_NAME,
- SemanticConvetion.DB_OPERATION_UPSERT)
- span.set_attribute(SemanticConvetion.DB_OPERATION_STATUS,
+ span.set_attribute(SemanticConvention.DB_OPERATION_NAME,
+ SemanticConvention.DB_OPERATION_UPSERT)
+ span.set_attribute(SemanticConvention.DB_OPERATION_STATUS,
response.status)
- span.set_attribute(SemanticConvetion.DB_VECTOR_COUNT,
+ span.set_attribute(SemanticConvention.DB_VECTOR_COUNT,
object_count(kwargs.get("points")))
elif gen_ai_endpoint in ["qdrant.delete_payload", "qdrant.delete_vectors"]:
- db_operation = SemanticConvetion.DB_OPERATION_DELETE
- span.set_attribute(SemanticConvetion.DB_OPERATION_NAME,
- SemanticConvetion.DB_OPERATION_DELETE)
- span.set_attribute(SemanticConvetion.DB_COLLECTION_NAME,
+ db_operation = SemanticConvention.DB_OPERATION_DELETE
+ span.set_attribute(SemanticConvention.DB_OPERATION_NAME,
+ SemanticConvention.DB_OPERATION_DELETE)
+ span.set_attribute(SemanticConvention.DB_COLLECTION_NAME,
kwargs.get("collection_name", ""))
- span.set_attribute(SemanticConvetion.DB_OPERATION_STATUS,
+ span.set_attribute(SemanticConvention.DB_OPERATION_STATUS,
response.status)
- span.set_attribute(SemanticConvetion.DB_VECTOR_COUNT,
+ span.set_attribute(SemanticConvention.DB_VECTOR_COUNT,
object_count(kwargs.get("points")))
elif gen_ai_endpoint in ["qdrant.clear_payload", "qdrant.delete"]:
- db_operation = SemanticConvetion.DB_OPERATION_DELETE
- span.set_attribute(SemanticConvetion.DB_OPERATION_NAME,
- SemanticConvetion.DB_OPERATION_DELETE)
- span.set_attribute(SemanticConvetion.DB_COLLECTION_NAME,
+ db_operation = SemanticConvention.DB_OPERATION_DELETE
+ span.set_attribute(SemanticConvention.DB_OPERATION_NAME,
+ SemanticConvention.DB_OPERATION_DELETE)
+ span.set_attribute(SemanticConvention.DB_COLLECTION_NAME,
kwargs.get("collection_name", ""))
- span.set_attribute(SemanticConvetion.DB_OPERATION_STATUS,
+ span.set_attribute(SemanticConvention.DB_OPERATION_STATUS,
response.status)
- span.set_attribute(SemanticConvetion.DB_VECTOR_COUNT,
+ span.set_attribute(SemanticConvention.DB_VECTOR_COUNT,
object_count(kwargs.get("points_selector")))
elif gen_ai_endpoint == "qdrant.create_payload_index":
- db_operation = SemanticConvetion.DB_OPERATION_CREATE_INDEX
- span.set_attribute(SemanticConvetion.DB_OPERATION_NAME,
- SemanticConvetion.DB_OPERATION_CREATE_INDEX)
- span.set_attribute(SemanticConvetion.DB_COLLECTION_NAME,
+ db_operation = SemanticConvention.DB_OPERATION_CREATE_INDEX
+ span.set_attribute(SemanticConvention.DB_OPERATION_NAME,
+ SemanticConvention.DB_OPERATION_CREATE_INDEX)
+ span.set_attribute(SemanticConvention.DB_COLLECTION_NAME,
kwargs.get("collection_name", ""))
elif gen_ai_endpoint == "qdrant.query_points":
- db_operation = SemanticConvetion.DB_OPERATION_QUERY
- span.set_attribute(SemanticConvetion.DB_OPERATION_NAME,
- SemanticConvetion.DB_OPERATION_QUERY)
- span.set_attribute(SemanticConvetion.DB_COLLECTION_NAME,
+ db_operation = SemanticConvention.DB_OPERATION_QUERY
+ span.set_attribute(SemanticConvention.DB_OPERATION_NAME,
+ SemanticConvention.DB_OPERATION_QUERY)
+ span.set_attribute(SemanticConvention.DB_COLLECTION_NAME,
kwargs.get("collection_name", ""))
- span.set_attribute(SemanticConvetion.DB_STATEMENT,
+ span.set_attribute(SemanticConvention.DB_STATEMENT,
str(kwargs.get("query", "")))
span.set_status(Status(StatusCode.OK))
@@ -250,13 +250,13 @@ def general_wrap(gen_ai_endpoint, version, environment, application_name,
"openlit",
SERVICE_NAME:
application_name,
- SemanticConvetion.DB_SYSTEM_NAME:
- SemanticConvetion.DB_SYSTEM_QDRANT,
+ SemanticConvention.DB_SYSTEM_NAME:
+ SemanticConvention.DB_SYSTEM_QDRANT,
DEPLOYMENT_ENVIRONMENT:
environment,
- SemanticConvetion.GEN_AI_OPERATION:
- SemanticConvetion.GEN_AI_OPERATION_TYPE_VECTORDB,
- SemanticConvetion.DB_OPERATION_NAME:
+ SemanticConvention.GEN_AI_OPERATION:
+ SemanticConvention.GEN_AI_OPERATION_TYPE_VECTORDB,
+ SemanticConvention.DB_OPERATION_NAME:
db_operation
}
diff --git a/sdk/python/src/openlit/instrumentation/reka/async_reka.py b/sdk/python/src/openlit/instrumentation/reka/async_reka.py
index e35fc077..267f73e7 100644
--- a/sdk/python/src/openlit/instrumentation/reka/async_reka.py
+++ b/sdk/python/src/openlit/instrumentation/reka/async_reka.py
@@ -12,7 +12,7 @@ from openlit.__helpers import (
create_metrics_attributes,
set_server_address_and_port
)
-from openlit.semcov import SemanticConvetion
+from openlit.semcov import SemanticConvention
# Initialize logger for logging potential issues and operations
logger = logging.getLogger(__name__)
@@ -54,7 +54,7 @@ def async_chat(version, environment, application_name,
server_address, server_port = set_server_address_and_port(instance, "api.reka.ai", 443)
request_model = kwargs.get("model", "reka-core-20240501")
- span_name = f"{SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT} {request_model}"
+ span_name = f"{SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT} {request_model}"
with tracer.start_as_current_span(span_name, kind= SpanKind.CLIENT) as span:
start_time = time.time()
@@ -89,41 +89,41 @@ def async_chat(version, environment, application_name,
# Set Span attributes (OTel Semconv)
span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
- span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
- SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT)
- span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
- SemanticConvetion.GEN_AI_SYSTEM_REKAAI)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT)
+ span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
+ SemanticConvention.GEN_AI_SYSTEM_REKAAI)
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
request_model)
- span.set_attribute(SemanticConvetion.SERVER_PORT,
+ span.set_attribute(SemanticConvention.SERVER_PORT,
server_port)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_SEED,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_SEED,
kwargs.get("seed", ""))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MAX_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS,
kwargs.get("max_tokens", -1))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_STOP_SEQUENCES,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_STOP_SEQUENCES,
kwargs.get("stop", []))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_PRESENCE_PENALTY,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_PRESENCE_PENALTY,
kwargs.get("presence_penalty", 0.0))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TEMPERATURE,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TEMPERATURE,
kwargs.get("temperature", 0.4))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TOP_K,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TOP_K,
kwargs.get("top_k", 1.0))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TOP_P,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TOP_P,
kwargs.get("top_p", 1.0))
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_FINISH_REASON,
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON,
[response.responses[0].finish_reason])
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_ID,
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_ID,
response.id)
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL,
response.model)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_INPUT_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS,
input_tokens)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_OUTPUT_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS,
output_tokens)
- span.set_attribute(SemanticConvetion.SERVER_ADDRESS,
+ span.set_attribute(SemanticConvention.SERVER_ADDRESS,
server_address)
- span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
+ span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
'text')
# Set Span attributes (Extra)
@@ -131,28 +131,28 @@ def async_chat(version, environment, application_name,
environment)
span.set_attribute(SERVICE_NAME,
application_name)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IS_STREAM,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM,
False)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_TOTAL_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS,
input_tokens + output_tokens)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST,
cost)
- span.set_attribute(SemanticConvetion.GEN_AI_SERVER_TTFT,
+ span.set_attribute(SemanticConvention.GEN_AI_SERVER_TTFT,
end_time - start_time)
- span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
+ span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION,
version)
if capture_message_content:
span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_PROMPT: prompt,
+ SemanticConvention.GEN_AI_CONTENT_PROMPT: prompt,
},
)
span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_COMPLETION_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_COMPLETION_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_COMPLETION: response.responses[0].message.content,
+ SemanticConvention.GEN_AI_CONTENT_COMPLETION: response.responses[0].message.content,
},
)
@@ -162,8 +162,8 @@ def async_chat(version, environment, application_name,
attributes = create_metrics_attributes(
service_name=application_name,
deployment_environment=environment,
- operation=SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT,
- system=SemanticConvetion.GEN_AI_SYSTEM_REKAAI,
+ operation=SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
+ system=SemanticConvention.GEN_AI_SYSTEM_REKAAI,
request_model=request_model,
server_address=server_address,
server_port=server_port,
diff --git a/sdk/python/src/openlit/instrumentation/reka/reka.py b/sdk/python/src/openlit/instrumentation/reka/reka.py
index 755f799c..695f5843 100644
--- a/sdk/python/src/openlit/instrumentation/reka/reka.py
+++ b/sdk/python/src/openlit/instrumentation/reka/reka.py
@@ -12,7 +12,7 @@ from openlit.__helpers import (
create_metrics_attributes,
set_server_address_and_port
)
-from openlit.semcov import SemanticConvetion
+from openlit.semcov import SemanticConvention
# Initialize logger for logging potential issues and operations
logger = logging.getLogger(__name__)
@@ -54,7 +54,7 @@ def chat(version, environment, application_name,
server_address, server_port = set_server_address_and_port(instance, "api.reka.ai", 443)
request_model = kwargs.get("model", "reka-core-20240501")
- span_name = f"{SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT} {request_model}"
+ span_name = f"{SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT} {request_model}"
with tracer.start_as_current_span(span_name, kind= SpanKind.CLIENT) as span:
start_time = time.time()
@@ -89,41 +89,41 @@ def chat(version, environment, application_name,
# Set Span attributes (OTel Semconv)
span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
- span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
- SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT)
- span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
- SemanticConvetion.GEN_AI_SYSTEM_REKAAI)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT)
+ span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
+ SemanticConvention.GEN_AI_SYSTEM_REKAAI)
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
request_model)
- span.set_attribute(SemanticConvetion.SERVER_PORT,
+ span.set_attribute(SemanticConvention.SERVER_PORT,
server_port)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_SEED,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_SEED,
kwargs.get("seed", ""))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MAX_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS,
kwargs.get("max_tokens", -1))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_STOP_SEQUENCES,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_STOP_SEQUENCES,
kwargs.get("stop", []))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_PRESENCE_PENALTY,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_PRESENCE_PENALTY,
kwargs.get("presence_penalty", 0.0))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TEMPERATURE,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TEMPERATURE,
kwargs.get("temperature", 0.4))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TOP_K,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TOP_K,
kwargs.get("top_k", 1.0))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TOP_P,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TOP_P,
kwargs.get("top_p", 1.0))
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_FINISH_REASON,
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON,
[response.responses[0].finish_reason])
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_ID,
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_ID,
response.id)
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL,
response.model)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_INPUT_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS,
input_tokens)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_OUTPUT_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS,
output_tokens)
- span.set_attribute(SemanticConvetion.SERVER_ADDRESS,
+ span.set_attribute(SemanticConvention.SERVER_ADDRESS,
server_address)
- span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
+ span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
'text')
# Set Span attributes (Extra)
@@ -131,28 +131,28 @@ def chat(version, environment, application_name,
environment)
span.set_attribute(SERVICE_NAME,
application_name)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IS_STREAM,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM,
False)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_TOTAL_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS,
input_tokens + output_tokens)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST,
cost)
- span.set_attribute(SemanticConvetion.GEN_AI_SERVER_TTFT,
+ span.set_attribute(SemanticConvention.GEN_AI_SERVER_TTFT,
end_time - start_time)
- span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
+ span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION,
version)
if capture_message_content:
span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_PROMPT: prompt,
+ SemanticConvention.GEN_AI_CONTENT_PROMPT: prompt,
},
)
span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_COMPLETION_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_COMPLETION_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_COMPLETION: response.responses[0].message.content,
+ SemanticConvention.GEN_AI_CONTENT_COMPLETION: response.responses[0].message.content,
},
)
@@ -162,8 +162,8 @@ def chat(version, environment, application_name,
attributes = create_metrics_attributes(
service_name=application_name,
deployment_environment=environment,
- operation=SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT,
- system=SemanticConvetion.GEN_AI_SYSTEM_REKAAI,
+ operation=SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
+ system=SemanticConvention.GEN_AI_SYSTEM_REKAAI,
request_model=request_model,
server_address=server_address,
server_port=server_port,
diff --git a/sdk/python/src/openlit/instrumentation/together/async_together.py b/sdk/python/src/openlit/instrumentation/together/async_together.py
index 8fd20a03..6d7645b4 100644
--- a/sdk/python/src/openlit/instrumentation/together/async_together.py
+++ b/sdk/python/src/openlit/instrumentation/together/async_together.py
@@ -16,7 +16,7 @@ from openlit.__helpers import (
create_metrics_attributes,
set_server_address_and_port
)
-from openlit.semcov import SemanticConvetion
+from openlit.semcov import SemanticConvention
# Initialize logger for logging potential issues and operations
logger = logging.getLogger(__name__)
@@ -157,46 +157,46 @@ def async_completion(version, environment, application_name,
# Set Span attributes (OTel Semconv)
self._span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
- self._span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
- SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT)
- self._span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
- SemanticConvetion.GEN_AI_SYSTEM_TOGETHER)
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
+ self._span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT)
+ self._span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
+ SemanticConvention.GEN_AI_SYSTEM_TOGETHER)
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
request_model)
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_SEED,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_SEED,
self._kwargs.get("seed", ""))
- self._span.set_attribute(SemanticConvetion.SERVER_PORT,
+ self._span.set_attribute(SemanticConvention.SERVER_PORT,
self._server_port)
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_FREQUENCY_PENALTY,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_FREQUENCY_PENALTY,
self._kwargs.get("frequency_penalty", 0.0))
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MAX_TOKENS,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS,
self._kwargs.get("max_tokens", -1))
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_PRESENCE_PENALTY,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_PRESENCE_PENALTY,
self._kwargs.get("presence_penalty", 0.0))
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_STOP_SEQUENCES,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_STOP_SEQUENCES,
self._kwargs.get("stop", []))
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TEMPERATURE,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TEMPERATURE,
self._kwargs.get("temperature", 1.0))
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TOP_P,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TOP_P,
self._kwargs.get("top_p", 1.0))
- self._span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_FINISH_REASON,
+ self._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON,
[self._finish_reason])
- self._span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_ID,
+ self._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_ID,
self._response_id)
- self._span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_MODEL,
+ self._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL,
self._response_model)
- self._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_INPUT_TOKENS,
+ self._span.set_attribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS,
self._input_tokens)
- self._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_OUTPUT_TOKENS,
+ self._span.set_attribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS,
self._output_tokens)
- self._span.set_attribute(SemanticConvetion.SERVER_ADDRESS,
+ self._span.set_attribute(SemanticConvention.SERVER_ADDRESS,
self._server_address)
if isinstance(self._llmresponse, str):
- self._span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
+ self._span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
"text")
else:
- self._span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
+ self._span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
"json")
# Set Span attributes (Extra)
@@ -204,31 +204,31 @@ def async_completion(version, environment, application_name,
environment)
self._span.set_attribute(SERVICE_NAME,
application_name)
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_USER,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_USER,
self._kwargs.get("user", ""))
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IS_STREAM,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM,
True)
- self._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_TOTAL_TOKENS,
+ self._span.set_attribute(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS,
self._input_tokens + self._output_tokens)
- self._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
+ self._span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST,
cost)
- self._span.set_attribute(SemanticConvetion.GEN_AI_SERVER_TBT,
+ self._span.set_attribute(SemanticConvention.GEN_AI_SERVER_TBT,
self._tbt)
- self._span.set_attribute(SemanticConvetion.GEN_AI_SERVER_TTFT,
+ self._span.set_attribute(SemanticConvention.GEN_AI_SERVER_TTFT,
self._ttft)
- self._span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
+ self._span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION,
version)
if capture_message_content:
self._span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_PROMPT: prompt,
+ SemanticConvention.GEN_AI_CONTENT_PROMPT: prompt,
},
)
self._span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_COMPLETION_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_COMPLETION_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_COMPLETION: self._llmresponse,
+ SemanticConvention.GEN_AI_CONTENT_COMPLETION: self._llmresponse,
},
)
self._span.set_status(Status(StatusCode.OK))
@@ -237,8 +237,8 @@ def async_completion(version, environment, application_name,
attributes = create_metrics_attributes(
service_name=application_name,
deployment_environment=environment,
- operation=SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT,
- system=SemanticConvetion.GEN_AI_SYSTEM_TOGETHER,
+ operation=SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
+ system=SemanticConvention.GEN_AI_SYSTEM_TOGETHER,
request_model=request_model,
server_address=self._server_address,
server_port=self._server_port,
@@ -290,7 +290,7 @@ def async_completion(version, environment, application_name,
server_address, server_port = set_server_address_and_port(instance, "api.together.xyz", 443)
request_model = kwargs.get("model", "gpt-4o")
- span_name = f"{SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT} {request_model}"
+ span_name = f"{SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT} {request_model}"
# pylint: disable=no-else-return
if streaming:
@@ -338,37 +338,37 @@ def async_completion(version, environment, application_name,
# Set base span attribues (OTel Semconv)
span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
- span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
- SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT)
- span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
- SemanticConvetion.GEN_AI_SYSTEM_TOGETHER)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT)
+ span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
+ SemanticConvention.GEN_AI_SYSTEM_TOGETHER)
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
request_model)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_SEED,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_SEED,
kwargs.get("seed", ""))
- span.set_attribute(SemanticConvetion.SERVER_PORT,
+ span.set_attribute(SemanticConvention.SERVER_PORT,
server_port)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_FREQUENCY_PENALTY,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_FREQUENCY_PENALTY,
kwargs.get("frequency_penalty", 0.0))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MAX_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS,
kwargs.get("max_tokens", -1))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_PRESENCE_PENALTY,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_PRESENCE_PENALTY,
kwargs.get("presence_penalty", 0.0))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_STOP_SEQUENCES,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_STOP_SEQUENCES,
kwargs.get("stop", []))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TEMPERATURE,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TEMPERATURE,
kwargs.get("temperature", 1.0))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TOP_P,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TOP_P,
kwargs.get("top_p", 1.0))
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_ID,
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_ID,
response_dict.get("id"))
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL,
response_dict.get('model'))
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_INPUT_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS,
input_tokens)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_OUTPUT_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS,
output_tokens)
- span.set_attribute(SemanticConvetion.SERVER_ADDRESS,
+ span.set_attribute(SemanticConvention.SERVER_ADDRESS,
server_address)
# Set base span attribues (Extras)
@@ -376,46 +376,46 @@ def async_completion(version, environment, application_name,
environment)
span.set_attribute(SERVICE_NAME,
application_name)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_USER,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_USER,
kwargs.get("user", ""))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IS_STREAM,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM,
False)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_TOTAL_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS,
input_tokens + output_tokens)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST,
cost)
- span.set_attribute(SemanticConvetion.GEN_AI_SERVER_TTFT,
+ span.set_attribute(SemanticConvention.GEN_AI_SERVER_TTFT,
end_time - start_time)
- span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
+ span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION,
version)
if capture_message_content:
span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_PROMPT: prompt,
+ SemanticConvention.GEN_AI_CONTENT_PROMPT: prompt,
},
)
for i in range(kwargs.get('n',1)):
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_FINISH_REASON,
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON,
[str(response_dict.get('choices')[i].get('finish_reason'))])
if capture_message_content:
span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_COMPLETION_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_COMPLETION_EVENT,
attributes={
# pylint: disable=line-too-long
- SemanticConvetion.GEN_AI_CONTENT_COMPLETION: str(response_dict.get('choices')[i].get('message').get('content')),
+ SemanticConvention.GEN_AI_CONTENT_COMPLETION: str(response_dict.get('choices')[i].get('message').get('content')),
},
)
if kwargs.get('tools'):
- span.set_attribute(SemanticConvetion.GEN_AI_TOOL_CALLS,
+ span.set_attribute(SemanticConvention.GEN_AI_TOOL_CALLS,
str(response_dict.get('choices')[i].get('message').get('tool_calls')))
if isinstance(response_dict.get('choices')[i].get('message').get('content'), str):
- span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
+ span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
"text")
elif response_dict.get('choices')[i].get('message').get('content') is not None:
- span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
+ span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
"json")
span.set_status(Status(StatusCode.OK))
@@ -424,8 +424,8 @@ def async_completion(version, environment, application_name,
attributes = create_metrics_attributes(
service_name=application_name,
deployment_environment=environment,
- operation=SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT,
- system=SemanticConvetion.GEN_AI_SYSTEM_TOGETHER,
+ operation=SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
+ system=SemanticConvention.GEN_AI_SYSTEM_TOGETHER,
request_model=request_model,
server_address=server_address,
server_port=server_port,
@@ -495,7 +495,7 @@ def async_image_generate(version, environment, application_name,
server_address, server_port = set_server_address_and_port(instance, "api.together.xyz", 443)
request_model = kwargs.get("model", "dall-e-2")
- span_name = f"{SemanticConvetion.GEN_AI_OPERATION_TYPE_IMAGE} {request_model}"
+ span_name = f"{SemanticConvention.GEN_AI_OPERATION_TYPE_IMAGE} {request_model}"
with tracer.start_as_current_span(span_name, kind= SpanKind.CLIENT) as span:
start_time = time.time()
@@ -521,21 +521,21 @@ def async_image_generate(version, environment, application_name,
for items in response.data:
# Set Span attributes (OTel Semconv)
span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
- span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
- SemanticConvetion.GEN_AI_OPERATION_TYPE_IMAGE)
- span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
- SemanticConvetion.GEN_AI_SYSTEM_TOGETHER)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_IMAGE)
+ span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
+ SemanticConvention.GEN_AI_SYSTEM_TOGETHER)
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
request_model)
- span.set_attribute(SemanticConvetion.SERVER_ADDRESS,
+ span.set_attribute(SemanticConvention.SERVER_ADDRESS,
server_address)
- span.set_attribute(SemanticConvetion.SERVER_PORT,
+ span.set_attribute(SemanticConvention.SERVER_PORT,
server_port)
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_ID,
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_ID,
response.id)
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL,
response.model)
- span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
+ span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
"image")
# Set Span attributes (Extras)
@@ -543,29 +543,29 @@ def async_image_generate(version, environment, application_name,
environment)
span.set_attribute(SERVICE_NAME,
application_name)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IMAGE_SIZE,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_IMAGE_SIZE,
image_size)
- span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
+ span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION,
version)
if capture_message_content:
span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_PROMPT: kwargs.get("prompt", ""),
+ SemanticConvention.GEN_AI_CONTENT_PROMPT: kwargs.get("prompt", ""),
},
)
- attribute_name = f"{SemanticConvetion.GEN_AI_RESPONSE_IMAGE}.{images_count}"
+ attribute_name = f"{SemanticConvention.GEN_AI_RESPONSE_IMAGE}.{images_count}"
span.add_event(
name=attribute_name,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_COMPLETION: getattr(items, image),
+ SemanticConvention.GEN_AI_CONTENT_COMPLETION: getattr(items, image),
},
)
images_count+=1
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST,
len(response.data) * cost)
span.set_status(Status(StatusCode.OK))
@@ -573,8 +573,8 @@ def async_image_generate(version, environment, application_name,
attributes = create_metrics_attributes(
service_name=application_name,
deployment_environment=environment,
- operation=SemanticConvetion.GEN_AI_OPERATION_TYPE_IMAGE,
- system=SemanticConvetion.GEN_AI_SYSTEM_TOGETHER,
+ operation=SemanticConvention.GEN_AI_OPERATION_TYPE_IMAGE,
+ system=SemanticConvention.GEN_AI_SYSTEM_TOGETHER,
request_model=request_model,
server_address=server_address,
server_port=server_port,
diff --git a/sdk/python/src/openlit/instrumentation/together/together.py b/sdk/python/src/openlit/instrumentation/together/together.py
index cd775962..0fced46c 100644
--- a/sdk/python/src/openlit/instrumentation/together/together.py
+++ b/sdk/python/src/openlit/instrumentation/together/together.py
@@ -16,7 +16,7 @@ from openlit.__helpers import (
create_metrics_attributes,
set_server_address_and_port
)
-from openlit.semcov import SemanticConvetion
+from openlit.semcov import SemanticConvention
# Initialize logger for logging potential issues and operations
logger = logging.getLogger(__name__)
@@ -157,46 +157,46 @@ def completion(version, environment, application_name,
# Set Span attributes (OTel Semconv)
self._span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
- self._span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
- SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT)
- self._span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
- SemanticConvetion.GEN_AI_SYSTEM_TOGETHER)
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
+ self._span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT)
+ self._span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
+ SemanticConvention.GEN_AI_SYSTEM_TOGETHER)
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
request_model)
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_SEED,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_SEED,
self._kwargs.get("seed", ""))
- self._span.set_attribute(SemanticConvetion.SERVER_PORT,
+ self._span.set_attribute(SemanticConvention.SERVER_PORT,
self._server_port)
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_FREQUENCY_PENALTY,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_FREQUENCY_PENALTY,
self._kwargs.get("frequency_penalty", 0.0))
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MAX_TOKENS,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS,
self._kwargs.get("max_tokens", -1))
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_PRESENCE_PENALTY,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_PRESENCE_PENALTY,
self._kwargs.get("presence_penalty", 0.0))
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_STOP_SEQUENCES,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_STOP_SEQUENCES,
self._kwargs.get("stop", []))
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TEMPERATURE,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TEMPERATURE,
self._kwargs.get("temperature", 1.0))
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TOP_P,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TOP_P,
self._kwargs.get("top_p", 1.0))
- self._span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_FINISH_REASON,
+ self._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON,
[self._finish_reason])
- self._span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_ID,
+ self._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_ID,
self._response_id)
- self._span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_MODEL,
+ self._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL,
self._response_model)
- self._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_INPUT_TOKENS,
+ self._span.set_attribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS,
self._input_tokens)
- self._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_OUTPUT_TOKENS,
+ self._span.set_attribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS,
self._output_tokens)
- self._span.set_attribute(SemanticConvetion.SERVER_ADDRESS,
+ self._span.set_attribute(SemanticConvention.SERVER_ADDRESS,
self._server_address)
if isinstance(self._llmresponse, str):
- self._span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
+ self._span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
"text")
else:
- self._span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
+ self._span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
"json")
# Set Span attributes (Extra)
@@ -204,31 +204,31 @@ def completion(version, environment, application_name,
environment)
self._span.set_attribute(SERVICE_NAME,
application_name)
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_USER,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_USER,
self._kwargs.get("user", ""))
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IS_STREAM,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM,
True)
- self._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_TOTAL_TOKENS,
+ self._span.set_attribute(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS,
self._input_tokens + self._output_tokens)
- self._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
+ self._span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST,
cost)
- self._span.set_attribute(SemanticConvetion.GEN_AI_SERVER_TBT,
+ self._span.set_attribute(SemanticConvention.GEN_AI_SERVER_TBT,
self._tbt)
- self._span.set_attribute(SemanticConvetion.GEN_AI_SERVER_TTFT,
+ self._span.set_attribute(SemanticConvention.GEN_AI_SERVER_TTFT,
self._ttft)
- self._span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
+ self._span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION,
version)
if capture_message_content:
self._span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_PROMPT: prompt,
+ SemanticConvention.GEN_AI_CONTENT_PROMPT: prompt,
},
)
self._span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_COMPLETION_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_COMPLETION_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_COMPLETION: self._llmresponse,
+ SemanticConvention.GEN_AI_CONTENT_COMPLETION: self._llmresponse,
},
)
self._span.set_status(Status(StatusCode.OK))
@@ -237,8 +237,8 @@ def completion(version, environment, application_name,
attributes = create_metrics_attributes(
service_name=application_name,
deployment_environment=environment,
- operation=SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT,
- system=SemanticConvetion.GEN_AI_SYSTEM_TOGETHER,
+ operation=SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
+ system=SemanticConvention.GEN_AI_SYSTEM_TOGETHER,
request_model=request_model,
server_address=self._server_address,
server_port=self._server_port,
@@ -290,7 +290,7 @@ def completion(version, environment, application_name,
server_address, server_port = set_server_address_and_port(instance, "api.together.xyz", 443)
request_model = kwargs.get("model", "gpt-4o")
- span_name = f"{SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT} {request_model}"
+ span_name = f"{SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT} {request_model}"
# pylint: disable=no-else-return
if streaming:
@@ -338,37 +338,37 @@ def completion(version, environment, application_name,
# Set base span attribues (OTel Semconv)
span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
- span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
- SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT)
- span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
- SemanticConvetion.GEN_AI_SYSTEM_TOGETHER)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT)
+ span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
+ SemanticConvention.GEN_AI_SYSTEM_TOGETHER)
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
request_model)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_SEED,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_SEED,
kwargs.get("seed", ""))
- span.set_attribute(SemanticConvetion.SERVER_PORT,
+ span.set_attribute(SemanticConvention.SERVER_PORT,
server_port)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_FREQUENCY_PENALTY,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_FREQUENCY_PENALTY,
kwargs.get("frequency_penalty", 0.0))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MAX_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS,
kwargs.get("max_tokens", -1))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_PRESENCE_PENALTY,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_PRESENCE_PENALTY,
kwargs.get("presence_penalty", 0.0))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_STOP_SEQUENCES,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_STOP_SEQUENCES,
kwargs.get("stop", []))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TEMPERATURE,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TEMPERATURE,
kwargs.get("temperature", 1.0))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TOP_P,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TOP_P,
kwargs.get("top_p", 1.0))
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_ID,
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_ID,
response_dict.get("id"))
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL,
response_dict.get('model'))
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_INPUT_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS,
input_tokens)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_OUTPUT_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS,
output_tokens)
- span.set_attribute(SemanticConvetion.SERVER_ADDRESS,
+ span.set_attribute(SemanticConvention.SERVER_ADDRESS,
server_address)
# Set base span attribues (Extras)
@@ -376,46 +376,46 @@ def completion(version, environment, application_name,
environment)
span.set_attribute(SERVICE_NAME,
application_name)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_USER,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_USER,
kwargs.get("user", ""))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IS_STREAM,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM,
False)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_TOTAL_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS,
input_tokens + output_tokens)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST,
cost)
- span.set_attribute(SemanticConvetion.GEN_AI_SERVER_TTFT,
+ span.set_attribute(SemanticConvention.GEN_AI_SERVER_TTFT,
end_time - start_time)
- span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
+ span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION,
version)
if capture_message_content:
span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_PROMPT: prompt,
+ SemanticConvention.GEN_AI_CONTENT_PROMPT: prompt,
},
)
for i in range(kwargs.get('n',1)):
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_FINISH_REASON,
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON,
[str(response_dict.get('choices')[i].get('finish_reason'))])
if capture_message_content:
span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_COMPLETION_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_COMPLETION_EVENT,
attributes={
# pylint: disable=line-too-long
- SemanticConvetion.GEN_AI_CONTENT_COMPLETION: str(response_dict.get('choices')[i].get('message').get('content')),
+ SemanticConvention.GEN_AI_CONTENT_COMPLETION: str(response_dict.get('choices')[i].get('message').get('content')),
},
)
if kwargs.get('tools'):
- span.set_attribute(SemanticConvetion.GEN_AI_TOOL_CALLS,
+ span.set_attribute(SemanticConvention.GEN_AI_TOOL_CALLS,
str(response_dict.get('choices')[i].get('message').get('tool_calls')))
if isinstance(response_dict.get('choices')[i].get('message').get('content'), str):
- span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
+ span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
"text")
elif response_dict.get('choices')[i].get('message').get('content') is not None:
- span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
+ span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
"json")
span.set_status(Status(StatusCode.OK))
@@ -424,8 +424,8 @@ def completion(version, environment, application_name,
attributes = create_metrics_attributes(
service_name=application_name,
deployment_environment=environment,
- operation=SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT,
- system=SemanticConvetion.GEN_AI_SYSTEM_TOGETHER,
+ operation=SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
+ system=SemanticConvention.GEN_AI_SYSTEM_TOGETHER,
request_model=request_model,
server_address=server_address,
server_port=server_port,
@@ -495,7 +495,7 @@ def image_generate(version, environment, application_name,
server_address, server_port = set_server_address_and_port(instance, "api.together.xyz", 443)
request_model = kwargs.get("model", "dall-e-2")
- span_name = f"{SemanticConvetion.GEN_AI_OPERATION_TYPE_IMAGE} {request_model}"
+ span_name = f"{SemanticConvention.GEN_AI_OPERATION_TYPE_IMAGE} {request_model}"
with tracer.start_as_current_span(span_name, kind= SpanKind.CLIENT) as span:
start_time = time.time()
@@ -521,21 +521,21 @@ def image_generate(version, environment, application_name,
for items in response.data:
# Set Span attributes (OTel Semconv)
span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
- span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
- SemanticConvetion.GEN_AI_OPERATION_TYPE_IMAGE)
- span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
- SemanticConvetion.GEN_AI_SYSTEM_TOGETHER)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_IMAGE)
+ span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
+ SemanticConvention.GEN_AI_SYSTEM_TOGETHER)
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
request_model)
- span.set_attribute(SemanticConvetion.SERVER_ADDRESS,
+ span.set_attribute(SemanticConvention.SERVER_ADDRESS,
server_address)
- span.set_attribute(SemanticConvetion.SERVER_PORT,
+ span.set_attribute(SemanticConvention.SERVER_PORT,
server_port)
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_ID,
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_ID,
response.id)
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL,
response.model)
- span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
+ span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
"image")
# Set Span attributes (Extras)
@@ -543,29 +543,29 @@ def image_generate(version, environment, application_name,
environment)
span.set_attribute(SERVICE_NAME,
application_name)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IMAGE_SIZE,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_IMAGE_SIZE,
image_size)
- span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
+ span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION,
version)
if capture_message_content:
span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_PROMPT: kwargs.get("prompt", ""),
+ SemanticConvention.GEN_AI_CONTENT_PROMPT: kwargs.get("prompt", ""),
},
)
- attribute_name = f"{SemanticConvetion.GEN_AI_RESPONSE_IMAGE}.{images_count}"
+ attribute_name = f"{SemanticConvention.GEN_AI_RESPONSE_IMAGE}.{images_count}"
span.add_event(
name=attribute_name,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_COMPLETION: getattr(items, image),
+ SemanticConvention.GEN_AI_CONTENT_COMPLETION: getattr(items, image),
},
)
images_count+=1
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST,
len(response.data) * cost)
span.set_status(Status(StatusCode.OK))
@@ -573,8 +573,8 @@ def image_generate(version, environment, application_name,
attributes = create_metrics_attributes(
service_name=application_name,
deployment_environment=environment,
- operation=SemanticConvetion.GEN_AI_OPERATION_TYPE_IMAGE,
- system=SemanticConvetion.GEN_AI_SYSTEM_TOGETHER,
+ operation=SemanticConvention.GEN_AI_OPERATION_TYPE_IMAGE,
+ system=SemanticConvention.GEN_AI_SYSTEM_TOGETHER,
request_model=request_model,
server_address=server_address,
server_port=server_port,
diff --git a/sdk/python/src/openlit/instrumentation/transformers/transformers.py b/sdk/python/src/openlit/instrumentation/transformers/transformers.py
index 8a1550c8..d5a6f20f 100644
--- a/sdk/python/src/openlit/instrumentation/transformers/transformers.py
+++ b/sdk/python/src/openlit/instrumentation/transformers/transformers.py
@@ -13,7 +13,7 @@ from openlit.__helpers import (
create_metrics_attributes,
set_server_address_and_port
)
-from openlit.semcov import SemanticConvetion
+from openlit.semcov import SemanticConvention
# Initialize logger for logging potential issues and operations
logger = logging.getLogger(__name__)
@@ -63,7 +63,7 @@ def text_wrap(version, environment, application_name,
server_address, server_port = set_server_address_and_port(instance, "127.0.0.1", 80)
request_model = instance.model.config.name_or_path
- span_name = f"{SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT} {request_model}"
+ span_name = f"{SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT} {request_model}"
with tracer.start_as_current_span(span_name, kind= SpanKind.CLIENT) as span:
start_time = time.time()
@@ -82,42 +82,42 @@ def text_wrap(version, environment, application_name,
input_tokens = general_tokens(prompt[0])
span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
- span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
- SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT)
- span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
- SemanticConvetion.GEN_AI_SYSTEM_HUGGING_FACE)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT)
+ span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
+ SemanticConvention.GEN_AI_SYSTEM_HUGGING_FACE)
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
request_model)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TEMPERATURE,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TEMPERATURE,
forward_params.get("temperature", "null"))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TOP_P,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TOP_P,
forward_params.get("top_p", "null"))
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MAX_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS,
forward_params.get("max_length", -1))
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_INPUT_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS,
input_tokens)
- span.set_attribute(SemanticConvetion.SERVER_ADDRESS,
+ span.set_attribute(SemanticConvention.SERVER_ADDRESS,
server_address)
- span.set_attribute(SemanticConvetion.SERVER_PORT,
+ span.set_attribute(SemanticConvention.SERVER_PORT,
server_port)
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL,
request_model)
span.set_attribute(DEPLOYMENT_ENVIRONMENT,
environment)
span.set_attribute(SERVICE_NAME,
application_name)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IS_STREAM,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM,
False)
- span.set_attribute(SemanticConvetion.GEN_AI_SERVER_TTFT,
+ span.set_attribute(SemanticConvention.GEN_AI_SERVER_TTFT,
end_time - start_time)
- span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
+ span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION,
version)
if capture_message_content:
span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_PROMPT: prompt,
+ SemanticConvention.GEN_AI_CONTENT_PROMPT: prompt,
},
)
@@ -127,7 +127,7 @@ def text_wrap(version, environment, application_name,
if len(response) > 1:
attribute_name = f"gen_ai.content.completion.{i}"
else:
- attribute_name = SemanticConvetion.GEN_AI_CONTENT_COMPLETION_EVENT
+ attribute_name = SemanticConvention.GEN_AI_CONTENT_COMPLETION_EVENT
if capture_message_content:
# pylint: disable=bare-except
try:
@@ -138,22 +138,22 @@ def text_wrap(version, environment, application_name,
span.add_event(
name=attribute_name,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_COMPLETION: llm_response,
+ SemanticConvention.GEN_AI_CONTENT_COMPLETION: llm_response,
},
)
output_tokens += general_tokens(llm_response)
i=i+1
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_OUTPUT_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS,
output_tokens)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_TOTAL_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS,
input_tokens + output_tokens)
# Calculate cost of the operation
cost = get_chat_model_cost(request_model,
pricing_info, input_tokens,
output_tokens)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST,
cost)
span.set_status(Status(StatusCode.OK))
@@ -162,8 +162,8 @@ def text_wrap(version, environment, application_name,
attributes = create_metrics_attributes(
service_name=application_name,
deployment_environment=environment,
- operation=SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT,
- system=SemanticConvetion.GEN_AI_SYSTEM_HUGGING_FACE,
+ operation=SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
+ system=SemanticConvention.GEN_AI_SYSTEM_HUGGING_FACE,
request_model=request_model,
server_address=server_address,
server_port=server_port,
diff --git a/sdk/python/src/openlit/instrumentation/vertexai/async_vertexai.py b/sdk/python/src/openlit/instrumentation/vertexai/async_vertexai.py
index aa232ae4..ca2b05a9 100644
--- a/sdk/python/src/openlit/instrumentation/vertexai/async_vertexai.py
+++ b/sdk/python/src/openlit/instrumentation/vertexai/async_vertexai.py
@@ -13,7 +13,7 @@ from openlit.__helpers import (
calculate_tbt,
create_metrics_attributes,
)
-from openlit.semcov import SemanticConvetion
+from openlit.semcov import SemanticConvention
# Initialize logger for logging potential issues and operations
logger = logging.getLogger(__name__)
@@ -139,26 +139,26 @@ def async_send_message(version, environment, application_name, tracer,
# Set Span attributes (OTel Semconv)
self._span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
- self._span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
- SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT)
- self._span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
- SemanticConvetion.GEN_AI_SYSTEM_VERTEXAI)
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
+ self._span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT)
+ self._span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
+ SemanticConvention.GEN_AI_SYSTEM_VERTEXAI)
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
self._request_model)
- self._span.set_attribute(SemanticConvetion.SERVER_PORT,
+ self._span.set_attribute(SemanticConvention.SERVER_PORT,
self._server_port)
inference_config = self._kwargs.get('generation_config', {})
# List of attributes and their config keys
attributes = [
- (SemanticConvetion.GEN_AI_REQUEST_FREQUENCY_PENALTY, 'frequency_penalty'),
- (SemanticConvetion.GEN_AI_REQUEST_MAX_TOKENS, 'max_output_tokens'),
- (SemanticConvetion.GEN_AI_REQUEST_PRESENCE_PENALTY, 'presence_penalty'),
- (SemanticConvetion.GEN_AI_REQUEST_STOP_SEQUENCES, 'stop_sequences'),
- (SemanticConvetion.GEN_AI_REQUEST_TEMPERATURE, 'temperature'),
- (SemanticConvetion.GEN_AI_REQUEST_TOP_P, 'top_p'),
- (SemanticConvetion.GEN_AI_REQUEST_TOP_K, 'top_k'),
+ (SemanticConvention.GEN_AI_REQUEST_FREQUENCY_PENALTY, 'frequency_penalty'),
+ (SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS, 'max_output_tokens'),
+ (SemanticConvention.GEN_AI_REQUEST_PRESENCE_PENALTY, 'presence_penalty'),
+ (SemanticConvention.GEN_AI_REQUEST_STOP_SEQUENCES, 'stop_sequences'),
+ (SemanticConvention.GEN_AI_REQUEST_TEMPERATURE, 'temperature'),
+ (SemanticConvention.GEN_AI_REQUEST_TOP_P, 'top_p'),
+ (SemanticConvention.GEN_AI_REQUEST_TOP_K, 'top_k'),
]
# Set each attribute if the corresponding value exists and is not None
@@ -168,19 +168,19 @@ def async_send_message(version, environment, application_name, tracer,
if value is not None:
self._span.set_attribute(attribute, value)
- self._span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_MODEL,
+ self._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL,
self._request_model)
- self._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_INPUT_TOKENS,
+ self._span.set_attribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS,
self._input_tokens)
- self._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_OUTPUT_TOKENS,
+ self._span.set_attribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS,
self._output_tokens)
- self._span.set_attribute(SemanticConvetion.SERVER_ADDRESS,
+ self._span.set_attribute(SemanticConvention.SERVER_ADDRESS,
self._server_address)
if isinstance(self._llmresponse, str):
- self._span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
+ self._span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
"text")
else:
- self._span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
+ self._span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
"json")
# Set Span attributes (Extra)
@@ -188,29 +188,29 @@ def async_send_message(version, environment, application_name, tracer,
environment)
self._span.set_attribute(SERVICE_NAME,
application_name)
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IS_STREAM,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM,
True)
- self._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_TOTAL_TOKENS,
+ self._span.set_attribute(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS,
self._input_tokens + self._output_tokens)
- self._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
+ self._span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST,
cost)
- self._span.set_attribute(SemanticConvetion.GEN_AI_SERVER_TBT,
+ self._span.set_attribute(SemanticConvention.GEN_AI_SERVER_TBT,
self._tbt)
- self._span.set_attribute(SemanticConvetion.GEN_AI_SERVER_TTFT,
+ self._span.set_attribute(SemanticConvention.GEN_AI_SERVER_TTFT,
self._ttft)
- self._span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
+ self._span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION,
version)
if capture_message_content:
self._span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_PROMPT: prompt,
+ SemanticConvention.GEN_AI_CONTENT_PROMPT: prompt,
},
)
self._span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_COMPLETION_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_COMPLETION_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_COMPLETION: self._llmresponse,
+ SemanticConvention.GEN_AI_CONTENT_COMPLETION: self._llmresponse,
},
)
self._span.set_status(Status(StatusCode.OK))
@@ -219,8 +219,8 @@ def async_send_message(version, environment, application_name, tracer,
attributes = create_metrics_attributes(
service_name=application_name,
deployment_environment=environment,
- operation=SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT,
- system=SemanticConvetion.GEN_AI_SYSTEM_VERTEXAI,
+ operation=SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
+ system=SemanticConvention.GEN_AI_SYSTEM_VERTEXAI,
request_model=self._request_model,
server_address=self._server_address,
server_port=self._server_port,
@@ -280,7 +280,7 @@ def async_send_message(version, environment, application_name, tracer,
server_address, server_port = location + '-aiplatform.googleapis.com', 443
- span_name = f"{SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT} {request_model}"
+ span_name = f"{SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT} {request_model}"
# pylint: disable=no-else-return
if streaming:
@@ -342,26 +342,26 @@ def async_send_message(version, environment, application_name, tracer,
# Set base span attribues (OTel Semconv)
span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
- span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
- SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT)
- span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
- SemanticConvetion.GEN_AI_SYSTEM_VERTEXAI)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT)
+ span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
+ SemanticConvention.GEN_AI_SYSTEM_VERTEXAI)
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
request_model)
- span.set_attribute(SemanticConvetion.SERVER_PORT,
+ span.set_attribute(SemanticConvention.SERVER_PORT,
server_port)
inference_config = kwargs.get('generation_config', {})
# List of attributes and their config keys
attributes = [
- (SemanticConvetion.GEN_AI_REQUEST_FREQUENCY_PENALTY, 'frequency_penalty'),
- (SemanticConvetion.GEN_AI_REQUEST_MAX_TOKENS, 'max_output_tokens'),
- (SemanticConvetion.GEN_AI_REQUEST_PRESENCE_PENALTY, 'presence_penalty'),
- (SemanticConvetion.GEN_AI_REQUEST_STOP_SEQUENCES, 'stop_sequences'),
- (SemanticConvetion.GEN_AI_REQUEST_TEMPERATURE, 'temperature'),
- (SemanticConvetion.GEN_AI_REQUEST_TOP_P, 'top_p'),
- (SemanticConvetion.GEN_AI_REQUEST_TOP_K, 'top_k'),
+ (SemanticConvention.GEN_AI_REQUEST_FREQUENCY_PENALTY, 'frequency_penalty'),
+ (SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS, 'max_output_tokens'),
+ (SemanticConvention.GEN_AI_REQUEST_PRESENCE_PENALTY, 'presence_penalty'),
+ (SemanticConvention.GEN_AI_REQUEST_STOP_SEQUENCES, 'stop_sequences'),
+ (SemanticConvention.GEN_AI_REQUEST_TEMPERATURE, 'temperature'),
+ (SemanticConvention.GEN_AI_REQUEST_TOP_P, 'top_p'),
+ (SemanticConvention.GEN_AI_REQUEST_TOP_K, 'top_k'),
]
# Set each attribute if the corresponding value exists and is not None
@@ -371,15 +371,15 @@ def async_send_message(version, environment, application_name, tracer,
if value is not None:
span.set_attribute(attribute, value)
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL,
request_model)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_INPUT_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS,
input_tokens)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_OUTPUT_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS,
output_tokens)
- span.set_attribute(SemanticConvetion.SERVER_ADDRESS,
+ span.set_attribute(SemanticConvention.SERVER_ADDRESS,
server_address)
- # span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_FINISH_REASON,
+ # span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON,
# [str(response.candidates[0].finish_reason)])
# Set base span attribues (Extras)
@@ -387,35 +387,35 @@ def async_send_message(version, environment, application_name, tracer,
environment)
span.set_attribute(SERVICE_NAME,
application_name)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IS_STREAM,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM,
False)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_TOTAL_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS,
input_tokens + output_tokens)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST,
cost)
- span.set_attribute(SemanticConvetion.GEN_AI_SERVER_TTFT,
+ span.set_attribute(SemanticConvention.GEN_AI_SERVER_TTFT,
end_time - start_time)
- span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
+ span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION,
version)
if capture_message_content:
span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_PROMPT: prompt,
+ SemanticConvention.GEN_AI_CONTENT_PROMPT: prompt,
},
)
span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_COMPLETION_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_COMPLETION_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_COMPLETION: response.text,
+ SemanticConvention.GEN_AI_CONTENT_COMPLETION: response.text,
},
)
if isinstance(response.text, str):
- span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
+ span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
"text")
elif response.text is not None:
- span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
+ span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
"json")
span.set_status(Status(StatusCode.OK))
@@ -424,8 +424,8 @@ def async_send_message(version, environment, application_name, tracer,
attributes = create_metrics_attributes(
service_name=application_name,
deployment_environment=environment,
- operation=SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT,
- system=SemanticConvetion.GEN_AI_SYSTEM_VERTEXAI,
+ operation=SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
+ system=SemanticConvention.GEN_AI_SYSTEM_VERTEXAI,
request_model=request_model,
server_address=server_address,
server_port=server_port,
diff --git a/sdk/python/src/openlit/instrumentation/vertexai/vertexai.py b/sdk/python/src/openlit/instrumentation/vertexai/vertexai.py
index 12ca4c51..811c6729 100644
--- a/sdk/python/src/openlit/instrumentation/vertexai/vertexai.py
+++ b/sdk/python/src/openlit/instrumentation/vertexai/vertexai.py
@@ -13,7 +13,7 @@ from openlit.__helpers import (
calculate_tbt,
create_metrics_attributes,
)
-from openlit.semcov import SemanticConvetion
+from openlit.semcov import SemanticConvention
# Initialize logger for logging potential issues and operations
logger = logging.getLogger(__name__)
@@ -139,26 +139,26 @@ def send_message(version, environment, application_name, tracer,
# Set Span attributes (OTel Semconv)
self._span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
- self._span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
- SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT)
- self._span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
- SemanticConvetion.GEN_AI_SYSTEM_VERTEXAI)
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
+ self._span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT)
+ self._span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
+ SemanticConvention.GEN_AI_SYSTEM_VERTEXAI)
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
self._request_model)
- self._span.set_attribute(SemanticConvetion.SERVER_PORT,
+ self._span.set_attribute(SemanticConvention.SERVER_PORT,
self._server_port)
inference_config = self._kwargs.get('generation_config', {})
# List of attributes and their config keys
attributes = [
- (SemanticConvetion.GEN_AI_REQUEST_FREQUENCY_PENALTY, 'frequency_penalty'),
- (SemanticConvetion.GEN_AI_REQUEST_MAX_TOKENS, 'max_output_tokens'),
- (SemanticConvetion.GEN_AI_REQUEST_PRESENCE_PENALTY, 'presence_penalty'),
- (SemanticConvetion.GEN_AI_REQUEST_STOP_SEQUENCES, 'stop_sequences'),
- (SemanticConvetion.GEN_AI_REQUEST_TEMPERATURE, 'temperature'),
- (SemanticConvetion.GEN_AI_REQUEST_TOP_P, 'top_p'),
- (SemanticConvetion.GEN_AI_REQUEST_TOP_K, 'top_k'),
+ (SemanticConvention.GEN_AI_REQUEST_FREQUENCY_PENALTY, 'frequency_penalty'),
+ (SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS, 'max_output_tokens'),
+ (SemanticConvention.GEN_AI_REQUEST_PRESENCE_PENALTY, 'presence_penalty'),
+ (SemanticConvention.GEN_AI_REQUEST_STOP_SEQUENCES, 'stop_sequences'),
+ (SemanticConvention.GEN_AI_REQUEST_TEMPERATURE, 'temperature'),
+ (SemanticConvention.GEN_AI_REQUEST_TOP_P, 'top_p'),
+ (SemanticConvention.GEN_AI_REQUEST_TOP_K, 'top_k'),
]
# Set each attribute if the corresponding value exists and is not None
@@ -168,19 +168,19 @@ def send_message(version, environment, application_name, tracer,
if value is not None:
self._span.set_attribute(attribute, value)
- self._span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_MODEL,
+ self._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL,
self._request_model)
- self._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_INPUT_TOKENS,
+ self._span.set_attribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS,
self._input_tokens)
- self._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_OUTPUT_TOKENS,
+ self._span.set_attribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS,
self._output_tokens)
- self._span.set_attribute(SemanticConvetion.SERVER_ADDRESS,
+ self._span.set_attribute(SemanticConvention.SERVER_ADDRESS,
self._server_address)
if isinstance(self._llmresponse, str):
- self._span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
+ self._span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
"text")
else:
- self._span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
+ self._span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
"json")
# Set Span attributes (Extra)
@@ -188,29 +188,29 @@ def send_message(version, environment, application_name, tracer,
environment)
self._span.set_attribute(SERVICE_NAME,
application_name)
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IS_STREAM,
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM,
True)
- self._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_TOTAL_TOKENS,
+ self._span.set_attribute(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS,
self._input_tokens + self._output_tokens)
- self._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
+ self._span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST,
cost)
- self._span.set_attribute(SemanticConvetion.GEN_AI_SERVER_TBT,
+ self._span.set_attribute(SemanticConvention.GEN_AI_SERVER_TBT,
self._tbt)
- self._span.set_attribute(SemanticConvetion.GEN_AI_SERVER_TTFT,
+ self._span.set_attribute(SemanticConvention.GEN_AI_SERVER_TTFT,
self._ttft)
- self._span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
+ self._span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION,
version)
if capture_message_content:
self._span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_PROMPT: prompt,
+ SemanticConvention.GEN_AI_CONTENT_PROMPT: prompt,
},
)
self._span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_COMPLETION_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_COMPLETION_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_COMPLETION: self._llmresponse,
+ SemanticConvention.GEN_AI_CONTENT_COMPLETION: self._llmresponse,
},
)
self._span.set_status(Status(StatusCode.OK))
@@ -219,8 +219,8 @@ def send_message(version, environment, application_name, tracer,
attributes = create_metrics_attributes(
service_name=application_name,
deployment_environment=environment,
- operation=SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT,
- system=SemanticConvetion.GEN_AI_SYSTEM_VERTEXAI,
+ operation=SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
+ system=SemanticConvention.GEN_AI_SYSTEM_VERTEXAI,
request_model=self._request_model,
server_address=self._server_address,
server_port=self._server_port,
@@ -280,7 +280,7 @@ def send_message(version, environment, application_name, tracer,
server_address, server_port = location + '-aiplatform.googleapis.com', 443
- span_name = f"{SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT} {request_model}"
+ span_name = f"{SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT} {request_model}"
# pylint: disable=no-else-return
if streaming:
@@ -342,26 +342,26 @@ def send_message(version, environment, application_name, tracer,
# Set base span attribues (OTel Semconv)
span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
- span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
- SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT)
- span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
- SemanticConvetion.GEN_AI_SYSTEM_VERTEXAI)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT)
+ span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
+ SemanticConvention.GEN_AI_SYSTEM_VERTEXAI)
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
request_model)
- span.set_attribute(SemanticConvetion.SERVER_PORT,
+ span.set_attribute(SemanticConvention.SERVER_PORT,
server_port)
inference_config = kwargs.get('generation_config', {})
# List of attributes and their config keys
attributes = [
- (SemanticConvetion.GEN_AI_REQUEST_FREQUENCY_PENALTY, 'frequency_penalty'),
- (SemanticConvetion.GEN_AI_REQUEST_MAX_TOKENS, 'max_output_tokens'),
- (SemanticConvetion.GEN_AI_REQUEST_PRESENCE_PENALTY, 'presence_penalty'),
- (SemanticConvetion.GEN_AI_REQUEST_STOP_SEQUENCES, 'stop_sequences'),
- (SemanticConvetion.GEN_AI_REQUEST_TEMPERATURE, 'temperature'),
- (SemanticConvetion.GEN_AI_REQUEST_TOP_P, 'top_p'),
- (SemanticConvetion.GEN_AI_REQUEST_TOP_K, 'top_k'),
+ (SemanticConvention.GEN_AI_REQUEST_FREQUENCY_PENALTY, 'frequency_penalty'),
+ (SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS, 'max_output_tokens'),
+ (SemanticConvention.GEN_AI_REQUEST_PRESENCE_PENALTY, 'presence_penalty'),
+ (SemanticConvention.GEN_AI_REQUEST_STOP_SEQUENCES, 'stop_sequences'),
+ (SemanticConvention.GEN_AI_REQUEST_TEMPERATURE, 'temperature'),
+ (SemanticConvention.GEN_AI_REQUEST_TOP_P, 'top_p'),
+ (SemanticConvention.GEN_AI_REQUEST_TOP_K, 'top_k'),
]
# Set each attribute if the corresponding value exists and is not None
@@ -371,15 +371,15 @@ def send_message(version, environment, application_name, tracer,
if value is not None:
span.set_attribute(attribute, value)
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL,
request_model)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_INPUT_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS,
input_tokens)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_OUTPUT_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS,
output_tokens)
- span.set_attribute(SemanticConvetion.SERVER_ADDRESS,
+ span.set_attribute(SemanticConvention.SERVER_ADDRESS,
server_address)
- # span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_FINISH_REASON,
+ # span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON,
# [str(response.candidates[0].finish_reason)])
# Set base span attribues (Extras)
@@ -387,35 +387,35 @@ def send_message(version, environment, application_name, tracer,
environment)
span.set_attribute(SERVICE_NAME,
application_name)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IS_STREAM,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM,
False)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_TOTAL_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS,
input_tokens + output_tokens)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST,
cost)
- span.set_attribute(SemanticConvetion.GEN_AI_SERVER_TTFT,
+ span.set_attribute(SemanticConvention.GEN_AI_SERVER_TTFT,
end_time - start_time)
- span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
+ span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION,
version)
if capture_message_content:
span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_PROMPT: prompt,
+ SemanticConvention.GEN_AI_CONTENT_PROMPT: prompt,
},
)
span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_COMPLETION_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_COMPLETION_EVENT,
attributes={
- SemanticConvetion.GEN_AI_CONTENT_COMPLETION: response.text,
+ SemanticConvention.GEN_AI_CONTENT_COMPLETION: response.text,
},
)
if isinstance(response.text, str):
- span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
+ span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
"text")
elif response.text is not None:
- span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
+ span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
"json")
span.set_status(Status(StatusCode.OK))
@@ -424,8 +424,8 @@ def send_message(version, environment, application_name, tracer,
attributes = create_metrics_attributes(
service_name=application_name,
deployment_environment=environment,
- operation=SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT,
- system=SemanticConvetion.GEN_AI_SYSTEM_VERTEXAI,
+ operation=SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
+ system=SemanticConvention.GEN_AI_SYSTEM_VERTEXAI,
request_model=request_model,
server_address=server_address,
server_port=server_port,
diff --git a/sdk/python/src/openlit/instrumentation/vllm/vllm.py b/sdk/python/src/openlit/instrumentation/vllm/vllm.py
index 5d884c76..71f9701b 100644
--- a/sdk/python/src/openlit/instrumentation/vllm/vllm.py
+++ b/sdk/python/src/openlit/instrumentation/vllm/vllm.py
@@ -13,7 +13,7 @@ from openlit.__helpers import (
create_metrics_attributes,
set_server_address_and_port
)
-from openlit.semcov import SemanticConvetion
+from openlit.semcov import SemanticConvention
# Initialize logger for logging potential issues and operations
logger = logging.getLogger(__name__)
@@ -55,7 +55,7 @@ def generate(version, environment, application_name,
server_address, server_port = set_server_address_and_port(instance, "api.cohere.com", 443)
request_model = instance.llm_engine.model_config.model or "facebook/opt-125m"
- span_name = f"{SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT} {request_model}"
+ span_name = f"{SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT} {request_model}"
# pylint: disable=line-too-long
with tracer.start_as_current_span(span_name, kind= SpanKind.CLIENT) as span:
@@ -66,19 +66,19 @@ def generate(version, environment, application_name,
try:
# Set base span attribues
span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
- span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
- SemanticConvetion.GEN_AI_SYSTEM_VLLM)
- span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
- SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT)
- span.set_attribute(SemanticConvetion.SERVER_PORT,
+ span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
+ SemanticConvention.GEN_AI_SYSTEM_VLLM)
+ span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT)
+ span.set_attribute(SemanticConvention.SERVER_PORT,
server_port)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
request_model)
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_MODEL,
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL,
request_model)
- span.set_attribute(SemanticConvetion.SERVER_ADDRESS,
+ span.set_attribute(SemanticConvention.SERVER_ADDRESS,
server_address)
- span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
+ span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
"text")
# Set base span attribues (Extras)
@@ -86,11 +86,11 @@ def generate(version, environment, application_name,
environment)
span.set_attribute(SERVICE_NAME,
application_name)
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IS_STREAM,
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM,
False)
- span.set_attribute(SemanticConvetion.GEN_AI_SERVER_TTFT,
+ span.set_attribute(SemanticConvention.GEN_AI_SERVER_TTFT,
end_time - start_time)
- span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
+ span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION,
version)
input_tokens = 0
@@ -102,34 +102,34 @@ def generate(version, environment, application_name,
completion_attributes = {}
for i, output in enumerate(response):
- prompt_attributes[f"{SemanticConvetion.GEN_AI_CONTENT_PROMPT}.{i}"] = output.prompt
- completion_attributes[f"{SemanticConvetion.GEN_AI_CONTENT_COMPLETION}.{i}"] = output.outputs[0].text
+ prompt_attributes[f"{SemanticConvention.GEN_AI_CONTENT_PROMPT}.{i}"] = output.prompt
+ completion_attributes[f"{SemanticConvention.GEN_AI_CONTENT_COMPLETION}.{i}"] = output.outputs[0].text
input_tokens += general_tokens(output.prompt)
output_tokens += general_tokens(output.outputs[0].text)
# Add a single event for all prompts
span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
attributes=prompt_attributes,
)
# Add a single event for all completions
span.add_event(
- name=SemanticConvetion.GEN_AI_CONTENT_COMPLETION_EVENT,
+ name=SemanticConvention.GEN_AI_CONTENT_COMPLETION_EVENT,
attributes=completion_attributes,
)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_INPUT_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS,
input_tokens)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_OUTPUT_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS,
output_tokens)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_TOTAL_TOKENS,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS,
input_tokens + output_tokens)
# Calculate cost of the operation
cost = get_chat_model_cost(request_model, pricing_info,
input_tokens, output_tokens)
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST,
cost)
span.set_status(Status(StatusCode.OK))
@@ -138,8 +138,8 @@ def generate(version, environment, application_name,
attributes = create_metrics_attributes(
service_name=application_name,
deployment_environment=environment,
- operation=SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT,
- system=SemanticConvetion.GEN_AI_SYSTEM_VLLM,
+ operation=SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
+ system=SemanticConvention.GEN_AI_SYSTEM_VLLM,
request_model=request_model,
server_address=server_address,
server_port=server_port,
diff --git a/sdk/python/src/openlit/otel/metrics.py b/sdk/python/src/openlit/otel/metrics.py
index 037e24cd..da9192f2 100644
--- a/sdk/python/src/openlit/otel/metrics.py
+++ b/sdk/python/src/openlit/otel/metrics.py
@@ -8,7 +8,7 @@ from opentelemetry.sdk.metrics import MeterProvider
from opentelemetry.sdk.metrics.export import PeriodicExportingMetricReader, ConsoleMetricExporter
from opentelemetry.sdk.resources import SERVICE_NAME, TELEMETRY_SDK_NAME, DEPLOYMENT_ENVIRONMENT
from opentelemetry.sdk.resources import Resource
-from openlit.semcov import SemanticConvetion
+from openlit.semcov import SemanticConvention
if os.environ.get("OTEL_EXPORTER_OTLP_PROTOCOL") == "grpc":
from opentelemetry.exporter.otlp.proto.grpc.metric_exporter import OTLPMetricExporter
@@ -156,31 +156,31 @@ def setup_meter(application_name, environment, meter, otlp_endpoint, otlp_header
metrics_dict = {
# OTel Semconv
"genai_client_usage_tokens": meter.create_histogram(
- name=SemanticConvetion.GEN_AI_CLIENT_TOKEN_USAGE,
+ name=SemanticConvention.GEN_AI_CLIENT_TOKEN_USAGE,
description="Measures number of input and output tokens used",
unit="{token}",
explicit_bucket_boundaries_advisory=_GEN_AI_CLIENT_TOKEN_USAGE_BUCKETS,
),
"genai_client_operation_duration": meter.create_histogram(
- name=SemanticConvetion.GEN_AI_CLIENT_OPERATION_DURATION,
+ name=SemanticConvention.GEN_AI_CLIENT_OPERATION_DURATION,
description="GenAI operation duration",
unit="s",
explicit_bucket_boundaries_advisory=_GEN_AI_CLIENT_OPERATION_DURATION_BUCKETS,
),
"genai_server_tbt": meter.create_histogram(
- name=SemanticConvetion.GEN_AI_SERVER_TBT,
+ name=SemanticConvention.GEN_AI_SERVER_TBT,
description="Time per output token generated after the first token for successful responses",
unit="s",
explicit_bucket_boundaries_advisory=_GEN_AI_SERVER_TBT,
),
"genai_server_ttft": meter.create_histogram(
- name=SemanticConvetion.GEN_AI_SERVER_TTFT,
+ name=SemanticConvention.GEN_AI_SERVER_TTFT,
description="Time to generate first token for successful responses",
unit="s",
explicit_bucket_boundaries_advisory=_GEN_AI_SERVER_TFTT,
),
"db_client_operation_duration": meter.create_histogram(
- name=SemanticConvetion.DB_CLIENT_OPERATION_DURATION,
+ name=SemanticConvention.DB_CLIENT_OPERATION_DURATION,
description="DB operation duration",
unit="s",
explicit_bucket_boundaries_advisory=_DB_CLIENT_OPERATION_DURATION_BUCKETS,
@@ -188,27 +188,27 @@ def setup_meter(application_name, environment, meter, otlp_endpoint, otlp_header
# Extra
"genai_requests": meter.create_counter(
- name=SemanticConvetion.GEN_AI_REQUESTS,
+ name=SemanticConvention.GEN_AI_REQUESTS,
description="Number of requests to GenAI",
unit="1",
),
"genai_prompt_tokens": meter.create_counter(
- name=SemanticConvetion.GEN_AI_USAGE_INPUT_TOKENS,
+ name=SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS,
description="Number of prompt tokens processed.",
unit="1",
),
"genai_completion_tokens": meter.create_counter(
- name=SemanticConvetion.GEN_AI_USAGE_OUTPUT_TOKENS,
+ name=SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS,
description="Number of completion tokens processed.",
unit="1",
),
"genai_cost": meter.create_histogram(
- name=SemanticConvetion.GEN_AI_USAGE_COST,
+ name=SemanticConvention.GEN_AI_USAGE_COST,
description="The distribution of GenAI request costs.",
unit="USD",
),
"db_requests": meter.create_counter(
- name=SemanticConvetion.DB_REQUESTS,
+ name=SemanticConvention.DB_REQUESTS,
description="Number of requests to VectorDBs",
unit="1",
),
diff --git a/sdk/python/src/openlit/semcov/__init__.py b/sdk/python/src/openlit/semcov/__init__.py
index a2357034..aebda306 100644
--- a/sdk/python/src/openlit/semcov/__init__.py
+++ b/sdk/python/src/openlit/semcov/__init__.py
@@ -1,14 +1,14 @@
# pylint: disable=too-few-public-methods
"""
-This module defines the `SemanticConvetion` class which encapsulates various constants used
+This module defines the `SemanticConvention` class which encapsulates various constants used
for semantic tagging within a generalized AI application context. These constants are
intended for use across different components of AI applications, including request handling,
response processing, usage metrics, and interaction with vector databases and AI systems.
The purpose is to standardize the semantics for easier integration, analytics, and maintenance.
"""
-class SemanticConvetion:
+class SemanticConvention:
"""
- The SemanticConvetion class provides a centralized repository of constant values that
+ The SemanticConvention class provides a centralized repository of constant values that
represent the keys for various semantic conventions within AI applications. These
conventions cover a broad range of areas including general AI configurations, request
parameters, usage metrics, response attributes, and integrations with external AI and