paid-python 0.2.1__tar.gz → 0.3.1__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 (105) hide show
  1. {paid_python-0.2.1 → paid_python-0.3.1}/PKG-INFO +2 -2
  2. {paid_python-0.2.1 → paid_python-0.3.1}/pyproject.toml +2 -2
  3. {paid_python-0.2.1 → paid_python-0.3.1}/src/paid/tracing/autoinstrumentation.py +27 -28
  4. {paid_python-0.2.1 → paid_python-0.3.1}/src/paid/tracing/context_data.py +25 -0
  5. {paid_python-0.2.1 → paid_python-0.3.1}/src/paid/tracing/distributed_tracing.py +1 -1
  6. {paid_python-0.2.1 → paid_python-0.3.1}/src/paid/tracing/tracing.py +7 -6
  7. {paid_python-0.2.1 → paid_python-0.3.1}/LICENSE +0 -0
  8. {paid_python-0.2.1 → paid_python-0.3.1}/README.md +0 -0
  9. {paid_python-0.2.1 → paid_python-0.3.1}/src/paid/__init__.py +0 -0
  10. {paid_python-0.2.1 → paid_python-0.3.1}/src/paid/agents/__init__.py +0 -0
  11. {paid_python-0.2.1 → paid_python-0.3.1}/src/paid/agents/client.py +0 -0
  12. {paid_python-0.2.1 → paid_python-0.3.1}/src/paid/agents/raw_client.py +0 -0
  13. {paid_python-0.2.1 → paid_python-0.3.1}/src/paid/client.py +0 -0
  14. {paid_python-0.2.1 → paid_python-0.3.1}/src/paid/contacts/__init__.py +0 -0
  15. {paid_python-0.2.1 → paid_python-0.3.1}/src/paid/contacts/client.py +0 -0
  16. {paid_python-0.2.1 → paid_python-0.3.1}/src/paid/contacts/raw_client.py +0 -0
  17. {paid_python-0.2.1 → paid_python-0.3.1}/src/paid/core/__init__.py +0 -0
  18. {paid_python-0.2.1 → paid_python-0.3.1}/src/paid/core/api_error.py +0 -0
  19. {paid_python-0.2.1 → paid_python-0.3.1}/src/paid/core/client_wrapper.py +0 -0
  20. {paid_python-0.2.1 → paid_python-0.3.1}/src/paid/core/datetime_utils.py +0 -0
  21. {paid_python-0.2.1 → paid_python-0.3.1}/src/paid/core/file.py +0 -0
  22. {paid_python-0.2.1 → paid_python-0.3.1}/src/paid/core/force_multipart.py +0 -0
  23. {paid_python-0.2.1 → paid_python-0.3.1}/src/paid/core/http_client.py +0 -0
  24. {paid_python-0.2.1 → paid_python-0.3.1}/src/paid/core/http_response.py +0 -0
  25. {paid_python-0.2.1 → paid_python-0.3.1}/src/paid/core/jsonable_encoder.py +0 -0
  26. {paid_python-0.2.1 → paid_python-0.3.1}/src/paid/core/pydantic_utilities.py +0 -0
  27. {paid_python-0.2.1 → paid_python-0.3.1}/src/paid/core/query_encoder.py +0 -0
  28. {paid_python-0.2.1 → paid_python-0.3.1}/src/paid/core/remove_none_from_dict.py +0 -0
  29. {paid_python-0.2.1 → paid_python-0.3.1}/src/paid/core/request_options.py +0 -0
  30. {paid_python-0.2.1 → paid_python-0.3.1}/src/paid/core/serialization.py +0 -0
  31. {paid_python-0.2.1 → paid_python-0.3.1}/src/paid/customers/__init__.py +0 -0
  32. {paid_python-0.2.1 → paid_python-0.3.1}/src/paid/customers/client.py +0 -0
  33. {paid_python-0.2.1 → paid_python-0.3.1}/src/paid/customers/raw_client.py +0 -0
  34. {paid_python-0.2.1 → paid_python-0.3.1}/src/paid/environment.py +0 -0
  35. {paid_python-0.2.1 → paid_python-0.3.1}/src/paid/errors/__init__.py +0 -0
  36. {paid_python-0.2.1 → paid_python-0.3.1}/src/paid/errors/bad_request_error.py +0 -0
  37. {paid_python-0.2.1 → paid_python-0.3.1}/src/paid/errors/forbidden_error.py +0 -0
  38. {paid_python-0.2.1 → paid_python-0.3.1}/src/paid/errors/not_found_error.py +0 -0
  39. {paid_python-0.2.1 → paid_python-0.3.1}/src/paid/logger.py +0 -0
  40. {paid_python-0.2.1 → paid_python-0.3.1}/src/paid/orders/__init__.py +0 -0
  41. {paid_python-0.2.1 → paid_python-0.3.1}/src/paid/orders/client.py +0 -0
  42. {paid_python-0.2.1 → paid_python-0.3.1}/src/paid/orders/lines/__init__.py +0 -0
  43. {paid_python-0.2.1 → paid_python-0.3.1}/src/paid/orders/lines/client.py +0 -0
  44. {paid_python-0.2.1 → paid_python-0.3.1}/src/paid/orders/lines/raw_client.py +0 -0
  45. {paid_python-0.2.1 → paid_python-0.3.1}/src/paid/orders/raw_client.py +0 -0
  46. {paid_python-0.2.1 → paid_python-0.3.1}/src/paid/py.typed +0 -0
  47. {paid_python-0.2.1 → paid_python-0.3.1}/src/paid/tracing/__init__.py +0 -0
  48. {paid_python-0.2.1 → paid_python-0.3.1}/src/paid/tracing/context_manager.py +0 -0
  49. {paid_python-0.2.1 → paid_python-0.3.1}/src/paid/tracing/signal.py +0 -0
  50. {paid_python-0.2.1 → paid_python-0.3.1}/src/paid/tracing/wrappers/__init__.py +0 -0
  51. {paid_python-0.2.1 → paid_python-0.3.1}/src/paid/tracing/wrappers/anthropic/__init__.py +0 -0
  52. {paid_python-0.2.1 → paid_python-0.3.1}/src/paid/tracing/wrappers/anthropic/anthropicWrapper.py +0 -0
  53. {paid_python-0.2.1 → paid_python-0.3.1}/src/paid/tracing/wrappers/bedrock/__init__.py +0 -0
  54. {paid_python-0.2.1 → paid_python-0.3.1}/src/paid/tracing/wrappers/bedrock/bedrockWrapper.py +0 -0
  55. {paid_python-0.2.1 → paid_python-0.3.1}/src/paid/tracing/wrappers/gemini/__init__.py +0 -0
  56. {paid_python-0.2.1 → paid_python-0.3.1}/src/paid/tracing/wrappers/gemini/geminiWrapper.py +0 -0
  57. {paid_python-0.2.1 → paid_python-0.3.1}/src/paid/tracing/wrappers/langchain/__init__.py +0 -0
  58. {paid_python-0.2.1 → paid_python-0.3.1}/src/paid/tracing/wrappers/langchain/paidLangChainCallback.py +0 -0
  59. {paid_python-0.2.1 → paid_python-0.3.1}/src/paid/tracing/wrappers/llamaindex/__init__.py +0 -0
  60. {paid_python-0.2.1 → paid_python-0.3.1}/src/paid/tracing/wrappers/llamaindex/llamaIndexWrapper.py +0 -0
  61. {paid_python-0.2.1 → paid_python-0.3.1}/src/paid/tracing/wrappers/mistral/__init__.py +0 -0
  62. {paid_python-0.2.1 → paid_python-0.3.1}/src/paid/tracing/wrappers/mistral/mistralWrapper.py +0 -0
  63. {paid_python-0.2.1 → paid_python-0.3.1}/src/paid/tracing/wrappers/openai/__init__.py +0 -0
  64. {paid_python-0.2.1 → paid_python-0.3.1}/src/paid/tracing/wrappers/openai/openAiWrapper.py +0 -0
  65. {paid_python-0.2.1 → paid_python-0.3.1}/src/paid/tracing/wrappers/openai_agents/__init__.py +0 -0
  66. {paid_python-0.2.1 → paid_python-0.3.1}/src/paid/tracing/wrappers/openai_agents/openaiAgentsHook.py +0 -0
  67. {paid_python-0.2.1 → paid_python-0.3.1}/src/paid/tracing/wrappers/utils.py +0 -0
  68. {paid_python-0.2.1 → paid_python-0.3.1}/src/paid/types/__init__.py +0 -0
  69. {paid_python-0.2.1 → paid_python-0.3.1}/src/paid/types/address.py +0 -0
  70. {paid_python-0.2.1 → paid_python-0.3.1}/src/paid/types/agent.py +0 -0
  71. {paid_python-0.2.1 → paid_python-0.3.1}/src/paid/types/agent_attribute.py +0 -0
  72. {paid_python-0.2.1 → paid_python-0.3.1}/src/paid/types/agent_price_point.py +0 -0
  73. {paid_python-0.2.1 → paid_python-0.3.1}/src/paid/types/agent_price_point_tiers.py +0 -0
  74. {paid_python-0.2.1 → paid_python-0.3.1}/src/paid/types/agent_update.py +0 -0
  75. {paid_python-0.2.1 → paid_python-0.3.1}/src/paid/types/api_error.py +0 -0
  76. {paid_python-0.2.1 → paid_python-0.3.1}/src/paid/types/billing_frequency.py +0 -0
  77. {paid_python-0.2.1 → paid_python-0.3.1}/src/paid/types/charge_type.py +0 -0
  78. {paid_python-0.2.1 → paid_python-0.3.1}/src/paid/types/contact.py +0 -0
  79. {paid_python-0.2.1 → paid_python-0.3.1}/src/paid/types/cost_amount.py +0 -0
  80. {paid_python-0.2.1 → paid_python-0.3.1}/src/paid/types/cost_trace.py +0 -0
  81. {paid_python-0.2.1 → paid_python-0.3.1}/src/paid/types/cost_traces_response.py +0 -0
  82. {paid_python-0.2.1 → paid_python-0.3.1}/src/paid/types/creation_source.py +0 -0
  83. {paid_python-0.2.1 → paid_python-0.3.1}/src/paid/types/creation_state.py +0 -0
  84. {paid_python-0.2.1 → paid_python-0.3.1}/src/paid/types/customer.py +0 -0
  85. {paid_python-0.2.1 → paid_python-0.3.1}/src/paid/types/customer_update.py +0 -0
  86. {paid_python-0.2.1 → paid_python-0.3.1}/src/paid/types/entitlement_usage.py +0 -0
  87. {paid_python-0.2.1 → paid_python-0.3.1}/src/paid/types/error.py +0 -0
  88. {paid_python-0.2.1 → paid_python-0.3.1}/src/paid/types/order.py +0 -0
  89. {paid_python-0.2.1 → paid_python-0.3.1}/src/paid/types/order_line.py +0 -0
  90. {paid_python-0.2.1 → paid_python-0.3.1}/src/paid/types/order_line_attribute.py +0 -0
  91. {paid_python-0.2.1 → paid_python-0.3.1}/src/paid/types/order_line_attribute_create.py +0 -0
  92. {paid_python-0.2.1 → paid_python-0.3.1}/src/paid/types/order_line_attribute_pricing.py +0 -0
  93. {paid_python-0.2.1 → paid_python-0.3.1}/src/paid/types/order_line_create.py +0 -0
  94. {paid_python-0.2.1 → paid_python-0.3.1}/src/paid/types/pagination_meta.py +0 -0
  95. {paid_python-0.2.1 → paid_python-0.3.1}/src/paid/types/price_point.py +0 -0
  96. {paid_python-0.2.1 → paid_python-0.3.1}/src/paid/types/pricing.py +0 -0
  97. {paid_python-0.2.1 → paid_python-0.3.1}/src/paid/types/pricing_model_type.py +0 -0
  98. {paid_python-0.2.1 → paid_python-0.3.1}/src/paid/types/salutation.py +0 -0
  99. {paid_python-0.2.1 → paid_python-0.3.1}/src/paid/types/signal.py +0 -0
  100. {paid_python-0.2.1 → paid_python-0.3.1}/src/paid/types/tax_exempt_status.py +0 -0
  101. {paid_python-0.2.1 → paid_python-0.3.1}/src/paid/types/tier.py +0 -0
  102. {paid_python-0.2.1 → paid_python-0.3.1}/src/paid/usage/__init__.py +0 -0
  103. {paid_python-0.2.1 → paid_python-0.3.1}/src/paid/usage/client.py +0 -0
  104. {paid_python-0.2.1 → paid_python-0.3.1}/src/paid/usage/raw_client.py +0 -0
  105. {paid_python-0.2.1 → paid_python-0.3.1}/src/paid/version.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: paid-python
3
- Version: 0.2.1
3
+ Version: 0.3.1
4
4
  Summary:
5
5
  Requires-Python: >=3.9,<3.14
6
6
  Classifier: Intended Audience :: Developers
@@ -20,11 +20,11 @@ Classifier: Typing :: Typed
20
20
  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
+ Requires-Dist: openinference-instrumentation-google-genai (>=0.1.8)
23
24
  Requires-Dist: openinference-instrumentation-openai-agents (>=1.0.0)
24
25
  Requires-Dist: opentelemetry-api (>=1.23.0)
25
26
  Requires-Dist: opentelemetry-exporter-otlp-proto-http (>=1.23.0)
26
27
  Requires-Dist: opentelemetry-instrumentation-anthropic (>=0.47.0)
27
- Requires-Dist: opentelemetry-instrumentation-google-generativeai (>=0.47.0)
28
28
  Requires-Dist: opentelemetry-instrumentation-langchain (>=0.47.0)
29
29
  Requires-Dist: opentelemetry-instrumentation-openai (>=0.47.0)
30
30
  Requires-Dist: opentelemetry-sdk (>=1.23.0)
@@ -3,7 +3,7 @@ name = "paid-python"
3
3
 
4
4
  [tool.poetry]
5
5
  name = "paid-python"
6
- version = "0.2.1"
6
+ version = "0.3.1"
7
7
  description = ""
8
8
  readme = "README.md"
9
9
  authors = []
@@ -44,11 +44,11 @@ opentelemetry-exporter-otlp-proto-http = ">=1.23.0"
44
44
  mutagen = ">=1.47.0"
45
45
  python-dotenv = ">=0.15.0"
46
46
  opentelemetry-instrumentation-anthropic = ">=0.47.0"
47
- opentelemetry-instrumentation-google-generativeai = ">=0.47.0"
48
47
  opentelemetry-instrumentation-openai = ">=0.47.0"
49
48
  opentelemetry-instrumentation-langchain = ">=0.47.0"
50
49
  openinference-instrumentation-openai-agents = ">=1.0.0"
51
50
  openinference-instrumentation-bedrock = ">=0.1.0"
51
+ openinference-instrumentation-google-genai = ">=0.1.8"
52
52
 
53
53
  [tool.poetry.group.dev.dependencies]
54
54
  mypy = "==1.13.0"
@@ -21,13 +21,6 @@ try:
21
21
  except ImportError:
22
22
  ANTHROPIC_AVAILABLE = False
23
23
 
24
- try:
25
- from opentelemetry.instrumentation.google_generativeai import GoogleGenerativeAiInstrumentor
26
-
27
- GEMINI_AVAILABLE = True
28
- except ImportError:
29
- GEMINI_AVAILABLE = False
30
-
31
24
  try:
32
25
  from opentelemetry.instrumentation.openai import OpenAIInstrumentor
33
26
 
@@ -56,6 +49,13 @@ try:
56
49
  except ImportError:
57
50
  LANGCHAIN_AVAILABLE = False
58
51
 
52
+ try:
53
+ from openinference.instrumentation.google_genai import GoogleGenAIInstrumentor
54
+
55
+ GOOGLE_GENAI_AVAILABLE = True
56
+ except ImportError:
57
+ GOOGLE_GENAI_AVAILABLE = False
58
+
59
59
 
60
60
  # Track which instrumentors have been initialized
61
61
  _initialized_instrumentors: List[str] = []
@@ -72,11 +72,11 @@ def paid_autoinstrument(libraries: Optional[List[str]] = None) -> None:
72
72
  Args:
73
73
  libraries: List of library names to instrument. Currently supported:
74
74
  - "anthropic": Anthropic library
75
- - "gemini": Gemini library
76
75
  - "openai": OpenAI library
77
76
  - "openai-agents": OpenAI Agents SDK
78
77
  - "bedrock": AWS Bedrock
79
78
  - "langchain": LangChain library
79
+ - "google-genai": Google GenAI library
80
80
  If None, all supported libraries that are installed will be instrumented.
81
81
 
82
82
  Note:
@@ -106,7 +106,7 @@ def paid_autoinstrument(libraries: Optional[List[str]] = None) -> None:
106
106
 
107
107
  # Default to all supported libraries if none specified
108
108
  if libraries is None:
109
- libraries = ["anthropic", "gemini", "openai", "openai-agents", "bedrock", "langchain"]
109
+ libraries = ["anthropic", "openai", "openai-agents", "bedrock", "langchain", "google-genai"]
110
110
 
111
111
  for library in libraries:
112
112
  if library in _initialized_instrumentors:
@@ -115,8 +115,6 @@ def paid_autoinstrument(libraries: Optional[List[str]] = None) -> None:
115
115
 
116
116
  if library == "anthropic":
117
117
  _instrument_anthropic()
118
- elif library == "gemini":
119
- _instrument_gemini()
120
118
  elif library == "openai":
121
119
  _instrument_openai()
122
120
  elif library == "openai-agents":
@@ -125,6 +123,8 @@ def paid_autoinstrument(libraries: Optional[List[str]] = None) -> None:
125
123
  _instrument_bedrock()
126
124
  elif library == "langchain":
127
125
  _instrument_langchain()
126
+ elif library == "google-genai":
127
+ _instrument_google_genai()
128
128
  else:
129
129
  logger.warning(
130
130
  f"Unknown library '{library}' - supported libraries: anthropic, gemini, openai, openai-agents, bedrock, langchain"
@@ -148,21 +148,6 @@ def _instrument_anthropic() -> None:
148
148
  logger.info("Anthropic auto-instrumentation enabled")
149
149
 
150
150
 
151
- def _instrument_gemini() -> None:
152
- """
153
- Instrument the Google Gemini library using opentelemetry-instrumentation-google-generativeai.
154
- """
155
- if not GEMINI_AVAILABLE:
156
- logger.warning("Gemini library not available, skipping instrumentation")
157
- return
158
-
159
- # Instrument Gemini with Paid's tracer provider
160
- GoogleGenerativeAiInstrumentor().instrument(tracer_provider=tracing.paid_tracer_provider)
161
-
162
- _initialized_instrumentors.append("gemini")
163
- logger.info("Gemini auto-instrumentation enabled")
164
-
165
-
166
151
  def _instrument_openai() -> None:
167
152
  """
168
153
  Instrument the OpenAI library using opentelemetry-instrumentation-openai.
@@ -217,8 +202,22 @@ def _instrument_langchain() -> None:
217
202
  return
218
203
 
219
204
  # Instrument LangChain with Paid's tracer provider
220
- LangchainInstrumentor(disable_trace_context_propagation=True).instrument(tracer_provider=tracing.paid_tracer_provider)
221
-
205
+ LangchainInstrumentor(disable_trace_context_propagation=True).instrument(
206
+ tracer_provider=tracing.paid_tracer_provider
207
+ )
222
208
 
223
209
  _initialized_instrumentors.append("langchain")
224
210
  logger.info("LangChain auto-instrumentation enabled")
211
+
212
+
213
+ def _instrument_google_genai() -> None:
214
+ """
215
+ Instrument Google GenAI using openinference-instrumentation-google-genai.
216
+ """
217
+ if not GOOGLE_GENAI_AVAILABLE:
218
+ logger.warning("Google GenAI instrumentation library not available, skipping instrumentation")
219
+ return
220
+
221
+ GoogleGenAIInstrumentor().instrument(tracer_provider=tracing.paid_tracer_provider)
222
+ _initialized_instrumentors.append("google-genai")
223
+ logger.info("Google GenAI auto-instrumentation enabled")
@@ -44,6 +44,8 @@ class ContextData:
44
44
 
45
45
  @classmethod
46
46
  def set_context_key(cls, key: str, value: Any) -> None:
47
+ if value is None:
48
+ return
47
49
  if key not in cls._context:
48
50
  logger.warning(f"Invalid context key: {key}")
49
51
  return
@@ -51,6 +53,18 @@ class ContextData:
51
53
  reset_tokens = cls._get_or_create_reset_tokens()
52
54
  reset_tokens[key] = reset_token
53
55
 
56
+ @classmethod
57
+ def unset_context_key(cls, key: str) -> None:
58
+ """Unset a specific context key"""
59
+ if key not in cls._context:
60
+ logger.warning(f"Invalid context key: {key}")
61
+ return
62
+ reset_tokens = cls._reset_tokens.get()
63
+ if reset_tokens:
64
+ _ = cls._context[key].set(None)
65
+ if key in reset_tokens:
66
+ del reset_tokens[key]
67
+
54
68
  @classmethod
55
69
  def reset_context(cls) -> None:
56
70
  reset_tokens = cls._reset_tokens.get()
@@ -58,3 +72,14 @@ class ContextData:
58
72
  for key, reset_token in reset_tokens.items():
59
73
  cls._context[key].reset(reset_token)
60
74
  reset_tokens.clear()
75
+
76
+ @classmethod
77
+ def reset_context_key(cls, key: str) -> None:
78
+ """Reset a specific context key to its previous value using the stored reset token."""
79
+ if key not in cls._context:
80
+ logger.warning(f"Invalid context key: {key}")
81
+ return
82
+ reset_tokens = cls._reset_tokens.get()
83
+ if reset_tokens and key in reset_tokens:
84
+ cls._context[key].reset(reset_tokens[key])
85
+ del reset_tokens[key]
@@ -110,4 +110,4 @@ def unset_tracing_token():
110
110
  DeprecationWarning,
111
111
  stacklevel=2,
112
112
  )
113
- ContextData.set_context_key("trace_id", None)
113
+ ContextData.unset_context_key("trace_id")
@@ -137,12 +137,11 @@ class PaidSpanProcessor(SpanProcessor):
137
137
  """Called to force flush. Always returns True since there's nothing to flush."""
138
138
  return True
139
139
 
140
+
140
141
  def setup_graceful_termination():
141
142
  def flush_traces():
142
143
  try:
143
- if not isinstance(paid_tracer_provider, NoOpTracerProvider) and not paid_tracer_provider.force_flush(
144
- 10000
145
- ):
144
+ if not isinstance(paid_tracer_provider, NoOpTracerProvider) and not paid_tracer_provider.force_flush(10000):
146
145
  logger.error("OTEL force flush : timeout reached")
147
146
  except Exception as e:
148
147
  logger.error(f"Error flushing traces: {e}")
@@ -169,8 +168,10 @@ def setup_graceful_termination():
169
168
  for sig in (signal.SIGINT, signal.SIGTERM):
170
169
  signal.signal(sig, create_chained_signal_handler(sig))
171
170
  except Exception as e:
172
- logger.warning(f"Could not set up termination handlers: {e}"
173
- "\nConsider calling initialize_tracing() from the main thread during app initialization if you don't already")
171
+ logger.warning(
172
+ f"Could not set up termination handlers: {e}"
173
+ "\nConsider calling initialize_tracing() from the main thread during app initialization if you don't already"
174
+ )
174
175
 
175
176
 
176
177
  def initialize_tracing(api_key: Optional[str] = None, collector_endpoint: Optional[str] = DEFAULT_COLLECTOR_ENDPOINT):
@@ -220,7 +221,7 @@ def initialize_tracing(api_key: Optional[str] = None, collector_endpoint: Option
220
221
  span_processor = SimpleSpanProcessor(otlp_exporter)
221
222
  paid_tracer_provider.add_span_processor(span_processor)
222
223
 
223
- setup_graceful_termination() # doesn't throw
224
+ setup_graceful_termination() # doesn't throw
224
225
 
225
226
  logger.info("Paid tracing initialized successfully - collector at %s", collector_endpoint)
226
227
  except Exception as e:
File without changes
File without changes