libdatadog 33.0.0.1.0 → 40.0.0.2.0

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 (115) hide show
  1. checksums.yaml +4 -4
  2. data/lib/libdatadog/version.rb +2 -2
  3. data/libdatadog.gemspec +43 -0
  4. data/rust-toolchain.toml +6 -0
  5. data/tasks/build.rake +36 -2
  6. data/tasks/gem.rake +245 -0
  7. data/tasks/release.rake +28 -0
  8. data/tasks/spec.rake +11 -0
  9. data/vendor/{libdatadog-33.0.0/aarch64-linux-musl/libdatadog-aarch64-alpine-linux-musl → libdatadog-40.0.0/aarch64-linux}/LICENSE-3rdparty.csv +7 -1
  10. data/vendor/libdatadog-40.0.0/aarch64-linux/NOTICE +12 -0
  11. data/vendor/{libdatadog-33.0.0/aarch64-linux/libdatadog-aarch64-unknown-linux-gnu → libdatadog-40.0.0/aarch64-linux}/bin/libdatadog-crashtracking-receiver +0 -0
  12. data/vendor/{libdatadog-33.0.0/x86_64-linux-musl/libdatadog-x86_64-alpine-linux-musl → libdatadog-40.0.0/aarch64-linux}/include/datadog/common.h +321 -81
  13. data/vendor/{libdatadog-33.0.0/arm64-darwin/libdatadog-aarch64-apple-darwin → libdatadog-40.0.0/aarch64-linux}/include/datadog/crashtracker.h +19 -0
  14. data/vendor/libdatadog-40.0.0/aarch64-linux/include/datadog/data-pipeline.h +612 -0
  15. data/vendor/libdatadog-40.0.0/aarch64-linux/include/datadog/otel-thread-ctx.h +86 -0
  16. data/vendor/{libdatadog-33.0.0/aarch64-linux-musl/libdatadog-aarch64-alpine-linux-musl → libdatadog-40.0.0/aarch64-linux}/include/datadog/profiling.h +37 -0
  17. data/vendor/libdatadog-40.0.0/aarch64-linux/include/datadog/shared-runtime.h +91 -0
  18. data/vendor/{libdatadog-33.0.0/x86_64-linux-musl/libdatadog-x86_64-alpine-linux-musl → libdatadog-40.0.0/aarch64-linux}/include/datadog/telemetry.h +37 -19
  19. data/vendor/{libdatadog-33.0.0/aarch64-linux/libdatadog-aarch64-unknown-linux-gnu → libdatadog-40.0.0/aarch64-linux}/lib/libdatadog_profiling.so +0 -0
  20. data/vendor/{libdatadog-33.0.0/aarch64-linux/libdatadog-aarch64-unknown-linux-gnu → libdatadog-40.0.0/aarch64-linux}/lib/pkgconfig/datadog_profiling_with_rpath.pc +1 -1
  21. data/vendor/{libdatadog-33.0.0/aarch64-linux/libdatadog-aarch64-unknown-linux-gnu → libdatadog-40.0.0/aarch64-linux-musl}/LICENSE-3rdparty.csv +7 -1
  22. data/vendor/libdatadog-40.0.0/aarch64-linux-musl/NOTICE +12 -0
  23. data/vendor/{libdatadog-33.0.0/aarch64-linux-musl/libdatadog-aarch64-alpine-linux-musl → libdatadog-40.0.0/aarch64-linux-musl}/bin/libdatadog-crashtracking-receiver +0 -0
  24. data/vendor/{libdatadog-33.0.0/arm64-darwin/libdatadog-aarch64-apple-darwin → libdatadog-40.0.0/aarch64-linux-musl}/include/datadog/common.h +321 -81
  25. data/vendor/{libdatadog-33.0.0/aarch64-linux/libdatadog-aarch64-unknown-linux-gnu → libdatadog-40.0.0/aarch64-linux-musl}/include/datadog/crashtracker.h +19 -0
  26. data/vendor/libdatadog-40.0.0/aarch64-linux-musl/include/datadog/data-pipeline.h +612 -0
  27. data/vendor/libdatadog-40.0.0/aarch64-linux-musl/include/datadog/otel-thread-ctx.h +86 -0
  28. data/vendor/{libdatadog-33.0.0/arm64-darwin/libdatadog-aarch64-apple-darwin → libdatadog-40.0.0/aarch64-linux-musl}/include/datadog/profiling.h +37 -0
  29. data/vendor/libdatadog-40.0.0/aarch64-linux-musl/include/datadog/shared-runtime.h +91 -0
  30. data/vendor/{libdatadog-33.0.0/arm64-darwin/libdatadog-aarch64-apple-darwin → libdatadog-40.0.0/aarch64-linux-musl}/include/datadog/telemetry.h +37 -19
  31. data/vendor/{libdatadog-33.0.0/aarch64-linux-musl/libdatadog-aarch64-alpine-linux-musl → libdatadog-40.0.0/aarch64-linux-musl}/lib/libdatadog_profiling.so +0 -0
  32. data/vendor/{libdatadog-33.0.0/aarch64-linux-musl/libdatadog-aarch64-alpine-linux-musl → libdatadog-40.0.0/aarch64-linux-musl}/lib/pkgconfig/datadog_profiling_with_rpath.pc +1 -1
  33. data/vendor/{libdatadog-33.0.0/arm64-darwin/libdatadog-aarch64-apple-darwin → libdatadog-40.0.0/arm64-darwin}/LICENSE-3rdparty.csv +7 -1
  34. data/vendor/libdatadog-40.0.0/arm64-darwin/NOTICE +12 -0
  35. data/vendor/{libdatadog-33.0.0/arm64-darwin/libdatadog-aarch64-apple-darwin → libdatadog-40.0.0/arm64-darwin}/bin/libdatadog-crashtracking-receiver +0 -0
  36. data/vendor/{libdatadog-33.0.0/aarch64-linux-musl/libdatadog-aarch64-alpine-linux-musl → libdatadog-40.0.0/arm64-darwin}/include/datadog/common.h +321 -81
  37. data/vendor/{libdatadog-33.0.0/aarch64-linux-musl/libdatadog-aarch64-alpine-linux-musl → libdatadog-40.0.0/arm64-darwin}/include/datadog/crashtracker.h +19 -0
  38. data/vendor/libdatadog-40.0.0/arm64-darwin/include/datadog/data-pipeline.h +612 -0
  39. data/vendor/libdatadog-40.0.0/arm64-darwin/include/datadog/otel-thread-ctx.h +86 -0
  40. data/vendor/{libdatadog-33.0.0/aarch64-linux/libdatadog-aarch64-unknown-linux-gnu → libdatadog-40.0.0/arm64-darwin}/include/datadog/profiling.h +37 -0
  41. data/vendor/libdatadog-40.0.0/arm64-darwin/include/datadog/shared-runtime.h +91 -0
  42. data/vendor/{libdatadog-33.0.0/aarch64-linux-musl/libdatadog-aarch64-alpine-linux-musl → libdatadog-40.0.0/arm64-darwin}/include/datadog/telemetry.h +37 -19
  43. data/vendor/{libdatadog-33.0.0/arm64-darwin/libdatadog-aarch64-apple-darwin → libdatadog-40.0.0/arm64-darwin}/lib/libdatadog_profiling.dylib +0 -0
  44. data/vendor/{libdatadog-33.0.0/arm64-darwin/libdatadog-aarch64-apple-darwin → libdatadog-40.0.0/arm64-darwin}/lib/pkgconfig/datadog_profiling_with_rpath.pc +1 -1
  45. data/vendor/libdatadog-40.0.0/x86_64-linux/LICENSE-3rdparty.csv +554 -0
  46. data/vendor/libdatadog-40.0.0/x86_64-linux/NOTICE +12 -0
  47. data/vendor/{libdatadog-33.0.0/x86_64-linux/libdatadog-x86_64-unknown-linux-gnu → libdatadog-40.0.0/x86_64-linux}/bin/libdatadog-crashtracking-receiver +0 -0
  48. data/vendor/libdatadog-40.0.0/x86_64-linux/include/datadog/common.h +3115 -0
  49. data/vendor/libdatadog-40.0.0/x86_64-linux/include/datadog/crashtracker.h +1026 -0
  50. data/vendor/libdatadog-40.0.0/x86_64-linux/include/datadog/data-pipeline.h +612 -0
  51. data/vendor/libdatadog-40.0.0/x86_64-linux/include/datadog/otel-thread-ctx.h +86 -0
  52. data/vendor/libdatadog-40.0.0/x86_64-linux/include/datadog/profiling.h +1167 -0
  53. data/vendor/libdatadog-40.0.0/x86_64-linux/include/datadog/shared-runtime.h +91 -0
  54. data/vendor/libdatadog-40.0.0/x86_64-linux/include/datadog/telemetry.h +325 -0
  55. data/vendor/{libdatadog-33.0.0/x86_64-linux/libdatadog-x86_64-unknown-linux-gnu → libdatadog-40.0.0/x86_64-linux}/lib/libdatadog_profiling.so +0 -0
  56. data/vendor/libdatadog-40.0.0/x86_64-linux/lib/pkgconfig/datadog_profiling_with_rpath.pc +15 -0
  57. data/vendor/{libdatadog-33.0.0/x86_64-linux-musl/libdatadog-x86_64-alpine-linux-musl → libdatadog-40.0.0/x86_64-linux-musl}/LICENSE-3rdparty.csv +7 -1
  58. data/vendor/libdatadog-40.0.0/x86_64-linux-musl/NOTICE +12 -0
  59. data/vendor/{libdatadog-33.0.0/x86_64-linux-musl/libdatadog-x86_64-alpine-linux-musl → libdatadog-40.0.0/x86_64-linux-musl}/bin/libdatadog-crashtracking-receiver +0 -0
  60. data/vendor/{libdatadog-33.0.0/aarch64-linux/libdatadog-aarch64-unknown-linux-gnu → libdatadog-40.0.0/x86_64-linux-musl}/include/datadog/common.h +321 -81
  61. data/vendor/{libdatadog-33.0.0/x86_64-linux-musl/libdatadog-x86_64-alpine-linux-musl → libdatadog-40.0.0/x86_64-linux-musl}/include/datadog/crashtracker.h +19 -0
  62. data/vendor/libdatadog-40.0.0/x86_64-linux-musl/include/datadog/data-pipeline.h +612 -0
  63. data/vendor/libdatadog-40.0.0/x86_64-linux-musl/include/datadog/otel-thread-ctx.h +86 -0
  64. data/vendor/{libdatadog-33.0.0/x86_64-linux-musl/libdatadog-x86_64-alpine-linux-musl → libdatadog-40.0.0/x86_64-linux-musl}/include/datadog/profiling.h +37 -0
  65. data/vendor/libdatadog-40.0.0/x86_64-linux-musl/include/datadog/shared-runtime.h +91 -0
  66. data/vendor/{libdatadog-33.0.0/aarch64-linux/libdatadog-aarch64-unknown-linux-gnu → libdatadog-40.0.0/x86_64-linux-musl}/include/datadog/telemetry.h +37 -19
  67. data/vendor/{libdatadog-33.0.0/x86_64-linux-musl/libdatadog-x86_64-alpine-linux-musl → libdatadog-40.0.0/x86_64-linux-musl}/lib/libdatadog_profiling.so +0 -0
  68. data/vendor/{libdatadog-33.0.0/x86_64-linux-musl/libdatadog-x86_64-alpine-linux-musl → libdatadog-40.0.0/x86_64-linux-musl}/lib/pkgconfig/datadog_profiling_with_rpath.pc +1 -1
  69. metadata +97 -82
  70. data/vendor/libdatadog-33.0.0/aarch64-linux/libdatadog-aarch64-unknown-linux-gnu/NOTICE +0 -4
  71. data/vendor/libdatadog-33.0.0/aarch64-linux/libdatadog-aarch64-unknown-linux-gnu/include/datadog/data-pipeline.h +0 -216
  72. data/vendor/libdatadog-33.0.0/aarch64-linux-musl/libdatadog-aarch64-alpine-linux-musl/NOTICE +0 -4
  73. data/vendor/libdatadog-33.0.0/aarch64-linux-musl/libdatadog-aarch64-alpine-linux-musl/include/datadog/data-pipeline.h +0 -216
  74. data/vendor/libdatadog-33.0.0/arm64-darwin/libdatadog-aarch64-apple-darwin/NOTICE +0 -4
  75. data/vendor/libdatadog-33.0.0/arm64-darwin/libdatadog-aarch64-apple-darwin/include/datadog/data-pipeline.h +0 -216
  76. data/vendor/libdatadog-33.0.0/x86_64-linux/libdatadog-x86_64-unknown-linux-gnu/LICENSE-3rdparty.csv +0 -548
  77. data/vendor/libdatadog-33.0.0/x86_64-linux/libdatadog-x86_64-unknown-linux-gnu/NOTICE +0 -4
  78. data/vendor/libdatadog-33.0.0/x86_64-linux/libdatadog-x86_64-unknown-linux-gnu/include/datadog/common.h +0 -2875
  79. data/vendor/libdatadog-33.0.0/x86_64-linux/libdatadog-x86_64-unknown-linux-gnu/include/datadog/crashtracker.h +0 -1007
  80. data/vendor/libdatadog-33.0.0/x86_64-linux/libdatadog-x86_64-unknown-linux-gnu/include/datadog/data-pipeline.h +0 -216
  81. data/vendor/libdatadog-33.0.0/x86_64-linux/libdatadog-x86_64-unknown-linux-gnu/include/datadog/profiling.h +0 -1130
  82. data/vendor/libdatadog-33.0.0/x86_64-linux/libdatadog-x86_64-unknown-linux-gnu/include/datadog/telemetry.h +0 -307
  83. data/vendor/libdatadog-33.0.0/x86_64-linux/libdatadog-x86_64-unknown-linux-gnu/lib/pkgconfig/datadog_profiling_with_rpath.pc +0 -15
  84. data/vendor/libdatadog-33.0.0/x86_64-linux-musl/libdatadog-x86_64-alpine-linux-musl/NOTICE +0 -4
  85. data/vendor/libdatadog-33.0.0/x86_64-linux-musl/libdatadog-x86_64-alpine-linux-musl/include/datadog/data-pipeline.h +0 -216
  86. /data/vendor/{libdatadog-33.0.0/aarch64-linux/libdatadog-aarch64-unknown-linux-gnu → libdatadog-40.0.0/aarch64-linux}/LICENSE +0 -0
  87. /data/vendor/{libdatadog-33.0.0/aarch64-linux/libdatadog-aarch64-unknown-linux-gnu → libdatadog-40.0.0/aarch64-linux}/include/datadog/blazesym.h +0 -0
  88. /data/vendor/{libdatadog-33.0.0/aarch64-linux/libdatadog-aarch64-unknown-linux-gnu → libdatadog-40.0.0/aarch64-linux}/include/datadog/ddsketch.h +0 -0
  89. /data/vendor/{libdatadog-33.0.0/aarch64-linux/libdatadog-aarch64-unknown-linux-gnu → libdatadog-40.0.0/aarch64-linux}/include/datadog/ffe.h +0 -0
  90. /data/vendor/{libdatadog-33.0.0/aarch64-linux/libdatadog-aarch64-unknown-linux-gnu → libdatadog-40.0.0/aarch64-linux}/include/datadog/library-config.h +0 -0
  91. /data/vendor/{libdatadog-33.0.0/aarch64-linux/libdatadog-aarch64-unknown-linux-gnu → libdatadog-40.0.0/aarch64-linux}/include/datadog/log.h +0 -0
  92. /data/vendor/{libdatadog-33.0.0/aarch64-linux-musl/libdatadog-aarch64-alpine-linux-musl → libdatadog-40.0.0/aarch64-linux-musl}/LICENSE +0 -0
  93. /data/vendor/{libdatadog-33.0.0/aarch64-linux-musl/libdatadog-aarch64-alpine-linux-musl → libdatadog-40.0.0/aarch64-linux-musl}/include/datadog/blazesym.h +0 -0
  94. /data/vendor/{libdatadog-33.0.0/aarch64-linux-musl/libdatadog-aarch64-alpine-linux-musl → libdatadog-40.0.0/aarch64-linux-musl}/include/datadog/ddsketch.h +0 -0
  95. /data/vendor/{libdatadog-33.0.0/aarch64-linux-musl/libdatadog-aarch64-alpine-linux-musl → libdatadog-40.0.0/aarch64-linux-musl}/include/datadog/ffe.h +0 -0
  96. /data/vendor/{libdatadog-33.0.0/aarch64-linux-musl/libdatadog-aarch64-alpine-linux-musl → libdatadog-40.0.0/aarch64-linux-musl}/include/datadog/library-config.h +0 -0
  97. /data/vendor/{libdatadog-33.0.0/aarch64-linux-musl/libdatadog-aarch64-alpine-linux-musl → libdatadog-40.0.0/aarch64-linux-musl}/include/datadog/log.h +0 -0
  98. /data/vendor/{libdatadog-33.0.0/arm64-darwin/libdatadog-aarch64-apple-darwin → libdatadog-40.0.0/arm64-darwin}/LICENSE +0 -0
  99. /data/vendor/{libdatadog-33.0.0/arm64-darwin/libdatadog-aarch64-apple-darwin → libdatadog-40.0.0/arm64-darwin}/include/datadog/blazesym.h +0 -0
  100. /data/vendor/{libdatadog-33.0.0/arm64-darwin/libdatadog-aarch64-apple-darwin → libdatadog-40.0.0/arm64-darwin}/include/datadog/ddsketch.h +0 -0
  101. /data/vendor/{libdatadog-33.0.0/arm64-darwin/libdatadog-aarch64-apple-darwin → libdatadog-40.0.0/arm64-darwin}/include/datadog/ffe.h +0 -0
  102. /data/vendor/{libdatadog-33.0.0/arm64-darwin/libdatadog-aarch64-apple-darwin → libdatadog-40.0.0/arm64-darwin}/include/datadog/library-config.h +0 -0
  103. /data/vendor/{libdatadog-33.0.0/arm64-darwin/libdatadog-aarch64-apple-darwin → libdatadog-40.0.0/arm64-darwin}/include/datadog/log.h +0 -0
  104. /data/vendor/{libdatadog-33.0.0/x86_64-linux/libdatadog-x86_64-unknown-linux-gnu → libdatadog-40.0.0/x86_64-linux}/LICENSE +0 -0
  105. /data/vendor/{libdatadog-33.0.0/x86_64-linux/libdatadog-x86_64-unknown-linux-gnu → libdatadog-40.0.0/x86_64-linux}/include/datadog/blazesym.h +0 -0
  106. /data/vendor/{libdatadog-33.0.0/x86_64-linux/libdatadog-x86_64-unknown-linux-gnu → libdatadog-40.0.0/x86_64-linux}/include/datadog/ddsketch.h +0 -0
  107. /data/vendor/{libdatadog-33.0.0/x86_64-linux/libdatadog-x86_64-unknown-linux-gnu → libdatadog-40.0.0/x86_64-linux}/include/datadog/ffe.h +0 -0
  108. /data/vendor/{libdatadog-33.0.0/x86_64-linux/libdatadog-x86_64-unknown-linux-gnu → libdatadog-40.0.0/x86_64-linux}/include/datadog/library-config.h +0 -0
  109. /data/vendor/{libdatadog-33.0.0/x86_64-linux/libdatadog-x86_64-unknown-linux-gnu → libdatadog-40.0.0/x86_64-linux}/include/datadog/log.h +0 -0
  110. /data/vendor/{libdatadog-33.0.0/x86_64-linux-musl/libdatadog-x86_64-alpine-linux-musl → libdatadog-40.0.0/x86_64-linux-musl}/LICENSE +0 -0
  111. /data/vendor/{libdatadog-33.0.0/x86_64-linux-musl/libdatadog-x86_64-alpine-linux-musl → libdatadog-40.0.0/x86_64-linux-musl}/include/datadog/blazesym.h +0 -0
  112. /data/vendor/{libdatadog-33.0.0/x86_64-linux-musl/libdatadog-x86_64-alpine-linux-musl → libdatadog-40.0.0/x86_64-linux-musl}/include/datadog/ddsketch.h +0 -0
  113. /data/vendor/{libdatadog-33.0.0/x86_64-linux-musl/libdatadog-x86_64-alpine-linux-musl → libdatadog-40.0.0/x86_64-linux-musl}/include/datadog/ffe.h +0 -0
  114. /data/vendor/{libdatadog-33.0.0/x86_64-linux-musl/libdatadog-x86_64-alpine-linux-musl → libdatadog-40.0.0/x86_64-linux-musl}/include/datadog/library-config.h +0 -0
  115. /data/vendor/{libdatadog-33.0.0/x86_64-linux-musl/libdatadog-x86_64-alpine-linux-musl → libdatadog-40.0.0/x86_64-linux-musl}/include/datadog/log.h +0 -0
@@ -0,0 +1,612 @@
1
+ // Copyright 2021-Present Datadog, Inc. https://www.datadoghq.com/
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+
5
+ #ifndef DDOG_DATA_PIPELINE_H
6
+ #define DDOG_DATA_PIPELINE_H
7
+
8
+ #include <stdarg.h>
9
+ #include <stdbool.h>
10
+ #include <stdint.h>
11
+ #include <stdlib.h>
12
+ #include "common.h"
13
+ #ifdef __cplusplus
14
+ extern "C" {
15
+ #endif // __cplusplus
16
+
17
+ /**
18
+ * Frees `error` and all its contents. After being called error will not point to a valid memory
19
+ * address so any further actions on it could lead to undefined behavior.
20
+ */
21
+ void ddog_trace_exporter_error_free(struct ddog_TraceExporterError *error);
22
+
23
+ /**
24
+ * Return a borrowed view of the response body. The returned slice is
25
+ * only valid as long as `response` is alive. Returns an empty slice
26
+ * when `response` is null or the body is absent.
27
+ */
28
+ ddog_ByteSlice ddog_trace_exporter_response_get_body(const struct ddog_TraceExporterResponse *response);
29
+
30
+ /**
31
+ * Free `response` and all its contents. After being called response will not point to a valid
32
+ * memory address so any further actions on it could lead to undefined behavior.
33
+ */
34
+ void ddog_trace_exporter_response_free(struct ddog_TraceExporterResponse *response);
35
+
36
+ /**
37
+ * Encode one flat preorder structured value as an owned MessagePack blob.
38
+ *
39
+ * On success, `out_handle` receives an owned blob that must be freed with
40
+ * [`ddog_tracer_encoded_value_free`]. The input is fully validated and must
41
+ * contain exactly one value. Token byte slices are borrowed only for this
42
+ * synchronous call; the returned blob does not retain them.
43
+ *
44
+ * # Safety
45
+ *
46
+ * `tokens` and every byte slice referenced by its tokens must remain valid for
47
+ * this call. `out_handle` must point to writable memory for a
48
+ * `Box<TracerEncodedValue>`.
49
+ */
50
+ struct ddog_TraceExporterError *ddog_tracer_encode_value(struct ddog_Slice_TracerValueToken tokens,
51
+ struct ddog_TracerEncodedValue **out_handle);
52
+
53
+ /**
54
+ * Borrow the bytes in an encoded value. The slice is valid until the blob is
55
+ * freed.
56
+ */
57
+ ddog_ByteSlice ddog_tracer_encoded_value_as_slice(const struct ddog_TracerEncodedValue *value);
58
+
59
+ /**
60
+ * Free an encoded structured value and its bytes.
61
+ */
62
+ void ddog_tracer_encoded_value_free(struct ddog_TracerEncodedValue *value);
63
+
64
+ void ddog_trace_exporter_config_new(struct ddog_TraceExporterConfig **out_handle);
65
+
66
+ /**
67
+ * Frees TraceExporterConfig handle internal resources.
68
+ */
69
+ void ddog_trace_exporter_config_free(struct ddog_TraceExporterConfig *handle);
70
+
71
+ /**
72
+ * Sets traces destination.
73
+ */
74
+ struct ddog_TraceExporterError *ddog_trace_exporter_config_set_url(struct ddog_TraceExporterConfig *config,
75
+ ddog_CharSlice url);
76
+
77
+ /**
78
+ * Sets tracer's version to be included in the headers request.
79
+ */
80
+ struct ddog_TraceExporterError *ddog_trace_exporter_config_set_tracer_version(struct ddog_TraceExporterConfig *config,
81
+ ddog_CharSlice version);
82
+
83
+ /**
84
+ * Sets tracer's language to be included in the headers request.
85
+ */
86
+ struct ddog_TraceExporterError *ddog_trace_exporter_config_set_language(struct ddog_TraceExporterConfig *config,
87
+ ddog_CharSlice lang);
88
+
89
+ /**
90
+ * Sets tracer's language version to be included in the headers request.
91
+ */
92
+ struct ddog_TraceExporterError *ddog_trace_exporter_config_set_lang_version(struct ddog_TraceExporterConfig *config,
93
+ ddog_CharSlice version);
94
+
95
+ /**
96
+ * Sets tracer's language interpreter to be included in the headers request.
97
+ */
98
+ struct ddog_TraceExporterError *ddog_trace_exporter_config_set_lang_interpreter(struct ddog_TraceExporterConfig *config,
99
+ ddog_CharSlice interpreter);
100
+
101
+ /**
102
+ * Sets hostname information to be included in the headers request.
103
+ */
104
+ struct ddog_TraceExporterError *ddog_trace_exporter_config_set_hostname(struct ddog_TraceExporterConfig *config,
105
+ ddog_CharSlice hostname);
106
+
107
+ /**
108
+ * Sets environment information to be included in the headers request.
109
+ */
110
+ struct ddog_TraceExporterError *ddog_trace_exporter_config_set_env(struct ddog_TraceExporterConfig *config,
111
+ ddog_CharSlice env);
112
+
113
+ struct ddog_TraceExporterError *ddog_trace_exporter_config_set_version(struct ddog_TraceExporterConfig *config,
114
+ ddog_CharSlice version);
115
+
116
+ /**
117
+ * Sets service name to be included in the headers request.
118
+ */
119
+ struct ddog_TraceExporterError *ddog_trace_exporter_config_set_service(struct ddog_TraceExporterConfig *config,
120
+ ddog_CharSlice service);
121
+
122
+ /**
123
+ * Enables health metrics emission.
124
+ */
125
+ struct ddog_TraceExporterError *ddog_trace_exporter_config_enable_health_metrics(struct ddog_TraceExporterConfig *config,
126
+ bool is_enabled);
127
+
128
+ /**
129
+ * Enables telemetry metrics.
130
+ */
131
+ struct ddog_TraceExporterError *ddog_trace_exporter_config_enable_telemetry(struct ddog_TraceExporterConfig *config,
132
+ const struct ddog_TelemetryClientConfig *telemetry_cfg);
133
+
134
+ /**
135
+ * Set client-side stats computation status.
136
+ */
137
+ struct ddog_TraceExporterError *ddog_trace_exporter_config_set_compute_stats(struct ddog_TraceExporterConfig *config,
138
+ bool is_enabled);
139
+
140
+ /**
141
+ * Sets `Datadog-Client-Computed-Stats` header to `true`.
142
+ * This indicates that the upstream system has already computed the stats,
143
+ * and no further stats computation should be performed.
144
+ *
145
+ * <div class="warning">
146
+ * This method must not be used when `compute_stats` is enabled, as it could
147
+ * result in duplicate stats computation.
148
+ * </div>
149
+ *
150
+ * A common use case is in Application Security Monitoring (ASM) scenarios:
151
+ * when APM is disabled but ASM is enabled, setting this header to `true`
152
+ * ensures that no stats are computed at any level (exporter or agent).
153
+ */
154
+ struct ddog_TraceExporterError *ddog_trace_exporter_config_set_client_computed_stats(struct ddog_TraceExporterConfig *config,
155
+ bool client_computed_stats);
156
+
157
+ /**
158
+ * Sets the process tags to be included in the stats payload.
159
+ */
160
+ struct ddog_TraceExporterError *ddog_trace_exporter_config_set_process_tags(struct ddog_TraceExporterConfig *config,
161
+ ddog_CharSlice process_tags);
162
+
163
+ /**
164
+ * Sets the `X-Datadog-Test-Session-Token` header. Only used for testing with the test agent.
165
+ */
166
+ struct ddog_TraceExporterError *ddog_trace_exporter_config_set_test_session_token(struct ddog_TraceExporterConfig *config,
167
+ ddog_CharSlice token);
168
+
169
+ /**
170
+ * Sets the timeout in ms for all agent's connections.
171
+ */
172
+ struct ddog_TraceExporterError *ddog_trace_exporter_config_set_connection_timeout(struct ddog_TraceExporterConfig *config,
173
+ uint64_t timeout_ms);
174
+
175
+ /**
176
+ * Sets a shared runtime for the TraceExporter to use for background workers.
177
+ *
178
+ * `handle` must have been initialized with [`ddog_shared_runtime_new`].
179
+ *
180
+ * When set, the exporter will use the provided runtime instead of creating its own.
181
+ * This allows multiple exporters (or other components) to share a single runtime.
182
+ * The config holds a clone of the `Arc` (increments the strong count), so the
183
+ * original handle remains valid and must still be freed with
184
+ * [`ddog_shared_runtime_free`].
185
+ */
186
+ struct ddog_TraceExporterError *ddog_trace_exporter_config_set_shared_runtime(struct ddog_TraceExporterConfig *config,
187
+ struct ddog_ForkSafeRuntime *handle);
188
+
189
+ /**
190
+ * Enables OTLP HTTP/JSON export and sets the endpoint URL.
191
+ *
192
+ * When set, traces are sent to this URL in OTLP HTTP/JSON format instead of the Datadog
193
+ * agent. The host language is responsible for resolving the endpoint from its configuration
194
+ * (e.g. `OTEL_EXPORTER_OTLP_TRACES_ENDPOINT`) before calling this function.
195
+ */
196
+ struct ddog_TraceExporterError *ddog_trace_exporter_config_set_otlp_endpoint(struct ddog_TraceExporterConfig *config,
197
+ ddog_CharSlice url);
198
+
199
+ /**
200
+ * Sets the OTLP export protocol. Accepts the OTel-standard values `http/json` (default) or
201
+ * `http/protobuf`; `grpc` is rejected as not yet supported. The host language resolves the value
202
+ * (e.g. from `OTEL_EXPORTER_OTLP_TRACES_PROTOCOL`).
203
+ *
204
+ * Has no effect unless an OTLP endpoint is also configured via
205
+ * `ddog_trace_exporter_config_set_otlp_endpoint`; without one, traces are sent to the
206
+ * Datadog agent and this protocol selection is ignored.
207
+ *
208
+ * Returns `None` on success, `ErrorCode::InvalidArgument` for a null config or an unaccepted
209
+ * value, and `ErrorCode::InvalidInput` for a non-UTF-8 string.
210
+ */
211
+ struct ddog_TraceExporterError *ddog_trace_exporter_config_set_otlp_protocol(struct ddog_TraceExporterConfig *config,
212
+ ddog_CharSlice protocol);
213
+
214
+ /**
215
+ * Sets OTLP trace instrumentation scope metadata.
216
+ *
217
+ * Has no effect unless an OTLP endpoint is also configured via
218
+ * `ddog_trace_exporter_config_set_otlp_endpoint`; without one, traces are sent to the
219
+ * Datadog agent and this scope metadata is ignored.
220
+ */
221
+ struct ddog_TraceExporterError *ddog_trace_exporter_config_set_otlp_instrumentation_scope(struct ddog_TraceExporterConfig *config,
222
+ ddog_CharSlice name,
223
+ ddog_CharSlice version);
224
+
225
+ /**
226
+ * Sets the cardinality limit for client-side stats computation.
227
+ *
228
+ * When the number of distinct stats groups exceeds `limit`, additional groups are
229
+ * aggregated into a sentinel key instead of being tracked individually.
230
+ * This bounds memory usage when the trace population has very high cardinality.
231
+ *
232
+ * Has no effect unless stats computation is enabled via
233
+ * `ddog_trace_exporter_config_set_compute_stats`.
234
+ */
235
+ struct ddog_TraceExporterError *ddog_trace_exporter_config_set_stats_cardinality_limit(struct ddog_TraceExporterConfig *config,
236
+ struct ddog_CardinalityLimitConfig limits);
237
+
238
+ /**
239
+ * Returns a `CardinalityLimitConfig` with default values
240
+ */
241
+ struct ddog_CardinalityLimitConfig ddog_trace_exporter_config_default_stats_cardinality_limit(void);
242
+
243
+ /**
244
+ * Configure the exporter to write traces as newline-delimited JSON to stdout (the Datadog
245
+ * Forwarder "log exporter" path) instead of sending them to a Datadog agent. Used in serverless
246
+ * environments (e.g. AWS Lambda) when no agent is reachable.
247
+ *
248
+ * `max_line_size` overrides the per-line byte cap; pass `0` to use the default (256 KiB, the AWS
249
+ * CloudWatch Logs limit). When enabled, agent-specific behavior (agent-info polling, client-side
250
+ * stats, V1 negotiation) is bypassed.
251
+ *
252
+ * In this mode each span's `meta` is serialized to process stdout (and thus captured by CloudWatch
253
+ * Logs in Lambda); `meta_struct` is excluded because it holds raw msgpack the log intake cannot
254
+ * interpret.
255
+ *
256
+ * Writes are synchronous/blocking on stdout, so this mode targets single-threaded / current-thread
257
+ * serverless runtimes (e.g. AWS Lambda) where a blocking write won't stall a shared async reactor.
258
+ */
259
+ struct ddog_TraceExporterError *ddog_trace_exporter_config_set_output_to_log(struct ddog_TraceExporterConfig *config,
260
+ uintptr_t max_line_size);
261
+
262
+ /**
263
+ * Create a new TraceExporter instance.
264
+ *
265
+ * When an OTLP endpoint is configured via `TraceExporterConfig`, the exporter sends traces to
266
+ * that endpoint in OTLP over HTTP — JSON or protobuf per the configured protocol — instead of
267
+ * to the Datadog agent. The same payload (e.g. MessagePack) is passed to
268
+ * `ddog_trace_exporter_send`; the library decodes and converts it to OTLP when OTLP is enabled.
269
+ *
270
+ * # Arguments
271
+ *
272
+ * * `out_handle` - The handle to write the TraceExporter instance in.
273
+ * * `config` - The configuration used to set up the TraceExporter handle.
274
+ */
275
+ struct ddog_TraceExporterError *ddog_trace_exporter_new(ddog_TraceExporter **out_handle,
276
+ const struct ddog_TraceExporterConfig *config);
277
+
278
+ /**
279
+ * Free the TraceExporter instance.
280
+ *
281
+ * # Arguments
282
+ *
283
+ * * handle - The handle to the TraceExporter instance.
284
+ */
285
+ void ddog_trace_exporter_free(ddog_TraceExporter *handle);
286
+
287
+ /**
288
+ * Send traces to the Datadog Agent.
289
+ *
290
+ * # Arguments
291
+ *
292
+ * * `handle` - The handle to the TraceExporter instance.
293
+ * * `trace` - The traces to send to the Datadog Agent in the input format used to create the
294
+ * TraceExporter. The memory for the trace must be valid for the life of the call to this
295
+ * function.
296
+ * * `trace_count` - The number of traces to send to the Datadog Agent.
297
+ * * `response_out` - Optional handle to store a pointer to the agent response information.
298
+ */
299
+ struct ddog_TraceExporterError *ddog_trace_exporter_send(const ddog_TraceExporter *handle,
300
+ ddog_ByteSlice trace,
301
+ struct ddog_TraceExporterResponse **response_out);
302
+
303
+ /**
304
+ * Create a new span with all scalar fields set.
305
+ *
306
+ * String fields are copied from the provided slices. The `meta`, `metrics` and `meta_struct`
307
+ * maps start empty; use [`ddog_tracer_span_set_meta`], [`ddog_tracer_span_set_metric`] and
308
+ * [`ddog_tracer_span_set_meta_struct_blob`] to populate them.
309
+ *
310
+ * Returns an error if `fields` is null, if any string field is not valid UTF-8, or if any of
311
+ * its slices is malformed.
312
+ *
313
+ * # Safety
314
+ *
315
+ * `out_handle` must point to valid, writable memory for a `Box<TracerSpan>`.
316
+ * All `CharSlice` fields in `fields` must point to valid memory for their
317
+ * stated length.
318
+ */
319
+ struct ddog_TraceExporterError *ddog_tracer_span_new(ddog_TracerSpan **out_handle,
320
+ const struct ddog_TracerSpanFields *fields);
321
+
322
+ /**
323
+ * Free a `TracerSpan` and all its contents.
324
+ *
325
+ * After this call the handle is invalid and must not be reused.
326
+ *
327
+ * # Safety
328
+ *
329
+ * `handle` must have been created by [`ddog_tracer_span_new`] and must not
330
+ * be used after this call.
331
+ */
332
+ void ddog_tracer_span_free(ddog_TracerSpan *handle);
333
+
334
+ /**
335
+ * Add or overwrite a string tag (`meta`) on the span.
336
+ *
337
+ * Both `key` and `value` are copied into the span.
338
+ *
339
+ * Returns an error if `handle` is null, if `key` or `value` is not valid UTF-8, or if either
340
+ * slice is malformed.
341
+ *
342
+ * # Safety
343
+ *
344
+ * `handle` must be a valid pointer to a `TracerSpan`. `key` and `value` must point to valid
345
+ * memory for their stated lengths.
346
+ */
347
+ struct ddog_TraceExporterError *ddog_tracer_span_set_meta(ddog_TracerSpan *handle,
348
+ ddog_CharSlice key,
349
+ ddog_CharSlice value);
350
+
351
+ /**
352
+ * Add or overwrite a numeric tag (`metric`) on the span.
353
+ *
354
+ * The `key` is copied into the span.
355
+ *
356
+ * Returns an error if `handle` is null, if `key` is not valid UTF-8, or if the slice is
357
+ * malformed.
358
+ *
359
+ * # Safety
360
+ *
361
+ * `handle` must be a valid pointer to a `TracerSpan`. `key` must point to valid memory for its
362
+ * stated length.
363
+ */
364
+ struct ddog_TraceExporterError *ddog_tracer_span_set_metric(ddog_TracerSpan *handle,
365
+ ddog_CharSlice key,
366
+ double value);
367
+
368
+ /**
369
+ * Add or overwrite a structured metadata entry (`meta_struct`) on the span.
370
+ *
371
+ * The `key` and opaque binary `value` are copied into the span. The value is
372
+ * not interpreted or validated as MessagePack.
373
+ *
374
+ * Returns an error if `handle` is null, if `key` is not valid UTF-8, or if either slice is
375
+ * malformed.
376
+ *
377
+ * # Safety
378
+ *
379
+ * `handle` must be a valid pointer to a `TracerSpan`. `key` and `value` must point to valid
380
+ * memory for their stated lengths.
381
+ */
382
+ struct ddog_TraceExporterError *ddog_tracer_span_set_meta_struct_blob(ddog_TracerSpan *handle,
383
+ ddog_CharSlice key,
384
+ ddog_ByteSlice value);
385
+
386
+ /**
387
+ * Encode and add or overwrite a structured metadata entry (`meta_struct`) on
388
+ * the span.
389
+ *
390
+ * The `key` is copied into the span. The structured-value tokens are fully
391
+ * validated and encoded directly into the span without exposing an
392
+ * intermediate blob to the caller. The span is unchanged on failure.
393
+ *
394
+ * # Safety
395
+ *
396
+ * `handle` must be a valid pointer to a `TracerSpan`. `key` must point to
397
+ * valid UTF-8 memory. `tokens` and every byte slice referenced by its tokens
398
+ * must remain valid for this call.
399
+ */
400
+ struct ddog_TraceExporterError *ddog_tracer_span_set_meta_struct(ddog_TracerSpan *handle,
401
+ ddog_CharSlice key,
402
+ struct ddog_Slice_TracerValueToken tokens);
403
+
404
+ /**
405
+ * Replace all span links in one atomic operation.
406
+ *
407
+ * The links, attributes, and strings are copied before this function returns.
408
+ * If any slice or string is invalid, the span's existing links are unchanged.
409
+ * Link order is preserved.
410
+ *
411
+ * # Safety
412
+ *
413
+ * `handle` must be a valid pointer to a `TracerSpan`. All slices must point to
414
+ * valid memory for their stated lengths.
415
+ */
416
+ struct ddog_TraceExporterError *ddog_tracer_span_set_links(ddog_TracerSpan *handle,
417
+ struct ddog_Slice_TracerSpanLink links);
418
+
419
+ /**
420
+ * Create an owned span event.
421
+ *
422
+ * The name is copied before this function returns. The event remains detached
423
+ * until consumed by [`ddog_tracer_span_add_event`].
424
+ */
425
+ struct ddog_TraceExporterError *ddog_tracer_span_event_new(ddog_TracerSpanEvent **out_handle,
426
+ ddog_CharSlice name,
427
+ uint64_t time_unix_nano);
428
+
429
+ /**
430
+ * Free a detached span event.
431
+ */
432
+ void ddog_tracer_span_event_free(ddog_TracerSpanEvent *handle);
433
+
434
+ /**
435
+ * Add or overwrite a string event attribute. The key and value are copied.
436
+ */
437
+ struct ddog_TraceExporterError *ddog_tracer_span_event_set_string(ddog_TracerSpanEvent *event,
438
+ ddog_CharSlice key,
439
+ ddog_CharSlice value);
440
+
441
+ /**
442
+ * Add or overwrite a boolean event attribute.
443
+ */
444
+ struct ddog_TraceExporterError *ddog_tracer_span_event_set_bool(ddog_TracerSpanEvent *event,
445
+ ddog_CharSlice key,
446
+ bool value);
447
+
448
+ /**
449
+ * Add or overwrite a signed integer event attribute.
450
+ */
451
+ struct ddog_TraceExporterError *ddog_tracer_span_event_set_int(ddog_TracerSpanEvent *event,
452
+ ddog_CharSlice key,
453
+ int64_t value);
454
+
455
+ /**
456
+ * Add or overwrite a double event attribute.
457
+ */
458
+ struct ddog_TraceExporterError *ddog_tracer_span_event_set_double(ddog_TracerSpanEvent *event,
459
+ ddog_CharSlice key,
460
+ double value);
461
+
462
+ /**
463
+ * Add or overwrite a homogeneous string array event attribute.
464
+ */
465
+ struct ddog_TraceExporterError *ddog_tracer_span_event_set_string_array(ddog_TracerSpanEvent *event,
466
+ ddog_CharSlice key,
467
+ struct ddog_Slice_CharSlice values);
468
+
469
+ /**
470
+ * Add or overwrite a homogeneous boolean array event attribute.
471
+ */
472
+ struct ddog_TraceExporterError *ddog_tracer_span_event_set_bool_array(ddog_TracerSpanEvent *event,
473
+ ddog_CharSlice key,
474
+ struct ddog_Slice_Bool values);
475
+
476
+ /**
477
+ * Add or overwrite a homogeneous signed integer array event attribute.
478
+ */
479
+ struct ddog_TraceExporterError *ddog_tracer_span_event_set_int_array(ddog_TracerSpanEvent *event,
480
+ ddog_CharSlice key,
481
+ struct ddog_Slice_I64 values);
482
+
483
+ /**
484
+ * Add or overwrite a homogeneous double array event attribute.
485
+ */
486
+ struct ddog_TraceExporterError *ddog_tracer_span_event_set_double_array(ddog_TracerSpanEvent *event,
487
+ ddog_CharSlice key,
488
+ struct ddog_Slice_F64 values);
489
+
490
+ /**
491
+ * Atomically attach a completed event to a span, consuming the event.
492
+ *
493
+ * A non-null `event` is always consumed — moved into the span on success, or
494
+ * dropped on any error (a null `span`, or an internal panic). Callers must not
495
+ * use or free the event after this call. On error the span is unchanged.
496
+ */
497
+ struct ddog_TraceExporterError *ddog_tracer_span_add_event(ddog_TracerSpan *span,
498
+ ddog_TracerSpanEvent *event);
499
+
500
+ /**
501
+ * Create a new empty trace chunks container.
502
+ *
503
+ * `capacity` is a hint for the expected number of chunks; pass 0 if
504
+ * unknown.
505
+ *
506
+ * # Safety
507
+ *
508
+ * `out_handle` must point to valid, writable memory for a
509
+ * `Box<TracerTraceChunks>`.
510
+ */
511
+ struct ddog_TraceExporterError *ddog_tracer_trace_chunks_new(uintptr_t capacity,
512
+ ddog_TracerTraceChunks **out_handle);
513
+
514
+ /**
515
+ * Free a trace chunks container and all its contents.
516
+ *
517
+ * After this call the handle is invalid and must not be reused.
518
+ *
519
+ * # Safety
520
+ *
521
+ * `handle` must have been created by [`ddog_tracer_trace_chunks_new`].
522
+ */
523
+ void ddog_tracer_trace_chunks_free(ddog_TracerTraceChunks *handle);
524
+
525
+ /**
526
+ * Start a new chunk (trace) inside the container.
527
+ *
528
+ * Subsequent [`ddog_tracer_trace_chunks_push_span`] calls will append
529
+ * spans to this chunk until the next `begin_chunk` call.
530
+ *
531
+ * `capacity` is a hint for the expected number of spans in this chunk;
532
+ * pass 0 if unknown.
533
+ *
534
+ * # Safety
535
+ *
536
+ * `handle` must be a valid pointer to a `TracerTraceChunks`.
537
+ */
538
+ struct ddog_TraceExporterError *ddog_tracer_trace_chunks_begin_chunk(ddog_TracerTraceChunks *handle,
539
+ uintptr_t capacity);
540
+
541
+ /**
542
+ * Move a span into the current (last) chunk, consuming the span handle.
543
+ *
544
+ * A chunk must have been started with
545
+ * [`ddog_tracer_trace_chunks_begin_chunk`] before calling this function.
546
+ *
547
+ * # Safety
548
+ *
549
+ * * `handle` must be a valid pointer to a `TracerTraceChunks`.
550
+ * * `span` is consumed and must not be used after this call.
551
+ */
552
+ struct ddog_TraceExporterError *ddog_tracer_trace_chunks_push_span(ddog_TracerTraceChunks *handle,
553
+ ddog_TracerSpan *span);
554
+
555
+ /**
556
+ * Create a new cancellation token.
557
+ *
558
+ * The returned token must be freed with
559
+ * [`ddog_trace_exporter_cancel_token_drop`].
560
+ */
561
+ ddog_TraceExporterCancelToken *ddog_trace_exporter_cancel_token_new(void);
562
+
563
+ /**
564
+ * Cancel a cancellation token.
565
+ *
566
+ * All clones of the same token observe the cancellation. Cancellation is cooperative and only
567
+ * affects a [`ddog_trace_exporter_send_trace_chunks`] call that is in flight: that send stops
568
+ * waiting for the agent at its next await point and fails with
569
+ * [`ExporterErrorCode::IoError`], and the chunks it was sending may be lost.
570
+ *
571
+ * Cancelling while no send is using the token has no immediate effect. A send started later with
572
+ * an already-cancelled token fails the same way without contacting the agent, and cancelling
573
+ * after a send has finished does nothing.
574
+ */
575
+ void ddog_trace_exporter_cancel_token_cancel(const ddog_TraceExporterCancelToken *token);
576
+
577
+ /**
578
+ * Free a cancellation token.
579
+ *
580
+ * After this call the token is invalid and must not be reused.
581
+ */
582
+ void ddog_trace_exporter_cancel_token_drop(ddog_TraceExporterCancelToken *token);
583
+
584
+ /**
585
+ * Send trace chunks through a [`TraceExporter`], consuming the chunks.
586
+ *
587
+ * Computes stats, serializes in the configured output format, and sends to the agent with
588
+ * retries.
589
+ *
590
+ * When `cancel` is non-null, cancelling that token aborts the in-flight request; see
591
+ * [`ddog_trace_exporter_cancel_token_cancel`].
592
+ *
593
+ * On success, if `response_out` is non-null, a heap-allocated
594
+ * [`ExporterResponse`] is written there. The caller owns it and must
595
+ * free it with `ddog_trace_exporter_response_free`.
596
+ *
597
+ * # Safety
598
+ *
599
+ * * `chunks` is consumed and must not be used after this call.
600
+ * * If `response_out` is non-null it must point to valid writable memory for a
601
+ * `Box<ExporterResponse>`.
602
+ */
603
+ struct ddog_TraceExporterError *ddog_trace_exporter_send_trace_chunks(const ddog_TraceExporter *exporter,
604
+ ddog_TracerTraceChunks *chunks,
605
+ struct ddog_TraceExporterResponse **response_out,
606
+ const ddog_TraceExporterCancelToken *cancel);
607
+
608
+ #ifdef __cplusplus
609
+ } // extern "C"
610
+ #endif // __cplusplus
611
+
612
+ #endif /* DDOG_DATA_PIPELINE_H */
@@ -0,0 +1,86 @@
1
+ // Copyright 2026-Present Datadog, Inc. https://www.datadoghq.com/
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+
5
+ #ifndef DDOG_OTEL_THREAD_CTX_H
6
+ #define DDOG_OTEL_THREAD_CTX_H
7
+
8
+ #pragma once
9
+
10
+ #include <stdbool.h>
11
+ #include <stddef.h>
12
+ #include <stdint.h>
13
+
14
+ #ifdef __cplusplus
15
+ extern "C" {
16
+ #endif // __cplusplus
17
+
18
+ #if defined(DDOG_OTEL_THREAD_CTX_SANITY_CHECK)
19
+ /**
20
+ * Verify that this binary was linked with the correct options such that the thread contexts are
21
+ * visible to an external reader (typically the eBPF profiler).
22
+ *
23
+ * Returns `VoidResult::Ok` if all checks pass, or a `VoidResult::Err` with a
24
+ * diagnostic message on failure.
25
+ */
26
+ struct ddog_VoidResult ddog_otel_thread_ctx_sanity_check(void);
27
+ #endif
28
+
29
+ /**
30
+ * Allocate and initialise a new thread context, including its W3C trace-flags byte.
31
+ *
32
+ * Returns a non-null owned handle that must eventually be released with
33
+ * `ddog_otel_thread_ctx_free`.
34
+ */
35
+ struct ddog_ThreadContextHandle *ddog_otel_thread_ctx_new(const uint8_t (*trace_id)[16],
36
+ const uint8_t (*span_id)[8],
37
+ uint8_t trace_flags,
38
+ const uint8_t (*local_root_span_id)[8]);
39
+
40
+ /**
41
+ * Free an owned thread context.
42
+ *
43
+ * # Safety
44
+ *
45
+ * `ctx` must be a valid non-null pointer obtained from `ddog_otel_thread_ctx_new` or
46
+ * `ddog_otel_thread_ctx_detach`, and must not be used after this call. In particular, `ctx`
47
+ * must not be currently attached to a thread.
48
+ */
49
+ void ddog_otel_thread_ctx_free(struct ddog_ThreadContextHandle *ctx);
50
+
51
+ /**
52
+ * Attach `ctx` to the current thread. Returns the previously attached context if any, or null
53
+ * otherwise.
54
+ *
55
+ * # Safety
56
+ *
57
+ * `ctx` must be a valid non-null pointer obtained from this API. Ownership of `ctx` is
58
+ * transferred to the TLS slot: the caller must not drop `ctx` while it is still actively
59
+ * attached.
60
+ */
61
+ struct ddog_ThreadContextHandle *ddog_otel_thread_ctx_attach(struct ddog_ThreadContextHandle *ctx);
62
+
63
+ /**
64
+ * Remove the currently attached context from the TLS slot.
65
+ *
66
+ * Returns the detached context (caller now owns it and must release it with
67
+ * `ddog_otel_thread_ctx_free`), or null if the slot was empty.
68
+ */
69
+ struct ddog_ThreadContextHandle *ddog_otel_thread_ctx_detach(void);
70
+
71
+ /**
72
+ * Update the currently attached context in-place, including its W3C trace-flags byte.
73
+ *
74
+ * If no context is currently attached, one is created and attached, equivalent to calling
75
+ * `ddog_otel_thread_ctx_new` followed by `ddog_otel_thread_ctx_attach`.
76
+ */
77
+ void ddog_otel_thread_ctx_update(const uint8_t (*trace_id)[16],
78
+ const uint8_t (*span_id)[8],
79
+ uint8_t trace_flags,
80
+ const uint8_t (*local_root_span_id)[8]);
81
+
82
+ #ifdef __cplusplus
83
+ } // extern "C"
84
+ #endif // __cplusplus
85
+
86
+ #endif /* DDOG_OTEL_THREAD_CTX_H */