-
Notifications
You must be signed in to change notification settings - Fork 536
Expand file tree
/
Copy path_native.pyi
More file actions
1639 lines (1470 loc) · 58.7 KB
/
Copy path_native.pyi
File metadata and controls
1639 lines (1470 loc) · 58.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import abc
import contextvars
from enum import Enum
import sys
from typing import Any
from typing import Iterable
from typing import Iterator
from typing import Literal
from typing import Mapping
from typing import Optional
from typing import TypeVar
from typing import Union
from ddtrace._trace.context import Context
from ddtrace._trace.span import Span
from ddtrace._trace.types import _AttributeValueType
# Mirror of ddtrace._trace.provider.ActiveTrace (a Span or a Context).
ActiveTrace = Union[Span, Context]
_SpanDataT = TypeVar("_SpanDataT", bound="SpanData")
class DDSketch:
def __init__(self): ...
def add(self, value: float) -> None: ...
def to_proto(self) -> bytes: ...
@property
def count(self) -> float: ...
class PyConfigurator:
"""
PyConfigurator is a class responsible for configuring the Python environment
for the application. It allows setting environment variables, command-line
arguments, and file overrides, and retrieving the current configuration.
"""
def __init__(self, debug_logs: bool):
"""
Initialize the PyConfigurator.
:param debug_logs: A boolean indicating whether debug logs should be enabled.
"""
...
def set_local_file_override(self, file: str) -> None:
"""
Overrides the local file path for the configuration. Should not be used outside of tests.
:param file: The path to the local file to override.
"""
...
def set_managed_file_override(self, file: str) -> None:
"""
Overrides the managed file path for the configuration. Should not be used outside of tests.
:param file: The path to the managed file to override.
"""
...
def get_configuration(self) -> list[dict[str, str]]:
"""
Retrieve the on-disk configuration.
:return: A list of dictionaries containing the configuration:
[{"source": ..., "key": ..., "value": ..., "config_id": ...}]
"""
...
@property
def local_stable_config_type(self) -> str:
"""
Retrieve the local stable configuration type.
:return: A string representing the local stable configuration type.
"""
...
@property
def fleet_stable_config_type(self) -> str:
"""
Retrieve the fleet stable configuration type.
:return: A string representing the fleet stable configuration type.
"""
...
class StacktraceCollection:
Disabled: "StacktraceCollection"
WithoutSymbols: "StacktraceCollection"
EnabledWithInprocessSymbols: "StacktraceCollection"
EnabledWithSymbolsInReceiver: "StacktraceCollection"
class CrashtrackerConfiguration:
def __init__(
self,
additional_files: list[str],
create_alt_stack: bool,
use_alt_stack: bool,
timeout_ms: int,
resolve_frames: StacktraceCollection,
collect_all_threads: bool,
max_threads: int,
endpoint: Optional[str] = None,
unix_socket_path: Optional[str] = None,
test_token: Optional[str] = None,
): ...
class CrashtrackerReceiverConfig:
def __init__(
self,
args: list[str],
env: dict[str, str],
path_to_receiver_binary: str,
stderr_filename: Optional[str],
stdout_filename: Optional[str],
): ...
class CrashtrackerMetadata:
def __init__(self, library_name: str, library_version: str, family: str, tags: dict[str, str]): ...
class CrashtrackerStatus:
NotInitialized: "CrashtrackerStatus"
Initialized: "CrashtrackerStatus"
FailedToInitialize: "CrashtrackerStatus"
def crashtracker_init(
config: CrashtrackerConfiguration,
receiver_config: CrashtrackerReceiverConfig,
metadata: CrashtrackerMetadata,
) -> None: ...
def crashtracker_on_fork(
config: CrashtrackerConfiguration, receiver_config: CrashtrackerReceiverConfig, metadata: CrashtrackerMetadata
) -> None: ...
def crashtracker_status() -> CrashtrackerStatus: ...
def crashtracker_receiver() -> None: ...
def crashtracker_report_unhandled_exception(
exception_type: Optional[str],
exception_message: Optional[str],
frames: list[dict[str, Optional[str]]],
) -> None: ...
class PyTracerMetadata:
"""
Stores the configuration settings for the Tracer.
This data is saved in a temporary file while the Tracer is running.
"""
def __init__(
self,
runtime_id: Optional[str],
tracer_version: str,
hostname: str,
service_name: Optional[str],
service_env: Optional[str],
service_version: Optional[str],
process_tags: Optional[str],
container_id: Optional[str],
):
"""
Initialize the `PyTracerMetadata`.
:param runtime_id: Runtime UUID.
:param tracer_version: Version of the tracer (e.g., "1.0.0").
:param hostname: Identifier of the machine running the tracer.
:param service_name: Name of the service being instrumented.
:param service_env: Environment of the service being instrumented.
:param service_version: Version of the service being instrumented.
:param process_tags: Process tags of the application being instrumented.
:param container_id: Container id seen by the application.
"""
...
class PyAnonymousFileHandle:
"""
Represents an anonymous file handle.
On Linux, it uses `memfd` (memory file descriptors) to create temporary files in memory.
"""
def __init__(self): ...
def store_metadata(data: PyTracerMetadata) -> PyAnonymousFileHandle:
"""
Create an anonymous file storing the tracer configuration.
:param data: The tracer configuration to store.
"""
...
if sys.platform == "linux":
def update_otel_thread_context(span: SpanData, local_root: Optional[SpanData], trace_flags: int) -> None:
"""
Update the OTel thread context from the active span and its local root span.
:param span: The active span.
:param local_root: The root span of the local trace chunk.
:param trace_flags: W3C Trace Context trace-flags byte (bit 0 = sampled).
"""
...
def detach_otel_thread_context() -> None:
"""Detach the OTel thread context from the current thread."""
...
class SharedRuntime:
"""
SharedRuntime manages a shared Tokio async runtime used by TraceExporter instances.
It provides fork-safety hooks to pause and resume the runtime around process forks.
"""
def __init__(self) -> None: ...
def before_fork(self) -> None:
"""Prepare the shared runtime for forking. Call this before os.fork()."""
...
def after_fork_parent(self) -> None:
"""Resume the shared runtime in the parent process after forking."""
...
def after_fork_child(self) -> None:
"""Re-initialize the shared runtime in the child process after forking."""
...
def shutdown(self, timeout_ms: Optional[int] = None) -> None:
"""Gracefully shut down the shared runtime.
Args:
timeout_ms: Maximum time in milliseconds to wait for shutdown.
If None, waits indefinitely.
"""
...
def shutdown_in_thread(self, timeout_ms: Optional[int] = None) -> None:
"""Gracefully shut down the shared runtime.
The code is run in a separate thread to bypass a stale thread local storage.
Args:
timeout_ms: Maximum time in milliseconds to wait for shutdown.
If None, waits indefinitely.
"""
...
def debug(self) -> str:
"""Returns a string representation of the runtime. Should only be used for debugging."""
...
class TelemetryWorker:
"""Native instrumentation-telemetry worker.
Wraps a ``Full``-flavor telemetry worker spawned on the shared
:class:`SharedRuntime`. The worker runs on the
shared runtime (no dedicated Python thread) and is reset on fork by the
runtime's fork hooks, preserving root-only app-started/app-closing.
All constructor parameters after ``runtime`` are keyword-only.
"""
def __new__(
cls,
runtime: SharedRuntime,
*,
service: str,
env: Optional[str],
app_version: Optional[str],
language_name: str,
language_version: str,
tracer_version: str,
runtime_id: str,
runtime_name: Optional[str],
runtime_version: Optional[str],
process_tags: Optional[str],
hostname: str,
os: Optional[str],
os_version: Optional[str],
architecture: Optional[str],
kernel_name: Optional[str],
kernel_release: Optional[str],
kernel_version: Optional[str],
container_id: Optional[str],
endpoint_url: str,
api_key: Optional[str],
session_id: str,
parent_session_id: Optional[str],
root_session_id: Optional[str],
heartbeat_interval_secs: float,
extended_heartbeat_interval_secs: float,
debug_enabled: bool,
emit_app_lifecycle: bool = ...,
endpoints_message_limit: int = ...,
test_session_token: Optional[str] = ...,
install_id: Optional[str] = ...,
install_type: Optional[str] = ...,
install_time: Optional[str] = ...,
) -> "TelemetryWorker":
"""Build and spawn the worker on ``runtime``.
:param endpoint_url: BASE url. Agent: e.g. ``"http://host:8126"`` (the
``/telemetry/proxy/api/v2/apmtelemetry`` path is appended). Agentless:
the intake base url (the ``/api/v2/apmtelemetry`` path is appended).
:param api_key: when not ``None`` selects agentless/direct submission
(sets ``dd-api-key`` and the direct path); when ``None`` the worker
POSTs through the agent proxy.
:param emit_app_lifecycle: when ``False`` (forked children) ``start()``
schedules heartbeats/flushes but emits neither ``app-started`` nor
``app-closing`` — only the root process emits them. Defaults to ``True``.
:param endpoints_message_limit: most endpoints serialized into one
``app-endpoints`` payload; the rest stay queued for the following payloads,
which are flagged ``is_first: false``. Defaults to unlimited.
:raises ValueError: on an invalid endpoint or if the worker cannot be spawned.
"""
...
def start(self) -> None:
"""Send the app-started lifecycle event. Call ONCE, on the origin process only."""
...
def stop(self, send_app_closing: bool) -> None:
"""Flush and shut the worker down, waiting briefly for it to drain.
:param send_app_closing: when ``True`` emit the app-closing event
(origin only); when ``False`` just force a final data flush.
"""
...
def flush(self) -> None:
"""Force a data flush. Does not emit any lifecycle event. Non-blocking."""
...
def add_configuration(
self, name: str, value: Optional[str], origin: "ConfigurationOrigin", config_id: Optional[str], seq_id: int
) -> None:
"""Queue a configuration change.
:param origin: a :class:`ConfigurationOrigin` (e.g. ``ConfigurationOrigin.env_var``).
"""
...
def add_integration(
self,
name: str,
version: Optional[str],
enabled: bool,
compatible: Optional[bool],
auto_enabled: Optional[bool],
error: Optional[str] = None,
) -> None:
"""Track a patch/integration outcome (app-integrations-change).
:param error: failure detail when patching failed (None when it succeeded).
"""
...
def add_dependency(
self,
name: str,
version: Optional[str],
metadata: Optional[list[tuple[str, str]]],
) -> None:
"""Report a loaded dependency (app-dependencies-loaded / app-started).
:param metadata: optional SCA metadata as ``(type, value)`` pairs, where ``value``
is an opaque stringified-JSON payload (per the ``dependency_metadata`` telemetry
schema), passed through verbatim. Pass ``None`` to omit the field (SCA disabled),
or ``[]`` to emit an empty array (SCA enabled, no findings).
"""
...
def add_log(
self, identifier: int, message: str, level: "LogLevel", stack_trace: Optional[str], tags: Optional[str]
) -> None:
"""Queue a (pre-formatted, pre-deduped) log.
:param identifier: the Python-computed dedup key (passed through as-is).
:param level: a :class:`LogLevel` (``LogLevel.ERROR``/``WARN``/``DEBUG``).
:param tags: a pre-formatted tag string (e.g. ``"k:v,k2:v2"``) or ``None``.
"""
...
def register_metric_context(
self,
namespace: "MetricNamespace",
name: str,
metric_type: "MetricType",
tags: list[str],
common: bool,
) -> "MetricContext":
"""Register a metric context and return an opaque handle for :meth:`add_point`.
Call ONCE per unique ``(namespace, name, type, tags)`` — the caller caches the
returned handle; registering the same metric twice creates a duplicate context.
The handle is only valid for this worker instance.
:param namespace: a :class:`MetricNamespace`.
:param metric_type: a :class:`MetricType`. ``MetricType.rate`` aggregates
as a count sum; the backend divides by the flush interval.
:param tags: a list of ``"key:value"`` strings.
"""
...
def add_point(self, context: "MetricContext", value: float) -> None:
"""Add ``value`` to a context returned by :meth:`register_metric_context`.
For contexts registered *with* tags. Use :meth:`add_point_with_tags` for untagged
contexts whose tags vary per point.
"""
...
def add_point_with_tags(self, context: "MetricContext", value: float, tags: list[str]) -> None:
"""Add ``value`` to an untagged context with ``tags`` (``"k:v"`` strings) on the point."""
...
def add_product_change(self, product: str, enabled: bool, version: Optional[str]) -> None:
"""Record a product enable/disable change (app-product-change).
:param product: e.g. ``mlobs``, ``dynamic_instrumentation``,
``profiler``, ``appsec`` (any string is accepted as the product name).
"""
...
def add_endpoint(
self,
method: str,
path: str,
operation_name: Optional[str],
resource_name: Optional[str],
request_body_type: Optional[list[str]] = None,
response_body_type: Optional[list[str]] = None,
response_code: Optional[list[int]] = None,
) -> None:
"""Report an instrumented endpoint (ASM app-endpoints).
:param method: HTTP method (unknown methods map to ``"*"``; empty => unset).
:param path: request path; empty => unset.
:param request_body_type: declared request media types (API Security inventory).
:param response_body_type: declared response media types (API Security inventory).
:param response_code: declared response status codes (API Security inventory).
"""
...
class DebuggerTrackType:
"""Which debugger track a payload belongs to. (decides the endpoint)"""
Diagnostics: "DebuggerTrackType"
Snapshots: "DebuggerTrackType"
Logs: "DebuggerTrackType"
def __int__(self) -> int: ...
def __str__(self) -> str: ...
def __eq__(self, other: object) -> bool: ...
def __hash__(self) -> int: ...
def __repr__(self) -> str: ...
class DebuggerResponse:
"""A response from the debugger payload receiver"""
@property
def accepted(self) -> bool:
"""Whether the intake took the payload."""
...
@property
def status(self) -> Optional[int]:
"""The response status, or ``None`` when the payload was accepted."""
...
@property
def body(self) -> str:
"""The response body. Empty unless the payload was rejected."""
...
def __repr__(self) -> str: ...
class DebuggerSenderError(Exception):
"""A payload could not be delivered to the debugger intake (transport failure or timeout)."""
class DebuggerSender:
"""Sender for debugger-related payloads.
Wraps the ``datadog-live-debugger`` sender.
All constructor parameters after ``runtime`` are keyword-only.
"""
def __new__(
cls,
runtime: SharedRuntime,
*,
url: Optional[str] = ...,
site: Optional[str] = ...,
api_key: Optional[str] = ...,
tags: str = ...,
timeout_ms: int = ...,
test_session_token: Optional[str] = ...,
) -> "DebuggerSender":
"""Build a sender on ``runtime``.
:param url: the trace agent URL (``http``, ``https`` or
``unix:///path.sock``) for agent-proxied uploads. Combined with
``api_key`` it becomes a direct intake URL, which is how tests point
agentless mode at a local intake.
:param site: e.g. ``"datadoghq.com"``; with ``api_key`` and no ``url``
the endpoint becomes ``https://debugger-intake.{site}``.
:param api_key: when not ``None`` selects agentless/direct submission
(sets ``dd-api-key`` and the direct path).
:param tags: unencoded ``"key:value,key:value"``, percent-encoded here
for the ``ddtags`` query string.
:raises ValueError: if neither ``url`` nor ``site`` + ``api_key`` is
given, or the resulting endpoint is invalid.
"""
...
@property
def agentless(self) -> bool:
"""Whether payloads go straight to the intake rather than via the agent."""
...
def downgrade_to_diagnostics(self) -> bool:
"""Point the logs and snapshots tracks at the diagnostics endpoint.
For agents that do not proxy ``/debugger/v2/input``. A no-op in agentless
mode, where all three tracks already share one intake path. Returns
whether anything changed.
"""
...
def reset_endpoints(self) -> None:
"""Undo a downgrade, restoring the endpoints derived at construction."""
...
def send(self, payload: bytes, debugger_type: DebuggerTrackType) -> DebuggerResponse:
"""POST a JSON array of payloads (``[{...},{...}]``), blocking on the response.
:raises DebuggerSenderError: if the request never completed (transport
failure or timeout).
"""
...
class SymDBSender:
"""Sender for symbol database (SymDB) uploads.
Reaches Datadog through the same intake host as :class:`DebuggerSender`, but
shares nothing else: the body is forwarded verbatim, the tags travel in
``X-Datadog-Additional-Tags`` rather than a ``ddtags`` query string, and there
is no track negotiation or downgrade.
All constructor parameters after ``runtime`` are keyword-only.
"""
def __new__(
cls,
runtime: SharedRuntime,
*,
url: Optional[str] = ...,
site: Optional[str] = ...,
api_key: Optional[str] = ...,
tags: str = ...,
timeout_ms: int = ...,
test_session_token: Optional[str] = ...,
) -> "SymDBSender":
"""Build a sender on ``runtime``.
``url`` / ``site`` / ``api_key`` select the agent or the intake exactly as
for :class:`DebuggerSender`. ``tags`` is sent verbatim in the
``X-Datadog-Additional-Tags`` header.
:raises ValueError: if neither ``url`` nor ``site`` + ``api_key`` is
given, or the resulting endpoint is invalid.
"""
...
@property
def agentless(self) -> bool:
"""Whether payloads go straight to the intake rather than via the agent."""
...
def send(self, payload: bytes, content_type: str) -> DebuggerResponse:
"""POST a SymDB payload verbatim, blocking on the response.
:param content_type: the caller's multipart content type.
:raises DebuggerSenderError: if the request never completed (transport
failure or timeout).
"""
...
class TraceExporter:
"""
TraceExporter is a class responsible for exporting traces to the Agent.
"""
def set_telemetry_handle(self, worker: Optional["TelemetryWorker"] = None) -> None:
"""
Report the exporter's ``trace_api.*`` health metrics through an existing
instrumentation-telemetry worker instead of a dedicated one.
"""
...
def __init__(self):
"""
Initialize a TraceExporter.
"""
...
def send(self, data: bytes) -> str:
"""
Send a trace payload to the Agent.
:param data: The msgpack encoded trace payload to send.
"""
...
def shutdown(self, timeout_ns: int) -> None:
"""
Shutdown the TraceExporter, releasing any resources and ensuring all pending stats are sent.
This method should be called before the application exits to ensure proper cleanup.
:param timeout_ns: The maximum time to wait for shutdown in nanoseconds.
"""
...
def drop(self) -> None:
"""
Drop the TraceExporter, releasing any resources without sending pending stats.
"""
...
def debug(self) -> str:
"""
Returns a string representation of the exporter.
Should only be used for debugging.
"""
...
class TraceExporterBuilder:
"""
TraceExporterBuilder is a class responsible for building a TraceExporter.
"""
def __init__(self):
"""
Initialize a TraceExporterBuilder.
"""
...
def set_hostname(self, hostname: str) -> TraceExporterBuilder:
"""
Set the hostname of the TraceExporter.
:param hostname: The hostname to set for the TraceExporter.
"""
...
def set_url(self, url: str) -> TraceExporterBuilder:
"""
Set the agent url of the TraceExporter.
:param url: The URL of the agent to send traces to.
"""
...
def set_dogstatsd_url(self, url: str) -> TraceExporterBuilder:
"""
Set the DogStatsD URL of the TraceExporter.
:param url: The URL of the DogStatsD endpoint.
"""
...
def set_env(self, env: str) -> TraceExporterBuilder:
"""
Set the env of the TraceExporter.
:param env: The environment name (e.g., 'prod', 'staging', 'dev').
"""
...
def set_app_version(self, version: str) -> TraceExporterBuilder:
"""
Set the app version of the TraceExporter.
:param version: The version string of the application.
"""
...
def set_service(self, service: str) -> TraceExporterBuilder:
"""
Set the service name of the TraceExporter.
:param version: The version string of the application.
"""
...
def set_git_commit_sha(self, git_commit_sha: str) -> TraceExporterBuilder:
"""
Set the git commit sha of the TraceExporter.
:param git_commit_sha: The git commit SHA of the current code version.
"""
...
def set_process_tags(self, process_tags: str) -> TraceExporterBuilder:
"""
Set the process tags to be included in the stats payload.
:param process_tags: Comma-separated list of key:value process tags (e.g., "key1:val1,key2:val2").
"""
...
def set_tracer_tags(self, tracer_tags: list[str]) -> TraceExporterBuilder:
"""Set tracer tags on the OTLP metrics resource."""
...
def set_tracer_version(self, version: str) -> TraceExporterBuilder:
"""
Set the tracer version of the TraceExporter.
:param version: The version string of the tracer.
"""
...
def set_language(self, language: str) -> TraceExporterBuilder:
"""
Set the language of the TraceExporter.
:param language: The programming language being traced (e.g., 'python').
"""
...
def set_language_version(self, version: str) -> TraceExporterBuilder:
"""
Set the language version of the TraceExporter.
:param version: The version string of the programming language.
"""
...
def set_language_interpreter(self, interpreter: str) -> TraceExporterBuilder:
"""
Set the language interpreter of the TraceExporter.
:param vendor: The language interpreter.
"""
...
def set_language_interpreter_vendor(self, vendor: str) -> TraceExporterBuilder:
"""
Set the language interpreter vendor of the TraceExporter.
:param vendor: The vendor of the language interpreter.
"""
...
def set_test_session_token(self, token: str) -> TraceExporterBuilder:
"""
Set the test session token for the TraceExporter.
:param token: The test session token to use for authentication.
"""
...
def set_input_format(self, input_format: str) -> TraceExporterBuilder:
"""
Set the input format for the trace data.
:param input_format: The format to use for input traces (supported values are "v0.4" and "v0.5").
:raises ValueError: If input_format is not a supported value.
"""
...
def set_output_format(self, output_format: str) -> TraceExporterBuilder:
"""
Set the output format for the trace data.
:param output_format: The format to use for output traces (supported values are "v0.4" and "v0.5").
:raises ValueError: If output_format is not a supported value.
"""
...
def set_client_computed_top_level(self) -> TraceExporterBuilder:
"""
Set the header indicating the tracer has computed the top-level tag
"""
...
def set_client_computed_stats(self) -> TraceExporterBuilder:
"""
Set the header indicating the tracer has already computed stats.
This should not be used along with `enable_stats`.
The main use is to opt-out trace metrics.
"""
...
def enable_stats(self, bucket_size_ns: int) -> TraceExporterBuilder:
"""
Enable stats computation in the TraceExporter
:param bucket_size_ns: The size of stats bucket in nanoseconds.
"""
def set_additional_metric_tag_keys(self, tag_keys: list[str]) -> TraceExporterBuilder:
"""Set span tag keys included in computed stats."""
...
def enable_client_side_stats_obfuscation(self) -> TraceExporterBuilder:
"""
Obfuscate client side stats buckets in the client instead of in the agent.
"""
...
def enable_telemetry(
self,
heartbeat_ms: int,
runtime_id: str,
debug_enabled: bool,
) -> TraceExporterBuilder:
"""
Emit telemetry in the TraceExporter
:param heartbeat: The flush interval for telemetry metrics in milliseconds.
:param runtime_id: The runtime id to use for telemetry.
:param debug_enabled: Whether to enable debug logging for telemetry.
"""
...
def enable_health_metrics(self) -> TraceExporterBuilder:
"""
Enable health metrics in the TraceExporter
"""
...
def set_otlp_endpoint(self, url: str) -> TraceExporterBuilder:
"""
Set the OTLP HTTP endpoint for trace export (serves both http/json and http/protobuf).
When set, traces are sent to this endpoint instead of the Datadog agent.
The host language is responsible for resolving the endpoint from its own
configuration (e.g. OTEL_EXPORTER_OTLP_TRACES_ENDPOINT).
:param url: The full URL of the OTLP endpoint (e.g. "http://localhost:4318/v1/traces").
"""
...
def set_otlp_protocol(self, protocol: str) -> TraceExporterBuilder:
"""
Select the OTLP export protocol: "http/json" or "http/protobuf".
Any other value raises ValueError.
:param protocol: The OTLP protocol ("http/json" or "http/protobuf").
"""
...
def set_otlp_headers(self, headers: list[tuple[str, str]]) -> TraceExporterBuilder:
"""
Set additional HTTP headers for OTLP trace export requests.
:param headers: A list of (key, value) header pairs.
"""
...
def set_otlp_metrics_endpoint(self, url: str) -> TraceExporterBuilder:
"""
Set the OTLP HTTP/JSON endpoint for trace-metrics export.
When set, client-computed span stats are exported as the traces.span.sdk.metrics.duration
OTLP histogram to this endpoint instead of the Datadog agent /v0.6/stats endpoint.
Requires stats computation to be enabled via enable_stats.
:param url: The full URL of the OTLP metrics endpoint (e.g. "http://localhost:4318/v1/metrics").
"""
...
def set_otlp_metrics_headers(self, headers: list[tuple[str, str]]) -> TraceExporterBuilder:
"""
Set additional HTTP headers for OTLP trace-metrics export requests.
:param headers: A list of (key, value) header pairs.
"""
...
def enable_otel_trace_semantics(self) -> TraceExporterBuilder:
"""
Enable OTel trace semantics, which does not add DD-specific per-span attributes
(e.g. operation.name, resource.name, span.type) to the OTLP payload. Driven by the
DD_TRACE_OTEL_SEMANTICS_ENABLED environment variable.
"""
...
def set_connection_timeout(self, timeout_ms: int) -> TraceExporterBuilder:
"""
Set the connection timeout in milliseconds for trace export requests.
:param timeout_ms: Timeout in milliseconds.
"""
...
def build(self, shared_runtime: SharedRuntime) -> TraceExporter:
"""
Build and return a TraceExporter instance with the configured settings.
This method consumes the builder, so it cannot be used again after calling build.
:param shared_runtime: A SharedRuntime instance to share with this exporter.
:return: A configured TraceExporter instance.
:raises ValueError: If the builder has already been consumed or if required settings are missing.
"""
...
def debug(self) -> str:
"""
Returns a string representation of the exporter.
Should only be used for debugging.
"""
...
class AgentResponse:
"""Sampling-rate response from the Datadog agent after a successful trace export."""
rate_by_service: Mapping[str, float]
def __init__(self, rate_by_service: Mapping[str, float]) -> None: ...
class AgentError(Exception):
"""
Raised when there is an error in agent response processing.
"""
...
class BuilderError(Exception):
"""
Raised when there is an error in the TraceExporterBuilder configuration.
"""
...
class SharedRuntimeError(Exception):
"""
Raised when there is an error in the SharedRuntime lifecycle (fork hooks, shutdown, etc.).
"""
...
class logger:
"""
Native logging module for configuring and managing log output.
"""
@staticmethod
def configure(
output: Literal["stdout", "stderr", "file"] = "stdout",
path: Optional[str] = None,
max_files: Optional[int] = None,
max_size_bytes: Optional[int] = None,
) -> None:
"""
Configure the logger with the specified output destination.
:param output: Output destination ("stdout", "stderr", or "file")
:param path: File path (required if output is "file")
:param max_files: Maximum number of log files to keep (for file output)
:param max_size_bytes: Maximum size of each log file in bytes (for file output)
:raises ValueError: If configuration is invalid
"""
...
@staticmethod
def disable(output: str) -> None:
"""
Disable logging output by type.
:param output: Output type to disable ("file", "stdout", or "stderr")
:raises ValueError: If output type is invalid
"""
...
@staticmethod
def set_log_level(level: str) -> None:
"""
Set the log level for the logger.
:param level: Log level ("trace", "debug", "info", "warning", or "error")
:raises ValueError: If log level is invalid
"""
...
@staticmethod
def log(level: str, message: str) -> None:
"""
Logs messages
:param level: Log level ("trace", "debug", "info", "warn", or "error")
:param message: message to be displayed in the log.
:raises ValueError: If log level is invalid
"""
...
class DeserializationError(Exception):
"""
Raised when there is an error deserializing trace payload.
"""
...
class IoError(Exception):
"""
Raised when there is an I/O error during trace processing.
"""
...
class NetworkError(Exception):
"""
Raised when there is a network-related error during trace processing.
"""
...
class RequestError(Exception):
"""
Raised when the agent responds with an error code.
"""
...
class SerializationError(Exception):
"""
Raised when there is an error serializing trace payload.
"""
...
class ffe:
"""
Native Feature Flags and Experimentation module.
"""
class FlagType(Enum):
String = ...
Integer = ...
Float = ...
Boolean = ...
Object = ...
class Reason(Enum):
Static = ...
Default = ...
TargetingMatch = ...
Split = ...
Cached = ...
Disabled = ...
Unknown = ...
Stale = ...
Error = ...
class ErrorCode(Enum):
TypeMismatch = ...
ParseError = ...
FlagNotFound = ...
TargetingKeyMissing = ...
InvalidContext = ...
ProviderNotReady = ...
General = ...
class ResolutionDetails:
@property
def value(self) -> Optional[Any]: ...
@property
def error_code(self) -> Optional[ffe.ErrorCode]: ...
@property
def error_message(self) -> Optional[str]: ...
@property
def reason(self) -> Optional[ffe.Reason]: ...
@property
def variant(self) -> Optional[str]: ...
@property
def allocation_key(self) -> Optional[str]: ...
@property
def flag_metadata(self) -> dict[str, str]: ...
@property
def do_log(self) -> bool: ...
@property
def serial_id(self) -> Optional[int]: ...
class Configuration:
def __init__(self, config_bytes: bytes) -> None: ...
def resolve_value(self, flag_key: str, expected_type: ffe.FlagType, context: dict) -> ffe.ResolutionDetails: ...
class native_flare:
class ListeningError(Exception): ...
class LockError(Exception): ...
class ParsingError(Exception): ...
class SendError(Exception): ...
class ZipError(Exception): ...
class FlareAction:
def __repr__(self) -> str: ...
def is_send(self) -> bool: ...
def is_set(self) -> bool: ...
def is_unset(self) -> bool: ...
@property
def level(self) -> Optional[str]: ...
@property
def case_id(self) -> Optional[str]: ...
@staticmethod
def none_action() -> native_flare.FlareAction: ...
class TracerFlareManager:
def __init__(self, agent_url: str) -> None: ...
def handle_remote_config_data(self, data: Any, product: str) -> native_flare.FlareAction: ...
def zip_and_send(self, directory: str, send_action: native_flare.FlareAction) -> None: ...
def set_current_log_level(self, level: str) -> None: ...