paid-python 0.3.5__tar.gz → 0.4.0__tar.gz

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 (125) hide show
  1. {paid_python-0.3.5 → paid_python-0.4.0}/PKG-INFO +10 -2
  2. {paid_python-0.3.5 → paid_python-0.4.0}/README.md +8 -0
  3. {paid_python-0.3.5 → paid_python-0.4.0}/pyproject.toml +2 -2
  4. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/tracing/__init__.py +2 -1
  5. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/tracing/autoinstrumentation.py +3 -5
  6. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/tracing/tracing.py +30 -3
  7. {paid_python-0.3.5 → paid_python-0.4.0}/LICENSE +0 -0
  8. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/__init__.py +0 -0
  9. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/_vendor/__init__.py +0 -0
  10. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/_vendor/opentelemetry/__init__.py +0 -0
  11. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/_vendor/opentelemetry/instrumentation/__init__.py +0 -0
  12. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/_vendor/opentelemetry/instrumentation/openai/__init__.py +0 -0
  13. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/_vendor/opentelemetry/instrumentation/openai/shared/__init__.py +0 -0
  14. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/_vendor/opentelemetry/instrumentation/openai/shared/chat_wrappers.py +0 -0
  15. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/_vendor/opentelemetry/instrumentation/openai/shared/completion_wrappers.py +0 -0
  16. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/_vendor/opentelemetry/instrumentation/openai/shared/config.py +0 -0
  17. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/_vendor/opentelemetry/instrumentation/openai/shared/embeddings_wrappers.py +0 -0
  18. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/_vendor/opentelemetry/instrumentation/openai/shared/event_emitter.py +0 -0
  19. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/_vendor/opentelemetry/instrumentation/openai/shared/event_models.py +0 -0
  20. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/_vendor/opentelemetry/instrumentation/openai/shared/image_gen_wrappers.py +0 -0
  21. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/_vendor/opentelemetry/instrumentation/openai/shared/span_utils.py +0 -0
  22. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/_vendor/opentelemetry/instrumentation/openai/utils.py +0 -0
  23. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/_vendor/opentelemetry/instrumentation/openai/v0/__init__.py +0 -0
  24. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/_vendor/opentelemetry/instrumentation/openai/v1/__init__.py +0 -0
  25. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/_vendor/opentelemetry/instrumentation/openai/v1/assistant_wrappers.py +0 -0
  26. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/_vendor/opentelemetry/instrumentation/openai/v1/event_handler_wrapper.py +0 -0
  27. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/_vendor/opentelemetry/instrumentation/openai/v1/responses_wrappers.py +0 -0
  28. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/_vendor/opentelemetry/instrumentation/openai/version.py +0 -0
  29. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/agents/__init__.py +0 -0
  30. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/agents/client.py +0 -0
  31. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/agents/raw_client.py +0 -0
  32. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/client.py +0 -0
  33. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/contacts/__init__.py +0 -0
  34. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/contacts/client.py +0 -0
  35. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/contacts/raw_client.py +0 -0
  36. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/core/__init__.py +0 -0
  37. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/core/api_error.py +0 -0
  38. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/core/client_wrapper.py +0 -0
  39. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/core/datetime_utils.py +0 -0
  40. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/core/file.py +0 -0
  41. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/core/force_multipart.py +0 -0
  42. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/core/http_client.py +0 -0
  43. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/core/http_response.py +0 -0
  44. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/core/jsonable_encoder.py +0 -0
  45. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/core/pydantic_utilities.py +0 -0
  46. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/core/query_encoder.py +0 -0
  47. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/core/remove_none_from_dict.py +0 -0
  48. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/core/request_options.py +0 -0
  49. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/core/serialization.py +0 -0
  50. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/customers/__init__.py +0 -0
  51. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/customers/client.py +0 -0
  52. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/customers/raw_client.py +0 -0
  53. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/environment.py +0 -0
  54. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/errors/__init__.py +0 -0
  55. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/errors/bad_request_error.py +0 -0
  56. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/errors/forbidden_error.py +0 -0
  57. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/errors/not_found_error.py +0 -0
  58. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/logger.py +0 -0
  59. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/orders/__init__.py +0 -0
  60. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/orders/client.py +0 -0
  61. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/orders/lines/__init__.py +0 -0
  62. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/orders/lines/client.py +0 -0
  63. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/orders/lines/raw_client.py +0 -0
  64. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/orders/raw_client.py +0 -0
  65. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/py.typed +0 -0
  66. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/tracing/context_data.py +0 -0
  67. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/tracing/context_manager.py +0 -0
  68. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/tracing/distributed_tracing.py +0 -0
  69. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/tracing/signal.py +0 -0
  70. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/tracing/wrappers/__init__.py +0 -0
  71. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/tracing/wrappers/anthropic/__init__.py +0 -0
  72. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/tracing/wrappers/anthropic/anthropicWrapper.py +0 -0
  73. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/tracing/wrappers/bedrock/__init__.py +0 -0
  74. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/tracing/wrappers/bedrock/bedrockWrapper.py +0 -0
  75. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/tracing/wrappers/gemini/__init__.py +0 -0
  76. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/tracing/wrappers/gemini/geminiWrapper.py +0 -0
  77. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/tracing/wrappers/langchain/__init__.py +0 -0
  78. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/tracing/wrappers/langchain/paidLangChainCallback.py +0 -0
  79. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/tracing/wrappers/llamaindex/__init__.py +0 -0
  80. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/tracing/wrappers/llamaindex/llamaIndexWrapper.py +0 -0
  81. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/tracing/wrappers/mistral/__init__.py +0 -0
  82. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/tracing/wrappers/mistral/mistralWrapper.py +0 -0
  83. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/tracing/wrappers/openai/__init__.py +0 -0
  84. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/tracing/wrappers/openai/openAiWrapper.py +0 -0
  85. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/tracing/wrappers/openai_agents/__init__.py +0 -0
  86. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/tracing/wrappers/openai_agents/openaiAgentsHook.py +0 -0
  87. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/tracing/wrappers/utils.py +0 -0
  88. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/types/__init__.py +0 -0
  89. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/types/address.py +0 -0
  90. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/types/agent.py +0 -0
  91. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/types/agent_attribute.py +0 -0
  92. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/types/agent_price_point.py +0 -0
  93. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/types/agent_price_point_tiers.py +0 -0
  94. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/types/agent_update.py +0 -0
  95. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/types/api_error.py +0 -0
  96. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/types/billing_frequency.py +0 -0
  97. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/types/charge_type.py +0 -0
  98. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/types/contact.py +0 -0
  99. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/types/cost_amount.py +0 -0
  100. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/types/cost_trace.py +0 -0
  101. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/types/cost_traces_response.py +0 -0
  102. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/types/creation_source.py +0 -0
  103. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/types/creation_state.py +0 -0
  104. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/types/customer.py +0 -0
  105. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/types/customer_update.py +0 -0
  106. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/types/entitlement_usage.py +0 -0
  107. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/types/error.py +0 -0
  108. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/types/order.py +0 -0
  109. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/types/order_line.py +0 -0
  110. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/types/order_line_attribute.py +0 -0
  111. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/types/order_line_attribute_create.py +0 -0
  112. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/types/order_line_attribute_pricing.py +0 -0
  113. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/types/order_line_create.py +0 -0
  114. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/types/pagination_meta.py +0 -0
  115. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/types/price_point.py +0 -0
  116. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/types/pricing.py +0 -0
  117. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/types/pricing_model_type.py +0 -0
  118. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/types/salutation.py +0 -0
  119. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/types/signal.py +0 -0
  120. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/types/tax_exempt_status.py +0 -0
  121. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/types/tier.py +0 -0
  122. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/usage/__init__.py +0 -0
  123. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/usage/client.py +0 -0
  124. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/usage/raw_client.py +0 -0
  125. {paid_python-0.3.5 → paid_python-0.4.0}/src/paid/version.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: paid-python
3
- Version: 0.3.5
3
+ Version: 0.4.0
4
4
  Summary:
5
5
  Requires-Python: >=3.9,<3.14
6
6
  Classifier: Intended Audience :: Developers
@@ -21,11 +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
29
  Requires-Dist: opentelemetry-sdk (>=1.23.0)
30
30
  Requires-Dist: pydantic (>=1.9.0)
31
31
  Requires-Dist: pydantic-core (>=2.18.0)
@@ -767,6 +767,14 @@ async def do_work():
767
767
  await do_work()
768
768
  ```
769
769
 
770
+ ### Paid OTEL Tracer Provider
771
+
772
+ If you would like to use the Paid OTEL tracer provider:
773
+ ```python
774
+ from paid.tracing import get_paid_tracer_provider
775
+ paid_tracer_provider = get_paid_tracer_provider()
776
+ ```
777
+
770
778
  ## Contributing
771
779
 
772
780
  While we value open-source contributions to this SDK, this library is generated programmatically.
@@ -732,6 +732,14 @@ async def do_work():
732
732
  await do_work()
733
733
  ```
734
734
 
735
+ ### Paid OTEL Tracer Provider
736
+
737
+ If you would like to use the Paid OTEL tracer provider:
738
+ ```python
739
+ from paid.tracing import get_paid_tracer_provider
740
+ paid_tracer_provider = get_paid_tracer_provider()
741
+ ```
742
+
735
743
  ## Contributing
736
744
 
737
745
  While we value open-source contributions to this SDK, this library is generated programmatically.
@@ -3,7 +3,7 @@ name = "paid-python"
3
3
 
4
4
  [tool.poetry]
5
5
  name = "paid-python"
6
- version = "0.3.5"
6
+ version = "0.4.0"
7
7
  description = ""
8
8
  readme = "README.md"
9
9
  authors = []
@@ -45,7 +45,7 @@ mutagen = ">=1.47.0"
45
45
  python-dotenv = ">=0.15.0"
46
46
  opentelemetry-instrumentation-anthropic = ">=0.47.0"
47
47
  # opentelemetry-instrumentation-openai is vendored from https://github.com/paid-ai/openllmetry-instrumentation-patch (patched version)
48
- opentelemetry-instrumentation-langchain = ">=0.47.0"
48
+ openinference-instrumentation-langchain = ">=0.1.55"
49
49
  openinference-instrumentation-openai-agents = ">=1.0.0"
50
50
  openinference-instrumentation-bedrock = ">=0.1.0"
51
51
  openinference-instrumentation-google-genai = ">=0.1.8"
@@ -7,13 +7,14 @@ from .distributed_tracing import (
7
7
  unset_tracing_token,
8
8
  )
9
9
  from .signal import signal
10
- from .tracing import initialize_tracing
10
+ from .tracing import initialize_tracing, get_paid_tracer_provider
11
11
 
12
12
  __all__ = [
13
13
  "generate_tracing_token",
14
14
  "paid_autoinstrument",
15
15
  "paid_tracing",
16
16
  "initialize_tracing",
17
+ "get_paid_tracer_provider",
17
18
  "set_tracing_token",
18
19
  "unset_tracing_token",
19
20
  "signal",
@@ -44,7 +44,7 @@ except ImportError:
44
44
  BEDROCK_AVAILABLE = False
45
45
 
46
46
  try:
47
- from opentelemetry.instrumentation.langchain import LangchainInstrumentor
47
+ from openinference.instrumentation.langchain import LangChainInstrumentor
48
48
 
49
49
  LANGCHAIN_AVAILABLE = True
50
50
  except ImportError:
@@ -196,16 +196,14 @@ def _instrument_bedrock() -> None:
196
196
 
197
197
  def _instrument_langchain() -> None:
198
198
  """
199
- Instrument LangChain using opentelemetry-instrumentation-langchain.
199
+ Instrument LangChain using openinference-instrumentation-langchain.
200
200
  """
201
201
  if not LANGCHAIN_AVAILABLE:
202
202
  logger.warning("LangChain instrumentation library not available, skipping instrumentation")
203
203
  return
204
204
 
205
205
  # Instrument LangChain with Paid's tracer provider
206
- LangchainInstrumentor(disable_trace_context_propagation=True).instrument(
207
- tracer_provider=tracing.paid_tracer_provider
208
- )
206
+ LangChainInstrumentor().instrument(tracer_provider=tracing.paid_tracer_provider)
209
207
 
210
208
  _initialized_instrumentors.append("langchain")
211
209
  logger.info("LangChain auto-instrumentation enabled")
@@ -56,6 +56,22 @@ def set_token(token: str) -> None:
56
56
  # Initialized at module load with defaults, never None (uses no-op provider if not initialized or API key isn't available)
57
57
  paid_tracer_provider: Union[TracerProvider, NoOpTracerProvider] = NoOpTracerProvider()
58
58
 
59
+ def get_paid_tracer_provider() -> Optional[TracerProvider]:
60
+ """Export the tracer provider to the user.
61
+ Initialize tracing if not already. Never return NoOpTracerProvider.
62
+
63
+ Returns:
64
+ The tracer provider instance.
65
+ """
66
+ global paid_tracer_provider
67
+
68
+ if get_token() is None:
69
+ initialize_tracing()
70
+
71
+ if not isinstance(paid_tracer_provider, TracerProvider):
72
+ return None
73
+
74
+ return paid_tracer_provider
59
75
 
60
76
  class PaidSpanProcessor(SpanProcessor):
61
77
  """
@@ -63,25 +79,36 @@ class PaidSpanProcessor(SpanProcessor):
63
79
  1. Prefixes all span names with 'paid.trace.'
64
80
  2. Automatically adds external_customer_id and external_agent_id attributes
65
81
  to all spans based on context variables set by the tracing decorator.
82
+ 3. Filters out prompt/response data unless store_prompt=True.
83
+ 4. Filters out duplicate LangChain spans that may duplicate information from other instrumentations.
66
84
  """
67
85
 
68
86
  SPAN_NAME_PREFIX = "paid.trace."
69
87
  PROMPT_ATTRIBUTES_SUBSTRINGS = {
70
- "prompt",
71
- # "gen_ai.prompt",
72
88
  "gen_ai.completion",
73
89
  "gen_ai.request.messages",
74
90
  "gen_ai.response.messages",
75
91
  "llm.output_message",
76
92
  "llm.input_message",
77
93
  "llm.invocation_parameters",
94
+ "gen_ai.prompt",
95
+ "langchain.prompt",
78
96
  "output.value",
79
97
  "input.value",
80
- # "langchain.prompt",
81
98
  }
82
99
 
83
100
  def on_start(self, span: Span, parent_context: Optional[Context] = None) -> None:
84
101
  """Called when a span is started. Prefix the span name and add attributes."""
102
+
103
+ LANGCHAIN_SPAN_FILTERS = ["ChatOpenAI", "ChatAnthropic"]
104
+ if any(f in span.name for f in LANGCHAIN_SPAN_FILTERS):
105
+ # HACK TO FILTER DUPLICATE SPANS CREATED BY LANGCHAIN INSTRUMENTATION.
106
+ # Langchain instrumentation creates spans, that are created by other instrumentations (ex. OpenAI, Anthropic).
107
+ # Not all spans need filtering (ex. ChatGoogleGenerativeAI), so first test actual telemetry before adding filters.
108
+ # TODO: maybe consider a dropping sampler for such spans instead of raising an exception?
109
+ logger.debug(f"Dropping Langchain span: {span.name}")
110
+ raise Exception(f"Dropping Langchain span: {span.name}")
111
+
85
112
  # Prefix the span name
86
113
  if span.name and not span.name.startswith(self.SPAN_NAME_PREFIX):
87
114
  span.update_name(f"{self.SPAN_NAME_PREFIX}{span.name}")
File without changes