paid-python 0.3.3__py3-none-any.whl → 0.3.4__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.
paid/tracing/tracing.py CHANGED
@@ -141,7 +141,7 @@ class PaidSpanProcessor(SpanProcessor):
141
141
  return True
142
142
 
143
143
 
144
- def setup_graceful_termination():
144
+ def setup_graceful_termination(paid_tracer_provider: TracerProvider):
145
145
  def flush_traces():
146
146
  try:
147
147
  if not isinstance(paid_tracer_provider, NoOpTracerProvider) and not paid_tracer_provider.force_flush(10000):
@@ -191,6 +191,12 @@ def initialize_tracing(api_key: Optional[str] = None, collector_endpoint: Option
191
191
  collector_endpoint = DEFAULT_COLLECTOR_ENDPOINT
192
192
 
193
193
  try:
194
+ # Check if tracing is disabled via environment variable
195
+ paid_enabled = os.environ.get("PAID_ENABLED", "true").lower()
196
+ if paid_enabled == "false":
197
+ logger.info("Paid tracing is disabled via PAID_ENABLED environment variable")
198
+ return
199
+
194
200
  if get_token() is not None:
195
201
  logger.warning("Tracing is already initialized - skipping re-initialization")
196
202
  return
@@ -224,7 +230,7 @@ def initialize_tracing(api_key: Optional[str] = None, collector_endpoint: Option
224
230
  span_processor = SimpleSpanProcessor(otlp_exporter)
225
231
  paid_tracer_provider.add_span_processor(span_processor)
226
232
 
227
- setup_graceful_termination() # doesn't throw
233
+ setup_graceful_termination(paid_tracer_provider) # doesn't throw
228
234
 
229
235
  logger.info("Paid tracing initialized successfully - collector at %s", collector_endpoint)
230
236
  except Exception as e:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: paid-python
3
- Version: 0.3.3
3
+ Version: 0.3.4
4
4
  Summary:
5
5
  Requires-Python: >=3.9,<3.14
6
6
  Classifier: Intended Audience :: Developers
@@ -123,6 +123,56 @@ export PAID_LOG_LEVEL=DEBUG
123
123
 
124
124
  Defaults to ERROR.
125
125
 
126
+ ## Environment Variables
127
+
128
+ The Paid SDK supports the following environment variables for configuration:
129
+
130
+ ### `PAID_API_KEY`
131
+
132
+ Your Paid API key for authentication. This is used as a fallback when you don't explicitly pass the `token` parameter to the `Paid()` client or `initialize_tracing()`.
133
+
134
+ ```bash
135
+ export PAID_API_KEY="your_api_key_here"
136
+ ```
137
+
138
+ You can then initialize the client without passing the token:
139
+
140
+ ```python
141
+ from paid import Paid
142
+
143
+ # API key is read from PAID_API_KEY environment variable
144
+ client = Paid()
145
+ ```
146
+
147
+ ### `PAID_ENABLED`
148
+
149
+ Controls whether Paid tracing is enabled. Set to `false` (case-insensitive) to disable all tracing functionality.
150
+
151
+ ```bash
152
+ export PAID_ENABLED=false
153
+ ```
154
+
155
+ This is useful for:
156
+ - Development/testing environments where tracing isn't needed
157
+ - Temporarily disabling tracing without modifying code
158
+ - Feature flagging in different deployment environments
159
+
160
+ Defaults to `true` if not set.
161
+
162
+ ### `PAID_LOG_LEVEL`
163
+
164
+ Sets the logging level for Paid SDK operations. See the [Logging](#logging) section for details.
165
+
166
+ ### `PAID_OTEL_COLLECTOR_ENDPOINT`
167
+
168
+ Overrides the default OpenTelemetry collector endpoint URL. Only needed if you want to route traces to a custom endpoint.
169
+
170
+ ```bash
171
+ export PAID_OTEL_COLLECTOR_ENDPOINT="https://your-custom-endpoint.com:4318/v1/traces"
172
+ ```
173
+
174
+ Defaults to `https://collector.agentpaid.io:4318/v1/traces`.
175
+
126
176
  ## Cost Tracking via OTEL tracing
127
177
 
128
178
  ### Simple Decorator and Context Manager Methods
@@ -42,7 +42,7 @@ paid/tracing/context_data.py,sha256=oiLocz-9qDqB5nQzJlrLsc2Mkr9MaNt_yF_hjppobKc,
42
42
  paid/tracing/context_manager.py,sha256=ZQtsJ9JPxTwn2t4AW26WpYboaOEZdI2T1Sw0Rwsbf-E,8470
43
43
  paid/tracing/distributed_tracing.py,sha256=Vht3U8QJmT5jlRVnrybTn-cI1RPuVtyb3V4eTu6gA4g,3991
44
44
  paid/tracing/signal.py,sha256=PfYxF6EFQS8j7RY5_C5NXrCBVu9Hq2E2tyG4fdQScJk,3252
45
- paid/tracing/tracing.py,sha256=HnQjLTfvrEqL_44pXGo-fYh8KXlWBh0ozp3omB6wuTI,14848
45
+ paid/tracing/tracing.py,sha256=0eMY357by892_32a2qCT6nRCUOHt03gxKCmUH2wDjVg,15184
46
46
  paid/tracing/wrappers/__init__.py,sha256=IIleLB_JUbzLw7FshrU2VHZAKF3dZHMGy1O5zCBwwqM,1588
47
47
  paid/tracing/wrappers/anthropic/__init__.py,sha256=_x1fjySAQxuT5cIGO_jU09LiGcZH-WQLqKg8mUFAu2w,115
48
48
  paid/tracing/wrappers/anthropic/anthropicWrapper.py,sha256=pGchbOb41CbTxc7H8xXoM-LjR085spqrzXqCVC_rrFk,4913
@@ -99,7 +99,7 @@ paid/usage/__init__.py,sha256=_VhToAyIt_5axN6CLJwtxg3-CO7THa_23pbUzqhXJa4,85
99
99
  paid/usage/client.py,sha256=280WJuepoovk3BAVbAx2yN2Q_qBdvx3CcPkLu8lXslc,3030
100
100
  paid/usage/raw_client.py,sha256=2acg5C4lxuZodZjepU9QYF0fmBxgG-3ZgXs1zUJG-wM,3709
101
101
  paid/version.py,sha256=QIpDFnOrxMxrs86eL0iNH0mSZ1DO078wWHYY9TYAoew,78
102
- paid_python-0.3.3.dist-info/LICENSE,sha256=Nz4baY1zvv0Qy7lqrQtbaiMhmEeGr2Q7A93aqzpml4c,1071
103
- paid_python-0.3.3.dist-info/METADATA,sha256=tb9zMnJfciOmVMIwq6G2_R70gk3djrPpXnI50Uootiw,22335
104
- paid_python-0.3.3.dist-info/WHEEL,sha256=Zb28QaM1gQi8f4VCBhsUklF61CTlNYfs9YAZn-TOGFk,88
105
- paid_python-0.3.3.dist-info/RECORD,,
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,,