paid-python 0.3.4__py3-none-any.whl → 0.3.6__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 (26) hide show
  1. paid/_vendor/__init__.py +0 -0
  2. paid/_vendor/opentelemetry/__init__.py +0 -0
  3. paid/_vendor/opentelemetry/instrumentation/__init__.py +0 -0
  4. paid/_vendor/opentelemetry/instrumentation/openai/__init__.py +54 -0
  5. paid/_vendor/opentelemetry/instrumentation/openai/shared/__init__.py +399 -0
  6. paid/_vendor/opentelemetry/instrumentation/openai/shared/chat_wrappers.py +1192 -0
  7. paid/_vendor/opentelemetry/instrumentation/openai/shared/completion_wrappers.py +292 -0
  8. paid/_vendor/opentelemetry/instrumentation/openai/shared/config.py +15 -0
  9. paid/_vendor/opentelemetry/instrumentation/openai/shared/embeddings_wrappers.py +311 -0
  10. paid/_vendor/opentelemetry/instrumentation/openai/shared/event_emitter.py +108 -0
  11. paid/_vendor/opentelemetry/instrumentation/openai/shared/event_models.py +41 -0
  12. paid/_vendor/opentelemetry/instrumentation/openai/shared/image_gen_wrappers.py +68 -0
  13. paid/_vendor/opentelemetry/instrumentation/openai/shared/span_utils.py +0 -0
  14. paid/_vendor/opentelemetry/instrumentation/openai/utils.py +190 -0
  15. paid/_vendor/opentelemetry/instrumentation/openai/v0/__init__.py +176 -0
  16. paid/_vendor/opentelemetry/instrumentation/openai/v1/__init__.py +358 -0
  17. paid/_vendor/opentelemetry/instrumentation/openai/v1/assistant_wrappers.py +329 -0
  18. paid/_vendor/opentelemetry/instrumentation/openai/v1/event_handler_wrapper.py +134 -0
  19. paid/_vendor/opentelemetry/instrumentation/openai/v1/responses_wrappers.py +996 -0
  20. paid/_vendor/opentelemetry/instrumentation/openai/version.py +1 -0
  21. paid/tracing/autoinstrumentation.py +5 -6
  22. paid/tracing/tracing.py +14 -3
  23. {paid_python-0.3.4.dist-info → paid_python-0.3.6.dist-info}/METADATA +2 -3
  24. {paid_python-0.3.4.dist-info → paid_python-0.3.6.dist-info}/RECORD +26 -6
  25. {paid_python-0.3.4.dist-info → paid_python-0.3.6.dist-info}/LICENSE +0 -0
  26. {paid_python-0.3.4.dist-info → paid_python-0.3.6.dist-info}/WHEEL +0 -0
@@ -0,0 +1 @@
1
+ __version__ = "0.48.1"
@@ -22,7 +22,8 @@ except ImportError:
22
22
  ANTHROPIC_AVAILABLE = False
23
23
 
24
24
  try:
25
- from opentelemetry.instrumentation.openai import OpenAIInstrumentor
25
+ # from opentelemetry.instrumentation.openai import OpenAIInstrumentor
26
+ from paid._vendor.opentelemetry.instrumentation.openai import OpenAIInstrumentor # remove once openai instrumentor is upstream
26
27
 
27
28
  OPENAI_AVAILABLE = True
28
29
  except ImportError:
@@ -43,7 +44,7 @@ except ImportError:
43
44
  BEDROCK_AVAILABLE = False
44
45
 
45
46
  try:
46
- from opentelemetry.instrumentation.langchain import LangchainInstrumentor
47
+ from openinference.instrumentation.langchain import LangChainInstrumentor
47
48
 
48
49
  LANGCHAIN_AVAILABLE = True
49
50
  except ImportError:
@@ -195,16 +196,14 @@ def _instrument_bedrock() -> None:
195
196
 
196
197
  def _instrument_langchain() -> None:
197
198
  """
198
- Instrument LangChain using opentelemetry-instrumentation-langchain.
199
+ Instrument LangChain using openinference-instrumentation-langchain.
199
200
  """
200
201
  if not LANGCHAIN_AVAILABLE:
201
202
  logger.warning("LangChain instrumentation library not available, skipping instrumentation")
202
203
  return
203
204
 
204
205
  # Instrument LangChain with Paid's tracer provider
205
- LangchainInstrumentor(disable_trace_context_propagation=True).instrument(
206
- tracer_provider=tracing.paid_tracer_provider
207
- )
206
+ LangChainInstrumentor().instrument(tracer_provider=tracing.paid_tracer_provider)
208
207
 
209
208
  _initialized_instrumentors.append("langchain")
210
209
  logger.info("LangChain auto-instrumentation enabled")
paid/tracing/tracing.py CHANGED
@@ -63,25 +63,36 @@ class PaidSpanProcessor(SpanProcessor):
63
63
  1. Prefixes all span names with 'paid.trace.'
64
64
  2. Automatically adds external_customer_id and external_agent_id attributes
65
65
  to all spans based on context variables set by the tracing decorator.
66
+ 3. Filters out prompt/response data unless store_prompt=True.
67
+ 4. Filters out duplicate LangChain spans that may duplicate information from other instrumentations.
66
68
  """
67
69
 
68
70
  SPAN_NAME_PREFIX = "paid.trace."
69
71
  PROMPT_ATTRIBUTES_SUBSTRINGS = {
70
- "prompt",
71
- # "gen_ai.prompt",
72
72
  "gen_ai.completion",
73
73
  "gen_ai.request.messages",
74
74
  "gen_ai.response.messages",
75
75
  "llm.output_message",
76
76
  "llm.input_message",
77
77
  "llm.invocation_parameters",
78
+ "gen_ai.prompt",
79
+ "langchain.prompt",
78
80
  "output.value",
79
81
  "input.value",
80
- # "langchain.prompt",
81
82
  }
82
83
 
83
84
  def on_start(self, span: Span, parent_context: Optional[Context] = None) -> None:
84
85
  """Called when a span is started. Prefix the span name and add attributes."""
86
+
87
+ LANGCHAIN_SPAN_FILTERS = ["ChatOpenAI", "ChatAnthropic"]
88
+ if any(f in span.name for f in LANGCHAIN_SPAN_FILTERS):
89
+ # HACK TO FILTER DUPLICATE SPANS CREATED BY LANGCHAIN INSTRUMENTATION.
90
+ # Langchain instrumentation creates spans, that are created by other instrumentations (ex. OpenAI, Anthropic).
91
+ # Not all spans need filtering (ex. ChatGoogleGenerativeAI), so first test actual telemetry before adding filters.
92
+ # TODO: maybe consider a dropping sampler for such spans instead of raising an exception?
93
+ logger.debug(f"Dropping Langchain span: {span.name}")
94
+ raise Exception(f"Dropping Langchain span: {span.name}")
95
+
85
96
  # Prefix the span name
86
97
  if span.name and not span.name.startswith(self.SPAN_NAME_PREFIX):
87
98
  span.update_name(f"{self.SPAN_NAME_PREFIX}{span.name}")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: paid-python
3
- Version: 0.3.4
3
+ Version: 0.3.6
4
4
  Summary:
5
5
  Requires-Python: >=3.9,<3.14
6
6
  Classifier: Intended Audience :: Developers
@@ -21,12 +21,11 @@ Requires-Dist: httpx (>=0.21.0)
21
21
  Requires-Dist: mutagen (>=1.47.0)
22
22
  Requires-Dist: openinference-instrumentation-bedrock (>=0.1.0)
23
23
  Requires-Dist: openinference-instrumentation-google-genai (>=0.1.8)
24
+ Requires-Dist: openinference-instrumentation-langchain (>=0.1.55)
24
25
  Requires-Dist: openinference-instrumentation-openai-agents (>=1.0.0)
25
26
  Requires-Dist: opentelemetry-api (>=1.23.0)
26
27
  Requires-Dist: opentelemetry-exporter-otlp-proto-http (>=1.23.0)
27
28
  Requires-Dist: opentelemetry-instrumentation-anthropic (>=0.47.0)
28
- Requires-Dist: opentelemetry-instrumentation-langchain (>=0.47.0)
29
- Requires-Dist: opentelemetry-instrumentation-openai (>=0.47.0)
30
29
  Requires-Dist: opentelemetry-sdk (>=1.23.0)
31
30
  Requires-Dist: pydantic (>=1.9.0)
32
31
  Requires-Dist: pydantic-core (>=2.18.0)
@@ -1,4 +1,24 @@
1
1
  paid/__init__.py,sha256=D1SeLoeTlySo_vZCZrxFX3y5KhKGrHflphLXoewImfk,1826
2
+ paid/_vendor/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
+ paid/_vendor/opentelemetry/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
+ paid/_vendor/opentelemetry/instrumentation/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
+ paid/_vendor/opentelemetry/instrumentation/openai/__init__.py,sha256=pCv_Z7FJVlR7XumomPX6AAmuIFDzik_PeAA6rpkgO80,2171
6
+ paid/_vendor/opentelemetry/instrumentation/openai/shared/__init__.py,sha256=hpn2hQFg-VnXdNaXJHd8CKDCBx5P4gTOqsrlOD8ispQ,12731
7
+ paid/_vendor/opentelemetry/instrumentation/openai/shared/chat_wrappers.py,sha256=X8Wu8zdXmOCCC1Cu-tpiOTZUdK2dKAd_Uhc8URjTwXc,40552
8
+ paid/_vendor/opentelemetry/instrumentation/openai/shared/completion_wrappers.py,sha256=gNzYfU6niiRmx-qkz39nV_hWBZjk1g4GYFC8KamDBXs,9418
9
+ paid/_vendor/opentelemetry/instrumentation/openai/shared/config.py,sha256=xMSz47vDPboU3Vciulf6lZkyWXTFA6eaLJHk-tYfkus,479
10
+ paid/_vendor/opentelemetry/instrumentation/openai/shared/embeddings_wrappers.py,sha256=lswpTs4aqH_7tchfHEFcp7rDsmmN4y_wTiV2Fn_iAGQ,9429
11
+ paid/_vendor/opentelemetry/instrumentation/openai/shared/event_emitter.py,sha256=hxZ1y3Ie8e_mUq655jDDMIZ1ko49QsRUVuHMPQdESlE,3263
12
+ paid/_vendor/opentelemetry/instrumentation/openai/shared/event_models.py,sha256=PCfCGxrrArwZqR-4wFcXrhwQq0sBMAxmSrpC4PUMtaM,876
13
+ paid/_vendor/opentelemetry/instrumentation/openai/shared/image_gen_wrappers.py,sha256=E_fRtkqHAX9tWIsBKCbd4jSIlgCKipaH7vGhLMrlQZI,2159
14
+ paid/_vendor/opentelemetry/instrumentation/openai/shared/span_utils.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
15
+ paid/_vendor/opentelemetry/instrumentation/openai/utils.py,sha256=i-HqIUMNf6lIvfj9dBarCEWzFquEU5Ak7_O9hzPrRVg,5106
16
+ paid/_vendor/opentelemetry/instrumentation/openai/v0/__init__.py,sha256=SWemnoZhnXwoSb0qZ5H_dpnTFtCryyfpAGmhMuUJAbs,6393
17
+ paid/_vendor/opentelemetry/instrumentation/openai/v1/__init__.py,sha256=sEf6lTWoIIxkdmOeqyaYiZzq2DP-lpjudygCddzE7Ww,13334
18
+ paid/_vendor/opentelemetry/instrumentation/openai/v1/assistant_wrappers.py,sha256=EOwYdg4GbQ4TMnGrGNABwNyhoYNanPyrYRKqNMELhl0,11538
19
+ paid/_vendor/opentelemetry/instrumentation/openai/v1/event_handler_wrapper.py,sha256=tzTKrKEXZMuSr98G4A-s10YHIJPzKvxkvck9ZrPnFZk,4462
20
+ paid/_vendor/opentelemetry/instrumentation/openai/v1/responses_wrappers.py,sha256=XfBeUfzzrxOEvEkXFHFkaMYMHoARL6qkjjGu0o96hAs,38538
21
+ paid/_vendor/opentelemetry/instrumentation/openai/version.py,sha256=BlW7lOSPQf4pAwU6T5nih5Vp6GJ_QyPSV_8_zA7WSp0,23
2
22
  paid/agents/__init__.py,sha256=_VhToAyIt_5axN6CLJwtxg3-CO7THa_23pbUzqhXJa4,85
3
23
  paid/agents/client.py,sha256=ojc3H-nx4MqDrb74_i6JE_wjHSJaVAErsIunfNeffMo,23305
4
24
  paid/agents/raw_client.py,sha256=jN9LvPK2-bGeNQzcV3iRmprpegXKtO2JaOEXjnPfz9Y,26833
@@ -37,12 +57,12 @@ paid/orders/lines/raw_client.py,sha256=KZN_yBokCOkf1lUb4ZJtX_NZbqmTqCdJNoaIOdWar
37
57
  paid/orders/raw_client.py,sha256=650e1Sj2vi9KVJc15M3ENXIKYoth0qMz66dzvXy1Sb4,16245
38
58
  paid/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
39
59
  paid/tracing/__init__.py,sha256=Pe55koIwqJ6Vv5-9Wqi8xIdwCS2BbxZds-MK5fD-F5Y,506
40
- paid/tracing/autoinstrumentation.py,sha256=J1v1YNR6fISd0B-P9MPwWQGVqJ309PuYfaUHsfqGUGk,7650
60
+ paid/tracing/autoinstrumentation.py,sha256=kH2d1wGPLE6Ore60nNAwFUKAWkH-3N_B_6urJYoobMg,7732
41
61
  paid/tracing/context_data.py,sha256=oiLocz-9qDqB5nQzJlrLsc2Mkr9MaNt_yF_hjppobKc,3298
42
62
  paid/tracing/context_manager.py,sha256=ZQtsJ9JPxTwn2t4AW26WpYboaOEZdI2T1Sw0Rwsbf-E,8470
43
63
  paid/tracing/distributed_tracing.py,sha256=Vht3U8QJmT5jlRVnrybTn-cI1RPuVtyb3V4eTu6gA4g,3991
44
64
  paid/tracing/signal.py,sha256=PfYxF6EFQS8j7RY5_C5NXrCBVu9Hq2E2tyG4fdQScJk,3252
45
- paid/tracing/tracing.py,sha256=0eMY357by892_32a2qCT6nRCUOHt03gxKCmUH2wDjVg,15184
65
+ paid/tracing/tracing.py,sha256=Gl1DMz4YXcFTe3QRbGWAAbNYGNsBJ-QdONkMNBVQIos,16034
46
66
  paid/tracing/wrappers/__init__.py,sha256=IIleLB_JUbzLw7FshrU2VHZAKF3dZHMGy1O5zCBwwqM,1588
47
67
  paid/tracing/wrappers/anthropic/__init__.py,sha256=_x1fjySAQxuT5cIGO_jU09LiGcZH-WQLqKg8mUFAu2w,115
48
68
  paid/tracing/wrappers/anthropic/anthropicWrapper.py,sha256=pGchbOb41CbTxc7H8xXoM-LjR085spqrzXqCVC_rrFk,4913
@@ -99,7 +119,7 @@ paid/usage/__init__.py,sha256=_VhToAyIt_5axN6CLJwtxg3-CO7THa_23pbUzqhXJa4,85
99
119
  paid/usage/client.py,sha256=280WJuepoovk3BAVbAx2yN2Q_qBdvx3CcPkLu8lXslc,3030
100
120
  paid/usage/raw_client.py,sha256=2acg5C4lxuZodZjepU9QYF0fmBxgG-3ZgXs1zUJG-wM,3709
101
121
  paid/version.py,sha256=QIpDFnOrxMxrs86eL0iNH0mSZ1DO078wWHYY9TYAoew,78
102
- paid_python-0.3.4.dist-info/LICENSE,sha256=Nz4baY1zvv0Qy7lqrQtbaiMhmEeGr2Q7A93aqzpml4c,1071
103
- paid_python-0.3.4.dist-info/METADATA,sha256=r3juPpujn-xEF7IRftwtqe-CdnV9aUffhrsa6ijd4qg,23695
104
- paid_python-0.3.4.dist-info/WHEEL,sha256=Zb28QaM1gQi8f4VCBhsUklF61CTlNYfs9YAZn-TOGFk,88
105
- paid_python-0.3.4.dist-info/RECORD,,
122
+ paid_python-0.3.6.dist-info/LICENSE,sha256=Nz4baY1zvv0Qy7lqrQtbaiMhmEeGr2Q7A93aqzpml4c,1071
123
+ paid_python-0.3.6.dist-info/METADATA,sha256=1z2fAr0_DoxcW9K249iiqR7HKQOs4VW5UsOcdwT3VXM,23632
124
+ paid_python-0.3.6.dist-info/WHEEL,sha256=Zb28QaM1gQi8f4VCBhsUklF61CTlNYfs9YAZn-TOGFk,88
125
+ paid_python-0.3.6.dist-info/RECORD,,