openlit 1.33.18__py3-none-any.whl → 1.33.20__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. openlit/__helpers.py +11 -41
  2. openlit/__init__.py +3 -3
  3. openlit/evals/utils.py +7 -7
  4. openlit/guard/utils.py +7 -7
  5. openlit/instrumentation/ag2/ag2.py +24 -24
  6. openlit/instrumentation/ai21/ai21.py +3 -3
  7. openlit/instrumentation/ai21/async_ai21.py +3 -3
  8. openlit/instrumentation/ai21/utils.py +59 -59
  9. openlit/instrumentation/anthropic/anthropic.py +2 -2
  10. openlit/instrumentation/anthropic/async_anthropic.py +2 -2
  11. openlit/instrumentation/anthropic/utils.py +34 -34
  12. openlit/instrumentation/assemblyai/assemblyai.py +24 -24
  13. openlit/instrumentation/astra/astra.py +3 -3
  14. openlit/instrumentation/astra/async_astra.py +3 -3
  15. openlit/instrumentation/astra/utils.py +39 -39
  16. openlit/instrumentation/azure_ai_inference/async_azure_ai_inference.py +10 -10
  17. openlit/instrumentation/azure_ai_inference/azure_ai_inference.py +10 -10
  18. openlit/instrumentation/azure_ai_inference/utils.py +38 -38
  19. openlit/instrumentation/bedrock/__init__.py +2 -1
  20. openlit/instrumentation/bedrock/bedrock.py +32 -214
  21. openlit/instrumentation/bedrock/utils.py +252 -0
  22. openlit/instrumentation/chroma/chroma.py +57 -57
  23. openlit/instrumentation/cohere/async_cohere.py +88 -88
  24. openlit/instrumentation/cohere/cohere.py +88 -88
  25. openlit/instrumentation/controlflow/controlflow.py +15 -15
  26. openlit/instrumentation/crawl4ai/async_crawl4ai.py +14 -14
  27. openlit/instrumentation/crawl4ai/crawl4ai.py +14 -14
  28. openlit/instrumentation/crewai/crewai.py +22 -22
  29. openlit/instrumentation/dynamiq/dynamiq.py +19 -19
  30. openlit/instrumentation/elevenlabs/async_elevenlabs.py +24 -25
  31. openlit/instrumentation/elevenlabs/elevenlabs.py +23 -25
  32. openlit/instrumentation/embedchain/embedchain.py +15 -15
  33. openlit/instrumentation/firecrawl/firecrawl.py +10 -10
  34. openlit/instrumentation/google_ai_studio/async_google_ai_studio.py +33 -33
  35. openlit/instrumentation/google_ai_studio/google_ai_studio.py +33 -33
  36. openlit/instrumentation/gpt4all/gpt4all.py +78 -78
  37. openlit/instrumentation/gpu/__init__.py +8 -8
  38. openlit/instrumentation/groq/async_groq.py +74 -74
  39. openlit/instrumentation/groq/groq.py +74 -74
  40. openlit/instrumentation/haystack/haystack.py +6 -6
  41. openlit/instrumentation/julep/async_julep.py +14 -14
  42. openlit/instrumentation/julep/julep.py +14 -14
  43. openlit/instrumentation/langchain/async_langchain.py +39 -39
  44. openlit/instrumentation/langchain/langchain.py +39 -39
  45. openlit/instrumentation/letta/letta.py +26 -26
  46. openlit/instrumentation/litellm/async_litellm.py +94 -94
  47. openlit/instrumentation/litellm/litellm.py +94 -94
  48. openlit/instrumentation/llamaindex/llamaindex.py +7 -7
  49. openlit/instrumentation/mem0/mem0.py +13 -13
  50. openlit/instrumentation/milvus/milvus.py +47 -47
  51. openlit/instrumentation/mistral/async_mistral.py +88 -88
  52. openlit/instrumentation/mistral/mistral.py +88 -88
  53. openlit/instrumentation/multion/async_multion.py +21 -21
  54. openlit/instrumentation/multion/multion.py +21 -21
  55. openlit/instrumentation/ollama/async_ollama.py +3 -3
  56. openlit/instrumentation/ollama/ollama.py +3 -3
  57. openlit/instrumentation/ollama/utils.py +50 -50
  58. openlit/instrumentation/openai/async_openai.py +225 -225
  59. openlit/instrumentation/openai/openai.py +225 -225
  60. openlit/instrumentation/openai_agents/openai_agents.py +11 -11
  61. openlit/instrumentation/phidata/phidata.py +15 -15
  62. openlit/instrumentation/pinecone/pinecone.py +43 -43
  63. openlit/instrumentation/premai/premai.py +86 -86
  64. openlit/instrumentation/qdrant/async_qdrant.py +95 -95
  65. openlit/instrumentation/qdrant/qdrant.py +99 -99
  66. openlit/instrumentation/reka/async_reka.py +33 -33
  67. openlit/instrumentation/reka/reka.py +33 -33
  68. openlit/instrumentation/together/async_together.py +90 -90
  69. openlit/instrumentation/together/together.py +90 -90
  70. openlit/instrumentation/transformers/transformers.py +26 -26
  71. openlit/instrumentation/vertexai/async_vertexai.py +64 -64
  72. openlit/instrumentation/vertexai/vertexai.py +64 -64
  73. openlit/instrumentation/vllm/vllm.py +24 -24
  74. openlit/otel/metrics.py +11 -11
  75. openlit/semcov/__init__.py +3 -3
  76. {openlit-1.33.18.dist-info → openlit-1.33.20.dist-info}/METADATA +8 -8
  77. openlit-1.33.20.dist-info/RECORD +131 -0
  78. {openlit-1.33.18.dist-info → openlit-1.33.20.dist-info}/WHEEL +1 -1
  79. openlit-1.33.18.dist-info/RECORD +0 -130
  80. {openlit-1.33.18.dist-info → openlit-1.33.20.dist-info}/LICENSE +0 -0
@@ -21,7 +21,7 @@ from openlit.__helpers import (
21
21
  create_metrics_attributes,
22
22
  set_server_address_and_port
23
23
  )
24
- from openlit.semcov import SemanticConvetion
24
+ from openlit.semcov import SemanticConvention
25
25
 
26
26
  # Initialize logger for logging potential issues and operations
27
27
  logger = logging.getLogger(__name__)
@@ -141,41 +141,41 @@ def responses(version, environment, application_name,
141
141
 
142
142
  # Set Span attributes (OTel Semconv)
143
143
  self._span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
144
- self._span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
145
- SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT)
146
- self._span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
147
- SemanticConvetion.GEN_AI_SYSTEM_OPENAI)
148
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
144
+ self._span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
145
+ SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT)
146
+ self._span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
147
+ SemanticConvention.GEN_AI_SYSTEM_OPENAI)
148
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
149
149
  request_model)
150
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_SEED,
150
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_SEED,
151
151
  self._kwargs.get("seed", ""))
152
- self._span.set_attribute(SemanticConvetion.SERVER_PORT,
152
+ self._span.set_attribute(SemanticConvention.SERVER_PORT,
153
153
  self._server_port)
154
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MAX_TOKENS,
154
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS,
155
155
  self._kwargs.get("max_output_tokens", -1))
156
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_STOP_SEQUENCES,
156
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_STOP_SEQUENCES,
157
157
  self._kwargs.get("stop", []))
158
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TEMPERATURE,
158
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TEMPERATURE,
159
159
  self._kwargs.get("temperature", 1.0))
160
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TOP_P,
160
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TOP_P,
161
161
  self._kwargs.get("top_p", 1.0))
162
- self._span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_FINISH_REASON,
162
+ self._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON,
163
163
  [self._finish_reason])
164
- self._span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_ID,
164
+ self._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_ID,
165
165
  self._response_id)
166
- self._span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_MODEL,
166
+ self._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL,
167
167
  self._response_model)
168
- self._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_INPUT_TOKENS,
168
+ self._span.set_attribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS,
169
169
  self._input_tokens)
170
- self._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_OUTPUT_TOKENS,
170
+ self._span.set_attribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS,
171
171
  self._output_tokens)
172
- self._span.set_attribute(SemanticConvetion.SERVER_ADDRESS,
172
+ self._span.set_attribute(SemanticConvention.SERVER_ADDRESS,
173
173
  self._server_address)
174
174
  if isinstance(self._llmresponse, str):
175
- self._span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
175
+ self._span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
176
176
  "text")
177
177
  else:
178
- self._span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
178
+ self._span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
179
179
  "json")
180
180
 
181
181
  # Set Span attributes (Extra)
@@ -183,32 +183,32 @@ def responses(version, environment, application_name,
183
183
  environment)
184
184
  self._span.set_attribute(SERVICE_NAME,
185
185
  application_name)
186
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_USER,
186
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_USER,
187
187
  self._kwargs.get("user", ""))
188
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IS_STREAM,
188
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM,
189
189
  True)
190
- self._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_TOTAL_TOKENS,
190
+ self._span.set_attribute(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS,
191
191
  self._input_tokens + self._output_tokens)
192
- self._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
192
+ self._span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST,
193
193
  cost)
194
- self._span.set_attribute(SemanticConvetion.GEN_AI_SERVER_TBT,
194
+ self._span.set_attribute(SemanticConvention.GEN_AI_SERVER_TBT,
195
195
  self._tbt)
196
- self._span.set_attribute(SemanticConvetion.GEN_AI_SERVER_TTFT,
196
+ self._span.set_attribute(SemanticConvention.GEN_AI_SERVER_TTFT,
197
197
  self._ttft)
198
- self._span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
198
+ self._span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION,
199
199
  version)
200
200
 
201
201
  if capture_message_content:
202
202
  self._span.add_event(
203
- name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
203
+ name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
204
204
  attributes={
205
- SemanticConvetion.GEN_AI_CONTENT_PROMPT: prompt,
205
+ SemanticConvention.GEN_AI_CONTENT_PROMPT: prompt,
206
206
  },
207
207
  )
208
208
  self._span.add_event(
209
- name=SemanticConvetion.GEN_AI_CONTENT_COMPLETION_EVENT,
209
+ name=SemanticConvention.GEN_AI_CONTENT_COMPLETION_EVENT,
210
210
  attributes={
211
- SemanticConvetion.GEN_AI_CONTENT_COMPLETION: self._llmresponse,
211
+ SemanticConvention.GEN_AI_CONTENT_COMPLETION: self._llmresponse,
212
212
  },
213
213
  )
214
214
  self._span.set_status(Status(StatusCode.OK))
@@ -217,8 +217,8 @@ def responses(version, environment, application_name,
217
217
  attributes = create_metrics_attributes(
218
218
  service_name=application_name,
219
219
  deployment_environment=environment,
220
- operation=SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT,
221
- system=SemanticConvetion.GEN_AI_SYSTEM_OPENAI,
220
+ operation=SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
221
+ system=SemanticConvention.GEN_AI_SYSTEM_OPENAI,
222
222
  request_model=request_model,
223
223
  server_address=self._server_address,
224
224
  server_port=self._server_port,
@@ -271,7 +271,7 @@ def responses(version, environment, application_name,
271
271
  server_address, server_port = set_server_address_and_port(instance, "api.openai.com", 443)
272
272
  request_model = kwargs.get("model", "gpt-4o")
273
273
 
274
- span_name = f"{SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT} {request_model}"
274
+ span_name = f"{SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT} {request_model}"
275
275
 
276
276
  # pylint: disable=no-else-return
277
277
  if streaming:
@@ -307,33 +307,33 @@ def responses(version, environment, application_name,
307
307
 
308
308
  # Set base span attribues (OTel Semconv)
309
309
  span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
310
- span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
311
- SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT)
312
- span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
313
- SemanticConvetion.GEN_AI_SYSTEM_OPENAI)
314
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
310
+ span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
311
+ SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT)
312
+ span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
313
+ SemanticConvention.GEN_AI_SYSTEM_OPENAI)
314
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
315
315
  request_model)
316
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_SEED,
316
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_SEED,
317
317
  kwargs.get("seed", ""))
318
- span.set_attribute(SemanticConvetion.SERVER_PORT,
318
+ span.set_attribute(SemanticConvention.SERVER_PORT,
319
319
  server_port)
320
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MAX_TOKENS,
320
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS,
321
321
  kwargs.get("max_output_tokens", -1))
322
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_STOP_SEQUENCES,
322
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_STOP_SEQUENCES,
323
323
  kwargs.get("stop", []))
324
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TEMPERATURE,
324
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TEMPERATURE,
325
325
  str(response_dict.get("temperature", 1.0)))
326
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TOP_P,
326
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TOP_P,
327
327
  str(response_dict.get("top_p", 1.0)))
328
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_ID,
328
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_ID,
329
329
  response_dict.get("id"))
330
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_MODEL,
330
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL,
331
331
  response_dict.get('model'))
332
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_INPUT_TOKENS,
332
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS,
333
333
  input_tokens)
334
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_OUTPUT_TOKENS,
334
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS,
335
335
  output_tokens)
336
- span.set_attribute(SemanticConvetion.SERVER_ADDRESS,
336
+ span.set_attribute(SemanticConvention.SERVER_ADDRESS,
337
337
  server_address)
338
338
 
339
339
  # Set base span attribues (Extras)
@@ -341,29 +341,29 @@ def responses(version, environment, application_name,
341
341
  environment)
342
342
  span.set_attribute(SERVICE_NAME,
343
343
  application_name)
344
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_USER,
344
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_USER,
345
345
  kwargs.get("user", ""))
346
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IS_STREAM,
346
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM,
347
347
  False)
348
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_TOTAL_TOKENS,
348
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS,
349
349
  input_tokens + output_tokens)
350
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
350
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST,
351
351
  cost)
352
- span.set_attribute(SemanticConvetion.GEN_AI_SERVER_TTFT,
352
+ span.set_attribute(SemanticConvention.GEN_AI_SERVER_TTFT,
353
353
  end_time - start_time)
354
- span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
354
+ span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION,
355
355
  version)
356
356
 
357
357
  if capture_message_content:
358
358
  span.add_event(
359
- name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
359
+ name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
360
360
  attributes={
361
- SemanticConvetion.GEN_AI_CONTENT_PROMPT: prompt,
361
+ SemanticConvention.GEN_AI_CONTENT_PROMPT: prompt,
362
362
  },
363
363
  )
364
364
 
365
365
  for i in range(kwargs.get('n',1)):
366
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_FINISH_REASON,
366
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON,
367
367
  [response_dict.get('status')])
368
368
  try:
369
369
  llm_response = response_dict.get('output')[i].get('content')[0].get('text','')
@@ -372,21 +372,21 @@ def responses(version, environment, application_name,
372
372
 
373
373
  if capture_message_content:
374
374
  span.add_event(
375
- name=SemanticConvetion.GEN_AI_CONTENT_COMPLETION_EVENT,
375
+ name=SemanticConvention.GEN_AI_CONTENT_COMPLETION_EVENT,
376
376
  attributes={
377
377
  # pylint: disable=line-too-long
378
- SemanticConvetion.GEN_AI_CONTENT_COMPLETION: llm_response,
378
+ SemanticConvention.GEN_AI_CONTENT_COMPLETION: llm_response,
379
379
  },
380
380
  )
381
381
  if kwargs.get('tools'):
382
- span.set_attribute(SemanticConvetion.GEN_AI_TOOL_CALLS,
382
+ span.set_attribute(SemanticConvention.GEN_AI_TOOL_CALLS,
383
383
  str(response_dict.get('tools')))
384
384
 
385
385
  if isinstance(llm_response, str):
386
- span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
386
+ span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
387
387
  "text")
388
388
  elif llm_response is not None:
389
- span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
389
+ span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
390
390
  "json")
391
391
 
392
392
  span.set_status(Status(StatusCode.OK))
@@ -395,8 +395,8 @@ def responses(version, environment, application_name,
395
395
  attributes = create_metrics_attributes(
396
396
  service_name=application_name,
397
397
  deployment_environment=environment,
398
- operation=SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT,
399
- system=SemanticConvetion.GEN_AI_SYSTEM_OPENAI,
398
+ operation=SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
399
+ system=SemanticConvention.GEN_AI_SYSTEM_OPENAI,
400
400
  request_model=request_model,
401
401
  server_address=server_address,
402
402
  server_port=server_port,
@@ -522,7 +522,7 @@ def chat_completions(version, environment, application_name,
522
522
  self._response_id = chunked.get('id')
523
523
  self._response_model = chunked.get('model')
524
524
  self._finish_reason = chunked.get('choices')[0].get('finish_reason')
525
- self._openai_response_service_tier = chunked.get('service_tier')
525
+ self._openai_response_service_tier = chunked.get('service_tier') or 'auto'
526
526
  self._openai_system_fingerprint = chunked.get('system_fingerprint')
527
527
  return chunk
528
528
  except StopIteration:
@@ -566,51 +566,51 @@ def chat_completions(version, environment, application_name,
566
566
 
567
567
  # Set Span attributes (OTel Semconv)
568
568
  self._span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
569
- self._span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
570
- SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT)
571
- self._span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
572
- SemanticConvetion.GEN_AI_SYSTEM_OPENAI)
573
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
569
+ self._span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
570
+ SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT)
571
+ self._span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
572
+ SemanticConvention.GEN_AI_SYSTEM_OPENAI)
573
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
574
574
  request_model)
575
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_SEED,
575
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_SEED,
576
576
  self._kwargs.get("seed", ""))
577
- self._span.set_attribute(SemanticConvetion.SERVER_PORT,
577
+ self._span.set_attribute(SemanticConvention.SERVER_PORT,
578
578
  self._server_port)
579
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_FREQUENCY_PENALTY,
579
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_FREQUENCY_PENALTY,
580
580
  self._kwargs.get("frequency_penalty", 0.0))
581
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MAX_TOKENS,
581
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS,
582
582
  self._kwargs.get("max_tokens", -1))
583
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_PRESENCE_PENALTY,
583
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_PRESENCE_PENALTY,
584
584
  self._kwargs.get("presence_penalty", 0.0))
585
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_STOP_SEQUENCES,
585
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_STOP_SEQUENCES,
586
586
  self._kwargs.get("stop", []))
587
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TEMPERATURE,
587
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TEMPERATURE,
588
588
  self._kwargs.get("temperature", 1.0))
589
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TOP_P,
589
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TOP_P,
590
590
  self._kwargs.get("top_p", 1.0))
591
- self._span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_FINISH_REASON,
591
+ self._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON,
592
592
  [self._finish_reason])
593
- self._span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_ID,
593
+ self._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_ID,
594
594
  self._response_id)
595
- self._span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_MODEL,
595
+ self._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL,
596
596
  self._response_model)
597
- self._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_INPUT_TOKENS,
597
+ self._span.set_attribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS,
598
598
  input_tokens)
599
- self._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_OUTPUT_TOKENS,
599
+ self._span.set_attribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS,
600
600
  output_tokens)
601
- self._span.set_attribute(SemanticConvetion.SERVER_ADDRESS,
601
+ self._span.set_attribute(SemanticConvention.SERVER_ADDRESS,
602
602
  self._server_address)
603
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_SERVICE_TIER,
603
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_SERVICE_TIER,
604
604
  self._kwargs.get("service_tier", "auto"))
605
- self._span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_SERVICE_TIER,
605
+ self._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_SERVICE_TIER,
606
606
  self._openai_response_service_tier)
607
- self._span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_SYSTEM_FINGERPRINT,
607
+ self._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_SYSTEM_FINGERPRINT,
608
608
  self._openai_system_fingerprint)
609
609
  if isinstance(self._llmresponse, str):
610
- self._span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
610
+ self._span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
611
611
  "text")
612
612
  else:
613
- self._span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
613
+ self._span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
614
614
  "json")
615
615
 
616
616
  # Set Span attributes (Extra)
@@ -618,31 +618,31 @@ def chat_completions(version, environment, application_name,
618
618
  environment)
619
619
  self._span.set_attribute(SERVICE_NAME,
620
620
  application_name)
621
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_USER,
621
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_USER,
622
622
  self._kwargs.get("user", ""))
623
- self._span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IS_STREAM,
623
+ self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM,
624
624
  True)
625
- self._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_TOTAL_TOKENS,
625
+ self._span.set_attribute(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS,
626
626
  input_tokens + output_tokens)
627
- self._span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
627
+ self._span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST,
628
628
  cost)
629
- self._span.set_attribute(SemanticConvetion.GEN_AI_SERVER_TBT,
629
+ self._span.set_attribute(SemanticConvention.GEN_AI_SERVER_TBT,
630
630
  self._tbt)
631
- self._span.set_attribute(SemanticConvetion.GEN_AI_SERVER_TTFT,
631
+ self._span.set_attribute(SemanticConvention.GEN_AI_SERVER_TTFT,
632
632
  self._ttft)
633
- self._span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
633
+ self._span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION,
634
634
  version)
635
635
  if capture_message_content:
636
636
  self._span.add_event(
637
- name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
637
+ name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
638
638
  attributes={
639
- SemanticConvetion.GEN_AI_CONTENT_PROMPT: prompt,
639
+ SemanticConvention.GEN_AI_CONTENT_PROMPT: prompt,
640
640
  },
641
641
  )
642
642
  self._span.add_event(
643
- name=SemanticConvetion.GEN_AI_CONTENT_COMPLETION_EVENT,
643
+ name=SemanticConvention.GEN_AI_CONTENT_COMPLETION_EVENT,
644
644
  attributes={
645
- SemanticConvetion.GEN_AI_CONTENT_COMPLETION: self._llmresponse,
645
+ SemanticConvention.GEN_AI_CONTENT_COMPLETION: self._llmresponse,
646
646
  },
647
647
  )
648
648
  self._span.set_status(Status(StatusCode.OK))
@@ -651,8 +651,8 @@ def chat_completions(version, environment, application_name,
651
651
  attributes = create_metrics_attributes(
652
652
  service_name=application_name,
653
653
  deployment_environment=environment,
654
- operation=SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT,
655
- system=SemanticConvetion.GEN_AI_SYSTEM_OPENAI,
654
+ operation=SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
655
+ system=SemanticConvention.GEN_AI_SYSTEM_OPENAI,
656
656
  request_model=request_model,
657
657
  server_address=self._server_address,
658
658
  server_port=self._server_port,
@@ -705,7 +705,7 @@ def chat_completions(version, environment, application_name,
705
705
  server_address, server_port = set_server_address_and_port(instance, "api.openai.com", 443)
706
706
  request_model = kwargs.get("model", "gpt-4o")
707
707
 
708
- span_name = f"{SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT} {request_model}"
708
+ span_name = f"{SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT} {request_model}"
709
709
 
710
710
  # pylint: disable=no-else-return
711
711
  if streaming:
@@ -753,43 +753,43 @@ def chat_completions(version, environment, application_name,
753
753
 
754
754
  # Set base span attribues (OTel Semconv)
755
755
  span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
756
- span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
757
- SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT)
758
- span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
759
- SemanticConvetion.GEN_AI_SYSTEM_OPENAI)
760
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
756
+ span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
757
+ SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT)
758
+ span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
759
+ SemanticConvention.GEN_AI_SYSTEM_OPENAI)
760
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
761
761
  request_model)
762
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_SEED,
762
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_SEED,
763
763
  kwargs.get("seed", ""))
764
- span.set_attribute(SemanticConvetion.SERVER_PORT,
764
+ span.set_attribute(SemanticConvention.SERVER_PORT,
765
765
  server_port)
766
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_FREQUENCY_PENALTY,
766
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_FREQUENCY_PENALTY,
767
767
  kwargs.get("frequency_penalty", 0.0))
768
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MAX_TOKENS,
768
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS,
769
769
  kwargs.get("max_tokens", -1))
770
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_PRESENCE_PENALTY,
770
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_PRESENCE_PENALTY,
771
771
  kwargs.get("presence_penalty", 0.0))
772
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_STOP_SEQUENCES,
772
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_STOP_SEQUENCES,
773
773
  kwargs.get("stop", []))
774
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TEMPERATURE,
774
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TEMPERATURE,
775
775
  kwargs.get("temperature", 1.0))
776
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_TOP_P,
776
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TOP_P,
777
777
  kwargs.get("top_p", 1.0))
778
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_ID,
778
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_ID,
779
779
  response_dict.get("id"))
780
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_MODEL,
780
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL,
781
781
  response_dict.get('model'))
782
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_INPUT_TOKENS,
782
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS,
783
783
  input_tokens)
784
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_OUTPUT_TOKENS,
784
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS,
785
785
  output_tokens)
786
- span.set_attribute(SemanticConvetion.SERVER_ADDRESS,
786
+ span.set_attribute(SemanticConvention.SERVER_ADDRESS,
787
787
  server_address)
788
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_SERVICE_TIER,
788
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_SERVICE_TIER,
789
789
  kwargs.get("service_tier", "auto"))
790
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_SERVICE_TIER,
791
- response_dict.get('service_tier'))
792
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_SYSTEM_FINGERPRINT,
790
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_SERVICE_TIER,
791
+ response_dict.get('service_tier', 'auto'))
792
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_SYSTEM_FINGERPRINT,
793
793
  str(response_dict.get('system_fingerprint', '')))
794
794
 
795
795
  # Set base span attribues (Extras)
@@ -797,46 +797,46 @@ def chat_completions(version, environment, application_name,
797
797
  environment)
798
798
  span.set_attribute(SERVICE_NAME,
799
799
  application_name)
800
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_USER,
800
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_USER,
801
801
  kwargs.get("user", ""))
802
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IS_STREAM,
802
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM,
803
803
  False)
804
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_TOTAL_TOKENS,
804
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS,
805
805
  input_tokens + output_tokens)
806
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
806
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST,
807
807
  cost)
808
- span.set_attribute(SemanticConvetion.GEN_AI_SERVER_TTFT,
808
+ span.set_attribute(SemanticConvention.GEN_AI_SERVER_TTFT,
809
809
  end_time - start_time)
810
- span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
810
+ span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION,
811
811
  version)
812
812
  if capture_message_content:
813
813
  span.add_event(
814
- name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
814
+ name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
815
815
  attributes={
816
- SemanticConvetion.GEN_AI_CONTENT_PROMPT: prompt,
816
+ SemanticConvention.GEN_AI_CONTENT_PROMPT: prompt,
817
817
  },
818
818
  )
819
819
 
820
820
  for i in range(kwargs.get('n',1)):
821
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_FINISH_REASON,
821
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON,
822
822
  [response_dict.get('choices')[i].get('finish_reason')])
823
823
  if capture_message_content:
824
824
  span.add_event(
825
- name=SemanticConvetion.GEN_AI_CONTENT_COMPLETION_EVENT,
825
+ name=SemanticConvention.GEN_AI_CONTENT_COMPLETION_EVENT,
826
826
  attributes={
827
827
  # pylint: disable=line-too-long
828
- SemanticConvetion.GEN_AI_CONTENT_COMPLETION: str(response_dict.get('choices')[i].get('message').get('content')),
828
+ SemanticConvention.GEN_AI_CONTENT_COMPLETION: str(response_dict.get('choices')[i].get('message').get('content')),
829
829
  },
830
830
  )
831
831
  if kwargs.get('tools'):
832
- span.set_attribute(SemanticConvetion.GEN_AI_TOOL_CALLS,
832
+ span.set_attribute(SemanticConvention.GEN_AI_TOOL_CALLS,
833
833
  str(response_dict.get('choices')[i].get('message').get('tool_calls')))
834
834
 
835
835
  if isinstance(response_dict.get('choices')[i].get('message').get('content'), str):
836
- span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
836
+ span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
837
837
  "text")
838
838
  elif response_dict.get('choices')[i].get('message').get('content') is not None:
839
- span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
839
+ span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
840
840
  "json")
841
841
 
842
842
  span.set_status(Status(StatusCode.OK))
@@ -845,8 +845,8 @@ def chat_completions(version, environment, application_name,
845
845
  attributes = create_metrics_attributes(
846
846
  service_name=application_name,
847
847
  deployment_environment=environment,
848
- operation=SemanticConvetion.GEN_AI_OPERATION_TYPE_CHAT,
849
- system=SemanticConvetion.GEN_AI_SYSTEM_OPENAI,
848
+ operation=SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
849
+ system=SemanticConvention.GEN_AI_SYSTEM_OPENAI,
850
850
  request_model=request_model,
851
851
  server_address=server_address,
852
852
  server_port=server_port,
@@ -916,7 +916,7 @@ def embedding(version, environment, application_name,
916
916
  server_address, server_port = set_server_address_and_port(instance, "api.openai.com", 443)
917
917
  request_model = kwargs.get("model", "text-embedding-ada-002")
918
918
 
919
- span_name = f"{SemanticConvetion.GEN_AI_OPERATION_TYPE_EMBEDDING} {request_model}"
919
+ span_name = f"{SemanticConvention.GEN_AI_OPERATION_TYPE_EMBEDDING} {request_model}"
920
920
 
921
921
  with tracer.start_as_current_span(span_name, kind= SpanKind.CLIENT) as span:
922
922
  start_time = time.time()
@@ -933,21 +933,21 @@ def embedding(version, environment, application_name,
933
933
 
934
934
  # Set Span attributes (OTel Semconv)
935
935
  span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
936
- span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
937
- SemanticConvetion.GEN_AI_OPERATION_TYPE_EMBEDDING)
938
- span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
939
- SemanticConvetion.GEN_AI_SYSTEM_OPENAI)
940
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
936
+ span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
937
+ SemanticConvention.GEN_AI_OPERATION_TYPE_EMBEDDING)
938
+ span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
939
+ SemanticConvention.GEN_AI_SYSTEM_OPENAI)
940
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
941
941
  request_model)
942
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_ENCODING_FORMATS,
942
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_ENCODING_FORMATS,
943
943
  [kwargs.get('encoding_format', 'float')])
944
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_MODEL,
944
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL,
945
945
  request_model)
946
- span.set_attribute(SemanticConvetion.SERVER_ADDRESS,
946
+ span.set_attribute(SemanticConvention.SERVER_ADDRESS,
947
947
  server_address)
948
- span.set_attribute(SemanticConvetion.SERVER_PORT,
948
+ span.set_attribute(SemanticConvention.SERVER_PORT,
949
949
  server_port)
950
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_INPUT_TOKENS,
950
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS,
951
951
  input_tokens)
952
952
 
953
953
  # Set Span attributes (Extras)
@@ -955,20 +955,20 @@ def embedding(version, environment, application_name,
955
955
  environment)
956
956
  span.set_attribute(SERVICE_NAME,
957
957
  application_name)
958
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_USER,
958
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_USER,
959
959
  kwargs.get("user", ""))
960
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_TOTAL_TOKENS,
960
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS,
961
961
  input_tokens)
962
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
962
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST,
963
963
  cost)
964
- span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
964
+ span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION,
965
965
  version)
966
966
 
967
967
  if capture_message_content:
968
968
  span.add_event(
969
- name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
969
+ name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
970
970
  attributes={
971
- SemanticConvetion.GEN_AI_CONTENT_PROMPT: str(kwargs.get("input", "")),
971
+ SemanticConvention.GEN_AI_CONTENT_PROMPT: str(kwargs.get("input", "")),
972
972
  },
973
973
  )
974
974
 
@@ -978,8 +978,8 @@ def embedding(version, environment, application_name,
978
978
  attributes = create_metrics_attributes(
979
979
  service_name=application_name,
980
980
  deployment_environment=environment,
981
- operation=SemanticConvetion.GEN_AI_OPERATION_TYPE_EMBEDDING,
982
- system=SemanticConvetion.GEN_AI_SYSTEM_OPENAI,
981
+ operation=SemanticConvention.GEN_AI_OPERATION_TYPE_EMBEDDING,
982
+ system=SemanticConvention.GEN_AI_SYSTEM_OPENAI,
983
983
  request_model=request_model,
984
984
  server_address=server_address,
985
985
  server_port=server_port,
@@ -1044,7 +1044,7 @@ def image_generate(version, environment, application_name,
1044
1044
  server_address, server_port = set_server_address_and_port(instance, "api.openai.com", 443)
1045
1045
  request_model = kwargs.get("model", "dall-e-2")
1046
1046
 
1047
- span_name = f"{SemanticConvetion.GEN_AI_OPERATION_TYPE_IMAGE} {request_model}"
1047
+ span_name = f"{SemanticConvention.GEN_AI_OPERATION_TYPE_IMAGE} {request_model}"
1048
1048
 
1049
1049
  with tracer.start_as_current_span(span_name, kind= SpanKind.CLIENT) as span:
1050
1050
  start_time = time.time()
@@ -1068,21 +1068,21 @@ def image_generate(version, environment, application_name,
1068
1068
  for items in response.data:
1069
1069
  # Set Span attributes (OTel Semconv)
1070
1070
  span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
1071
- span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
1072
- SemanticConvetion.GEN_AI_OPERATION_TYPE_IMAGE)
1073
- span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
1074
- SemanticConvetion.GEN_AI_SYSTEM_OPENAI)
1075
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
1071
+ span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
1072
+ SemanticConvention.GEN_AI_OPERATION_TYPE_IMAGE)
1073
+ span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
1074
+ SemanticConvention.GEN_AI_SYSTEM_OPENAI)
1075
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
1076
1076
  request_model)
1077
- span.set_attribute(SemanticConvetion.SERVER_ADDRESS,
1077
+ span.set_attribute(SemanticConvention.SERVER_ADDRESS,
1078
1078
  server_address)
1079
- span.set_attribute(SemanticConvetion.SERVER_PORT,
1079
+ span.set_attribute(SemanticConvention.SERVER_PORT,
1080
1080
  server_port)
1081
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_ID,
1081
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_ID,
1082
1082
  response.created)
1083
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_MODEL,
1083
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL,
1084
1084
  request_model)
1085
- span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
1085
+ span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
1086
1086
  "image")
1087
1087
 
1088
1088
  # Set Span attributes (Extras)
@@ -1090,37 +1090,37 @@ def image_generate(version, environment, application_name,
1090
1090
  environment)
1091
1091
  span.set_attribute(SERVICE_NAME,
1092
1092
  application_name)
1093
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IMAGE_SIZE,
1093
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_IMAGE_SIZE,
1094
1094
  kwargs.get("size", "1024x1024"))
1095
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IMAGE_QUALITY,
1095
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_IMAGE_QUALITY,
1096
1096
  kwargs.get("quality", "standard"))
1097
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IMAGE_STYLE,
1097
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_IMAGE_STYLE,
1098
1098
  kwargs.get("style", "vivid"))
1099
- span.set_attribute(SemanticConvetion.GEN_AI_CONTENT_REVISED_PROMPT,
1099
+ span.set_attribute(SemanticConvention.GEN_AI_CONTENT_REVISED_PROMPT,
1100
1100
  items.revised_prompt if items.revised_prompt else "")
1101
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_USER,
1101
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_USER,
1102
1102
  kwargs.get("user", ""))
1103
- span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
1103
+ span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION,
1104
1104
  version)
1105
1105
 
1106
1106
  if capture_message_content:
1107
1107
  span.add_event(
1108
- name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
1108
+ name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
1109
1109
  attributes={
1110
- SemanticConvetion.GEN_AI_CONTENT_PROMPT: kwargs.get("prompt", ""),
1110
+ SemanticConvention.GEN_AI_CONTENT_PROMPT: kwargs.get("prompt", ""),
1111
1111
  },
1112
1112
  )
1113
- attribute_name = f"{SemanticConvetion.GEN_AI_RESPONSE_IMAGE}.{images_count}"
1113
+ attribute_name = f"{SemanticConvention.GEN_AI_RESPONSE_IMAGE}.{images_count}"
1114
1114
  span.add_event(
1115
1115
  name=attribute_name,
1116
1116
  attributes={
1117
- SemanticConvetion.GEN_AI_CONTENT_COMPLETION: getattr(items, image),
1117
+ SemanticConvention.GEN_AI_CONTENT_COMPLETION: getattr(items, image),
1118
1118
  },
1119
1119
  )
1120
1120
 
1121
1121
  images_count+=1
1122
1122
 
1123
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
1123
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST,
1124
1124
  len(response.data) * cost)
1125
1125
  span.set_status(Status(StatusCode.OK))
1126
1126
 
@@ -1128,8 +1128,8 @@ def image_generate(version, environment, application_name,
1128
1128
  attributes = create_metrics_attributes(
1129
1129
  service_name=application_name,
1130
1130
  deployment_environment=environment,
1131
- operation=SemanticConvetion.GEN_AI_OPERATION_TYPE_IMAGE,
1132
- system=SemanticConvetion.GEN_AI_SYSTEM_OPENAI,
1131
+ operation=SemanticConvention.GEN_AI_OPERATION_TYPE_IMAGE,
1132
+ system=SemanticConvention.GEN_AI_SYSTEM_OPENAI,
1133
1133
  request_model=request_model,
1134
1134
  server_address=server_address,
1135
1135
  server_port=server_port,
@@ -1191,7 +1191,7 @@ def image_variatons(version, environment, application_name,
1191
1191
  server_address, server_port = set_server_address_and_port(instance, "api.openai.com", 443)
1192
1192
  request_model = kwargs.get("model", "dall-e-2")
1193
1193
 
1194
- span_name = f"{SemanticConvetion.GEN_AI_OPERATION_TYPE_IMAGE} {request_model}"
1194
+ span_name = f"{SemanticConvention.GEN_AI_OPERATION_TYPE_IMAGE} {request_model}"
1195
1195
 
1196
1196
  with tracer.start_as_current_span(span_name, kind= SpanKind.CLIENT) as span:
1197
1197
  start_time = time.time()
@@ -1214,21 +1214,21 @@ def image_variatons(version, environment, application_name,
1214
1214
  for items in response.data:
1215
1215
  # Set Span attributes (OTel Semconv)
1216
1216
  span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
1217
- span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
1218
- SemanticConvetion.GEN_AI_OPERATION_TYPE_IMAGE)
1219
- span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
1220
- SemanticConvetion.GEN_AI_SYSTEM_OPENAI)
1221
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
1217
+ span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
1218
+ SemanticConvention.GEN_AI_OPERATION_TYPE_IMAGE)
1219
+ span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
1220
+ SemanticConvention.GEN_AI_SYSTEM_OPENAI)
1221
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
1222
1222
  request_model)
1223
- span.set_attribute(SemanticConvetion.SERVER_ADDRESS,
1223
+ span.set_attribute(SemanticConvention.SERVER_ADDRESS,
1224
1224
  server_address)
1225
- span.set_attribute(SemanticConvetion.SERVER_PORT,
1225
+ span.set_attribute(SemanticConvention.SERVER_PORT,
1226
1226
  server_port)
1227
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_ID,
1227
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_ID,
1228
1228
  response.created)
1229
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_MODEL,
1229
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL,
1230
1230
  request_model)
1231
- span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
1231
+ span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
1232
1232
  "image")
1233
1233
 
1234
1234
  # Set Span attributes (Extras)
@@ -1236,27 +1236,27 @@ def image_variatons(version, environment, application_name,
1236
1236
  environment)
1237
1237
  span.set_attribute(SERVICE_NAME,
1238
1238
  application_name)
1239
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IMAGE_SIZE,
1239
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_IMAGE_SIZE,
1240
1240
  kwargs.get("size", "1024x1024"))
1241
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IMAGE_QUALITY,
1241
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_IMAGE_QUALITY,
1242
1242
  "standard")
1243
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_USER,
1243
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_USER,
1244
1244
  kwargs.get("user", ""))
1245
- span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
1245
+ span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION,
1246
1246
  version)
1247
1247
 
1248
1248
  if capture_message_content:
1249
- attribute_name = f"{SemanticConvetion.GEN_AI_RESPONSE_IMAGE}.{images_count}"
1249
+ attribute_name = f"{SemanticConvention.GEN_AI_RESPONSE_IMAGE}.{images_count}"
1250
1250
  span.add_event(
1251
1251
  name=attribute_name,
1252
1252
  attributes={
1253
- SemanticConvetion.GEN_AI_CONTENT_COMPLETION: getattr(items, image),
1253
+ SemanticConvention.GEN_AI_CONTENT_COMPLETION: getattr(items, image),
1254
1254
  },
1255
1255
  )
1256
1256
 
1257
1257
  images_count+=1
1258
1258
 
1259
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
1259
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST,
1260
1260
  len(response.data) * cost)
1261
1261
  span.set_status(Status(StatusCode.OK))
1262
1262
 
@@ -1264,8 +1264,8 @@ def image_variatons(version, environment, application_name,
1264
1264
  attributes = create_metrics_attributes(
1265
1265
  service_name=application_name,
1266
1266
  deployment_environment=environment,
1267
- operation=SemanticConvetion.GEN_AI_OPERATION_TYPE_IMAGE,
1268
- system=SemanticConvetion.GEN_AI_SYSTEM_OPENAI,
1267
+ operation=SemanticConvention.GEN_AI_OPERATION_TYPE_IMAGE,
1268
+ system=SemanticConvention.GEN_AI_SYSTEM_OPENAI,
1269
1269
  request_model=request_model,
1270
1270
  server_address=server_address,
1271
1271
  server_port=server_port,
@@ -1327,7 +1327,7 @@ def audio_create(version, environment, application_name,
1327
1327
  server_address, server_port = set_server_address_and_port(instance, "api.openai.com", 443)
1328
1328
  request_model = kwargs.get("model", "tts-1")
1329
1329
 
1330
- span_name = f"{SemanticConvetion.GEN_AI_OPERATION_TYPE_AUDIO} {request_model}"
1330
+ span_name = f"{SemanticConvention.GEN_AI_OPERATION_TYPE_AUDIO} {request_model}"
1331
1331
 
1332
1332
  with tracer.start_as_current_span(span_name, kind=SpanKind.CLIENT) as span:
1333
1333
  start_time = time.time()
@@ -1341,40 +1341,40 @@ def audio_create(version, environment, application_name,
1341
1341
 
1342
1342
  # Set Span attributes
1343
1343
  span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
1344
- span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
1345
- SemanticConvetion.GEN_AI_OPERATION_TYPE_AUDIO)
1346
- span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
1347
- SemanticConvetion.GEN_AI_SYSTEM_OPENAI)
1348
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
1344
+ span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
1345
+ SemanticConvention.GEN_AI_OPERATION_TYPE_AUDIO)
1346
+ span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
1347
+ SemanticConvention.GEN_AI_SYSTEM_OPENAI)
1348
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
1349
1349
  request_model)
1350
- span.set_attribute(SemanticConvetion.SERVER_ADDRESS,
1350
+ span.set_attribute(SemanticConvention.SERVER_ADDRESS,
1351
1351
  server_address)
1352
- span.set_attribute(SemanticConvetion.SERVER_PORT,
1352
+ span.set_attribute(SemanticConvention.SERVER_PORT,
1353
1353
  server_port)
1354
- span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_MODEL,
1354
+ span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL,
1355
1355
  request_model)
1356
- span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
1356
+ span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
1357
1357
  "speech")
1358
1358
 
1359
1359
  span.set_attribute(DEPLOYMENT_ENVIRONMENT,
1360
1360
  environment)
1361
1361
  span.set_attribute(SERVICE_NAME,
1362
1362
  application_name)
1363
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_AUDIO_VOICE,
1363
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_AUDIO_VOICE,
1364
1364
  kwargs.get("voice", "alloy"))
1365
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_AUDIO_RESPONSE_FORMAT,
1365
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_AUDIO_RESPONSE_FORMAT,
1366
1366
  kwargs.get("response_format", "mp3"))
1367
- span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_AUDIO_SPEED,
1367
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_AUDIO_SPEED,
1368
1368
  kwargs.get("speed", 1))
1369
- span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
1369
+ span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST,
1370
1370
  cost)
1371
- span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
1371
+ span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION,
1372
1372
  version)
1373
1373
  if capture_message_content:
1374
1374
  span.add_event(
1375
- name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
1375
+ name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
1376
1376
  attributes={
1377
- SemanticConvetion.GEN_AI_CONTENT_PROMPT: kwargs.get("input", ""),
1377
+ SemanticConvention.GEN_AI_CONTENT_PROMPT: kwargs.get("input", ""),
1378
1378
  },
1379
1379
  )
1380
1380
 
@@ -1384,8 +1384,8 @@ def audio_create(version, environment, application_name,
1384
1384
  attributes = create_metrics_attributes(
1385
1385
  service_name=application_name,
1386
1386
  deployment_environment=environment,
1387
- operation=SemanticConvetion.GEN_AI_OPERATION_TYPE_AUDIO,
1388
- system=SemanticConvetion.GEN_AI_SYSTEM_OPENAI,
1387
+ operation=SemanticConvention.GEN_AI_OPERATION_TYPE_AUDIO,
1388
+ system=SemanticConvention.GEN_AI_SYSTEM_OPENAI,
1389
1389
  request_model=request_model,
1390
1390
  server_address=server_address,
1391
1391
  server_port=server_port,