dd-trace 5.97.0 → 5.99.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 (175) hide show
  1. package/LICENSE-3rdparty.csv +0 -1
  2. package/ext/tags.js +1 -0
  3. package/index.d.ts +35 -3
  4. package/package.json +48 -46
  5. package/packages/datadog-instrumentations/src/crypto.js +45 -0
  6. package/packages/datadog-instrumentations/src/cucumber.js +65 -3
  7. package/packages/datadog-instrumentations/src/cypress-config.js +153 -53
  8. package/packages/datadog-instrumentations/src/dns.js +24 -56
  9. package/packages/datadog-instrumentations/src/graphql.js +1 -1
  10. package/packages/datadog-instrumentations/src/helpers/callback-instrumentor.js +74 -0
  11. package/packages/datadog-instrumentations/src/helpers/check-require-cache.js +4 -1
  12. package/packages/datadog-instrumentations/src/helpers/hooks.js +2 -0
  13. package/packages/datadog-instrumentations/src/helpers/rewriter/compiler.js +10 -3
  14. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/index.js +1 -0
  15. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/modelcontextprotocol-sdk.js +59 -0
  16. package/packages/datadog-instrumentations/src/helpers/rewriter/transforms.js +11 -2
  17. package/packages/datadog-instrumentations/src/jest.js +104 -12
  18. package/packages/datadog-instrumentations/src/mocha/utils.js +8 -0
  19. package/packages/datadog-instrumentations/src/modelcontextprotocol-sdk.js +7 -0
  20. package/packages/datadog-instrumentations/src/pino.js +4 -28
  21. package/packages/datadog-instrumentations/src/playwright-browser-scripts.js +27 -0
  22. package/packages/datadog-instrumentations/src/playwright.js +5 -17
  23. package/packages/datadog-instrumentations/src/redis.js +12 -6
  24. package/packages/datadog-instrumentations/src/stripe.js +38 -24
  25. package/packages/datadog-instrumentations/src/vitest.js +32 -4
  26. package/packages/datadog-instrumentations/src/zlib.js +29 -0
  27. package/packages/datadog-plugin-aws-sdk/src/base.js +2 -3
  28. package/packages/datadog-plugin-aws-sdk/src/services/dynamodb.js +1 -0
  29. package/packages/datadog-plugin-aws-sdk/src/services/eventbridge.js +1 -0
  30. package/packages/datadog-plugin-aws-sdk/src/services/kinesis.js +1 -0
  31. package/packages/datadog-plugin-aws-sdk/src/services/redshift.js +1 -0
  32. package/packages/datadog-plugin-aws-sdk/src/services/sns.js +1 -0
  33. package/packages/datadog-plugin-aws-sdk/src/services/sqs.js +1 -0
  34. package/packages/datadog-plugin-azure-event-hubs/src/producer.js +8 -15
  35. package/packages/datadog-plugin-azure-service-bus/src/producer.js +4 -9
  36. package/packages/datadog-plugin-cucumber/src/index.js +8 -2
  37. package/packages/datadog-plugin-cypress/src/cypress-plugin.js +114 -6
  38. package/packages/datadog-plugin-cypress/src/index.js +59 -2
  39. package/packages/datadog-plugin-cypress/src/source-map-utils.js +48 -1
  40. package/packages/datadog-plugin-fs/src/index.js +1 -1
  41. package/packages/datadog-plugin-google-cloud-pubsub/src/consumer.js +2 -1
  42. package/packages/datadog-plugin-google-cloud-pubsub/src/pubsub-push-subscription.js +2 -7
  43. package/packages/datadog-plugin-http/src/client.js +1 -1
  44. package/packages/datadog-plugin-http/src/server.js +21 -13
  45. package/packages/datadog-plugin-http2/src/client.js +1 -1
  46. package/packages/datadog-plugin-http2/src/server.js +10 -2
  47. package/packages/datadog-plugin-jest/src/index.js +2 -2
  48. package/packages/datadog-plugin-mocha/src/index.js +1 -2
  49. package/packages/datadog-plugin-modelcontextprotocol-sdk/src/index.js +24 -0
  50. package/packages/datadog-plugin-modelcontextprotocol-sdk/src/tracing.js +55 -0
  51. package/packages/datadog-plugin-mongodb-core/src/index.js +4 -9
  52. package/packages/datadog-plugin-mysql/src/index.js +1 -1
  53. package/packages/datadog-plugin-next/src/index.js +8 -2
  54. package/packages/datadog-plugin-pg/src/index.js +1 -1
  55. package/packages/datadog-plugin-playwright/src/index.js +2 -3
  56. package/packages/datadog-plugin-tedious/src/index.js +1 -1
  57. package/packages/datadog-plugin-vitest/src/index.js +14 -6
  58. package/packages/datadog-plugin-ws/src/close.js +3 -1
  59. package/packages/datadog-plugin-ws/src/producer.js +2 -0
  60. package/packages/datadog-plugin-ws/src/receiver.js +2 -1
  61. package/packages/dd-trace/src/aiguard/channels.js +8 -0
  62. package/packages/dd-trace/src/aiguard/index.js +7 -3
  63. package/packages/dd-trace/src/aiguard/sdk.js +66 -22
  64. package/packages/dd-trace/src/aiguard/tags.js +1 -0
  65. package/packages/dd-trace/src/appsec/blocked_templates.js +4 -3
  66. package/packages/dd-trace/src/appsec/blocking.js +62 -34
  67. package/packages/dd-trace/src/appsec/graphql.js +6 -6
  68. package/packages/dd-trace/src/appsec/index.js +9 -11
  69. package/packages/dd-trace/src/appsec/rasp/command_injection.js +4 -5
  70. package/packages/dd-trace/src/appsec/rasp/lfi.js +8 -4
  71. package/packages/dd-trace/src/appsec/rasp/sql_injection.js +5 -10
  72. package/packages/dd-trace/src/appsec/rasp/ssrf.js +5 -6
  73. package/packages/dd-trace/src/appsec/recommended.json +2438 -13
  74. package/packages/dd-trace/src/appsec/reporter.js +6 -5
  75. package/packages/dd-trace/src/appsec/sdk/set_user.js +1 -1
  76. package/packages/dd-trace/src/appsec/sdk/track_event.js +5 -5
  77. package/packages/dd-trace/src/appsec/sdk/user_blocking.js +6 -10
  78. package/packages/dd-trace/src/appsec/sdk/utils.js +4 -2
  79. package/packages/dd-trace/src/appsec/store.js +50 -0
  80. package/packages/dd-trace/src/appsec/waf/index.js +3 -5
  81. package/packages/dd-trace/src/ci-visibility/early-flake-detection/get-known-tests.js +2 -2
  82. package/packages/dd-trace/src/ci-visibility/exporters/agentless/coverage-writer.js +2 -2
  83. package/packages/dd-trace/src/ci-visibility/exporters/agentless/di-logs-writer.js +2 -2
  84. package/packages/dd-trace/src/ci-visibility/exporters/agentless/writer.js +2 -2
  85. package/packages/dd-trace/src/ci-visibility/exporters/git/git_metadata.js +3 -4
  86. package/packages/dd-trace/src/ci-visibility/intelligent-test-runner/get-skippable-suites.js +2 -2
  87. package/packages/dd-trace/src/ci-visibility/log-submission/log-submission-plugin.js +4 -5
  88. package/packages/dd-trace/src/ci-visibility/requests/fs-cache.js +3 -4
  89. package/packages/dd-trace/src/ci-visibility/requests/get-library-configuration.js +6 -6
  90. package/packages/dd-trace/src/ci-visibility/requests/upload-coverage-report.js +2 -2
  91. package/packages/dd-trace/src/ci-visibility/test-management/get-test-management-tests.js +2 -2
  92. package/packages/dd-trace/src/config/config-types.d.ts +0 -4
  93. package/packages/dd-trace/src/config/defaults.js +10 -11
  94. package/packages/dd-trace/src/config/generated-config-types.d.ts +14 -8
  95. package/packages/dd-trace/src/config/index.js +49 -32
  96. package/packages/dd-trace/src/config/parsers.js +26 -9
  97. package/packages/dd-trace/src/config/supported-configurations.json +86 -33
  98. package/packages/dd-trace/src/constants.js +1 -0
  99. package/packages/dd-trace/src/debugger/config.js +2 -0
  100. package/packages/dd-trace/src/debugger/devtools_client/send.js +25 -5
  101. package/packages/dd-trace/src/debugger/devtools_client/snapshot/processor.js +5 -2
  102. package/packages/dd-trace/src/encode/0.4.js +11 -11
  103. package/packages/dd-trace/src/encode/span-stats.js +4 -1
  104. package/packages/dd-trace/src/exporters/agent/index.js +0 -1
  105. package/packages/dd-trace/src/exporters/agent/writer.js +1 -2
  106. package/packages/dd-trace/src/exporters/agentless/writer.js +3 -3
  107. package/packages/dd-trace/src/exporters/common/util.js +2 -2
  108. package/packages/dd-trace/src/id.js +2 -0
  109. package/packages/dd-trace/src/index.js +2 -5
  110. package/packages/dd-trace/src/lambda/handler.js +1 -3
  111. package/packages/dd-trace/src/llmobs/plugins/{anthropic.js → anthropic/index.js} +5 -63
  112. package/packages/dd-trace/src/llmobs/plugins/anthropic/util.js +106 -0
  113. package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/chain.js +3 -2
  114. package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/chat_model.js +3 -2
  115. package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/embedding.js +2 -1
  116. package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/index.js +0 -49
  117. package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/vectorstore.js +2 -1
  118. package/packages/dd-trace/src/llmobs/plugins/langchain/messages.js +76 -0
  119. package/packages/dd-trace/src/llmobs/plugins/langgraph/index.js +1 -26
  120. package/packages/dd-trace/src/llmobs/plugins/modelcontextprotocol-sdk/index.js +68 -0
  121. package/packages/dd-trace/src/llmobs/plugins/modelcontextprotocol-sdk/utils.js +57 -0
  122. package/packages/dd-trace/src/llmobs/sdk.js +2 -2
  123. package/packages/dd-trace/src/log/index.js +0 -10
  124. package/packages/dd-trace/src/openfeature/eval-metrics-hook.js +103 -0
  125. package/packages/dd-trace/src/openfeature/flagging_provider.js +3 -0
  126. package/packages/dd-trace/src/openfeature/remote_config.js +6 -1
  127. package/packages/dd-trace/src/opentelemetry/context_manager.js +6 -4
  128. package/packages/dd-trace/src/opentelemetry/logs/index.js +1 -1
  129. package/packages/dd-trace/src/opentelemetry/logs/otlp_http_log_exporter.js +3 -2
  130. package/packages/dd-trace/src/opentelemetry/metrics/index.js +1 -1
  131. package/packages/dd-trace/src/opentelemetry/metrics/otlp_http_metric_exporter.js +3 -2
  132. package/packages/dd-trace/src/opentelemetry/otlp/otlp_http_exporter_base.js +19 -51
  133. package/packages/dd-trace/src/opentelemetry/otlp/protobuf_loader.js +14 -2
  134. package/packages/dd-trace/src/opentelemetry/otlp/trace.proto +358 -0
  135. package/packages/dd-trace/src/opentelemetry/otlp/trace_service.proto +78 -0
  136. package/packages/dd-trace/src/opentelemetry/trace/index.js +70 -0
  137. package/packages/dd-trace/src/opentelemetry/trace/otlp_http_trace_exporter.js +74 -0
  138. package/packages/dd-trace/src/opentelemetry/trace/otlp_transformer.js +342 -0
  139. package/packages/dd-trace/src/opentelemetry/tracer.js +9 -11
  140. package/packages/dd-trace/src/opentracing/propagation/text_map.js +17 -10
  141. package/packages/dd-trace/src/opentracing/span.js +1 -1
  142. package/packages/dd-trace/src/opentracing/tracer.js +17 -5
  143. package/packages/dd-trace/src/plugins/index.js +1 -0
  144. package/packages/dd-trace/src/plugins/log_plugin.js +3 -0
  145. package/packages/dd-trace/src/plugins/plugin.js +6 -11
  146. package/packages/dd-trace/src/plugins/storage.js +2 -2
  147. package/packages/dd-trace/src/plugins/tracing.js +22 -5
  148. package/packages/dd-trace/src/plugins/util/test.js +128 -5
  149. package/packages/dd-trace/src/plugins/util/url.js +2 -1
  150. package/packages/dd-trace/src/plugins/util/web.js +6 -88
  151. package/packages/dd-trace/src/profiling/profiler.js +34 -77
  152. package/packages/dd-trace/src/profiling/profilers/event_plugins/crypto.js +32 -0
  153. package/packages/dd-trace/src/profiling/profilers/event_plugins/zlib.js +19 -0
  154. package/packages/dd-trace/src/profiling/profilers/events.js +35 -0
  155. package/packages/dd-trace/src/proxy.js +3 -4
  156. package/packages/dd-trace/src/runtime_metrics/runtime_metrics.js +17 -13
  157. package/packages/dd-trace/src/service-naming/index.js +1 -1
  158. package/packages/dd-trace/src/service-naming/schemas/definition.js +4 -1
  159. package/packages/dd-trace/src/service-naming/schemas/util.js +15 -1
  160. package/packages/dd-trace/src/service-naming/schemas/v0/messaging.js +24 -1
  161. package/packages/dd-trace/src/service-naming/schemas/v0/storage.js +60 -0
  162. package/packages/dd-trace/src/service-naming/schemas/v0/web.js +21 -1
  163. package/packages/dd-trace/src/service-naming/schemas/v0/websocket.js +5 -0
  164. package/packages/dd-trace/src/service-naming/schemas/v1/storage.js +17 -0
  165. package/packages/dd-trace/src/service-naming/schemas/v1/web.js +15 -1
  166. package/packages/dd-trace/src/service-naming/schemas/v1/websocket.js +6 -0
  167. package/packages/dd-trace/src/span_processor.js +1 -2
  168. package/packages/dd-trace/src/span_stats.js +5 -1
  169. package/packages/dd-trace/src/tagger.js +2 -2
  170. package/packages/dd-trace/src/telemetry/send-data.js +5 -7
  171. package/vendor/dist/@apm-js-collab/code-transformer/index.js +28 -6
  172. package/vendor/dist/protobufjs/index.js +1 -1
  173. package/packages/dd-trace/src/log/utils.js +0 -16
  174. package/vendor/dist/ignore/LICENSE +0 -21
  175. package/vendor/dist/ignore/index.js +0 -1
@@ -0,0 +1,358 @@
1
+ // Vendored from: https://github.com/open-telemetry/opentelemetry-proto/blob/v1.7.0/opentelemetry/proto/trace/v1/trace.proto
2
+ // Copyright 2019, OpenTelemetry Authors
3
+ //
4
+ // Licensed under the Apache License, Version 2.0 (the "License");
5
+ // you may not use this file except in compliance with the License.
6
+ // You may obtain a copy of the License at
7
+ //
8
+ // http://www.apache.org/licenses/LICENSE-2.0
9
+ //
10
+ // Unless required by applicable law or agreed to in writing, software
11
+ // distributed under the License is distributed on an "AS IS" BASIS,
12
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ // See the License for the specific language governing permissions and
14
+ // limitations under the License.
15
+
16
+ syntax = "proto3";
17
+
18
+ package opentelemetry.proto.trace.v1;
19
+
20
+ import "common.proto";
21
+ import "resource.proto";
22
+
23
+ option csharp_namespace = "OpenTelemetry.Proto.Trace.V1";
24
+ option java_multiple_files = true;
25
+ option java_package = "io.opentelemetry.proto.trace.v1";
26
+ option java_outer_classname = "TraceProto";
27
+ option go_package = "go.opentelemetry.io/proto/otlp/trace/v1";
28
+
29
+ // TracesData represents the traces data that can be stored in a persistent storage,
30
+ // OR can be embedded by other protocols that transfer OTLP traces data but do
31
+ // not implement the OTLP protocol.
32
+ //
33
+ // The main difference between this message and collector protocol is that
34
+ // in this message there will not be any "control" or "metadata" specific to
35
+ // OTLP protocol.
36
+ //
37
+ // When new fields are added into this message, the OTLP request MUST be updated
38
+ // as well.
39
+ message TracesData {
40
+ // An array of ResourceSpans.
41
+ // For data coming from a single resource this array will typically contain
42
+ // one element. Intermediary nodes that receive data from multiple origins
43
+ // typically batch the data before forwarding further and in that case this
44
+ // array will contain multiple elements.
45
+ repeated ResourceSpans resource_spans = 1;
46
+ }
47
+
48
+ // A collection of ScopeSpans from a Resource.
49
+ message ResourceSpans {
50
+ reserved 1000;
51
+
52
+ // The resource for the spans in this message.
53
+ // If this field is not set then no resource info is known.
54
+ opentelemetry.proto.resource.v1.Resource resource = 1;
55
+
56
+ // A list of ScopeSpans that originate from a resource.
57
+ repeated ScopeSpans scope_spans = 2;
58
+
59
+ // The Schema URL, if known. This is the identifier of the Schema that the resource data
60
+ // is recorded in. Notably, the last part of the URL path is the version number of the
61
+ // schema: http[s]://server[:port]/path/<version>. To learn more about Schema URL see
62
+ // https://opentelemetry.io/docs/specs/otel/schemas/#schema-url
63
+ // This schema_url applies to the data in the "resource" field. It does not apply
64
+ // to the data in the "scope_spans" field which have their own schema_url field.
65
+ string schema_url = 3;
66
+ }
67
+
68
+ // A collection of Spans produced by an InstrumentationScope.
69
+ message ScopeSpans {
70
+ // The instrumentation scope information for the spans in this message.
71
+ // Semantically when InstrumentationScope isn't set, it is equivalent with
72
+ // an empty instrumentation scope name (unknown).
73
+ opentelemetry.proto.common.v1.InstrumentationScope scope = 1;
74
+
75
+ // A list of Spans that originate from an instrumentation scope.
76
+ repeated Span spans = 2;
77
+
78
+ // The Schema URL, if known. This is the identifier of the Schema that the span data
79
+ // is recorded in. Notably, the last part of the URL path is the version number of the
80
+ // schema: http[s]://server[:port]/path/<version>. To learn more about Schema URL see
81
+ // https://opentelemetry.io/docs/specs/otel/schemas/#schema-url
82
+ // This schema_url applies to all spans and span events in the "spans" field.
83
+ string schema_url = 3;
84
+ }
85
+
86
+ // A Span represents a single operation performed by a single component of the system.
87
+ //
88
+ // The next available field id is 17.
89
+ message Span {
90
+ // A unique identifier for a trace. All spans from the same trace share
91
+ // the same `trace_id`. The ID is a 16-byte array. An ID with all zeroes OR
92
+ // of length other than 16 bytes is considered invalid (empty string in OTLP/JSON
93
+ // is zero-length and thus is also invalid).
94
+ //
95
+ // This field is required.
96
+ bytes trace_id = 1;
97
+
98
+ // A unique identifier for a span within a trace, assigned when the span
99
+ // is created. The ID is an 8-byte array. An ID with all zeroes OR of length
100
+ // other than 8 bytes is considered invalid (empty string in OTLP/JSON
101
+ // is zero-length and thus is also invalid).
102
+ //
103
+ // This field is required.
104
+ bytes span_id = 2;
105
+
106
+ // trace_state conveys information about request position in multiple distributed tracing graphs.
107
+ // It is a trace_state in w3c-trace-context format: https://www.w3.org/TR/trace-context/#tracestate-header
108
+ // See also https://github.com/w3c/distributed-tracing for more details about this field.
109
+ string trace_state = 3;
110
+
111
+ // The `span_id` of this span's parent span. If this is a root span, then this
112
+ // field must be empty. The ID is an 8-byte array.
113
+ bytes parent_span_id = 4;
114
+
115
+ // Flags, a bit field.
116
+ //
117
+ // Bits 0-7 (8 least significant bits) are the trace flags as defined in W3C Trace
118
+ // Context specification. To read the 8-bit W3C trace flag, use
119
+ // `flags & SPAN_FLAGS_TRACE_FLAGS_MASK`.
120
+ //
121
+ // See https://www.w3.org/TR/trace-context-2/#trace-flags for the flag definitions.
122
+ //
123
+ // Bits 8 and 9 represent the 3 states of whether a span's parent
124
+ // is remote. The states are (unknown, is not remote, is remote).
125
+ // To read whether the value is known, use `(flags & SPAN_FLAGS_CONTEXT_HAS_IS_REMOTE_MASK) != 0`.
126
+ // To read whether the span is remote, use `(flags & SPAN_FLAGS_CONTEXT_IS_REMOTE_MASK) != 0`.
127
+ //
128
+ // When creating span messages, if the message is logically forwarded from another source
129
+ // with an equivalent flags fields (i.e., usually another OTLP span message), the field SHOULD
130
+ // be copied as-is. If creating from a source that does not have an equivalent flags field
131
+ // (such as a runtime representation of an OpenTelemetry span), the high 22 bits MUST
132
+ // be set to zero.
133
+ // Readers MUST NOT assume that bits 10-31 (22 most significant bits) will be zero.
134
+ //
135
+ // [Optional].
136
+ fixed32 flags = 16;
137
+
138
+ // A description of the span's operation.
139
+ //
140
+ // For example, the name can be a qualified method name or a file name
141
+ // and a line number where the operation is called. A best practice is to use
142
+ // the same display name at the same call point in an application.
143
+ // This makes it easier to correlate spans in different traces.
144
+ //
145
+ // This field is semantically required to be set to non-empty string.
146
+ // Empty value is equivalent to an unknown span name.
147
+ //
148
+ // This field is required.
149
+ string name = 5;
150
+
151
+ // SpanKind is the type of span. Can be used to specify additional relationships between spans
152
+ // in addition to a parent/child relationship.
153
+ enum SpanKind {
154
+ // Unspecified. Do NOT use as default.
155
+ // Implementations MAY assume SpanKind to be INTERNAL when receiving UNSPECIFIED.
156
+ SPAN_KIND_UNSPECIFIED = 0;
157
+
158
+ // Indicates that the span represents an internal operation within an application,
159
+ // as opposed to an operation happening at the boundaries. Default value.
160
+ SPAN_KIND_INTERNAL = 1;
161
+
162
+ // Indicates that the span covers server-side handling of an RPC or other
163
+ // remote network request.
164
+ SPAN_KIND_SERVER = 2;
165
+
166
+ // Indicates that the span describes a request to some remote service.
167
+ SPAN_KIND_CLIENT = 3;
168
+
169
+ // Indicates that the span describes a producer sending a message to a broker.
170
+ // Unlike CLIENT and SERVER, there is often no direct critical path latency relationship
171
+ // between producer and consumer spans. A PRODUCER span ends when the message was accepted
172
+ // by the broker while the logical processing of the message might span a much longer time.
173
+ SPAN_KIND_PRODUCER = 4;
174
+
175
+ // Indicates that the span describes consumer receiving a message from a broker.
176
+ // Like the PRODUCER kind, there is often no direct critical path latency relationship
177
+ // between producer and consumer spans.
178
+ SPAN_KIND_CONSUMER = 5;
179
+ }
180
+
181
+ // Distinguishes between spans generated in a particular context. For example,
182
+ // two spans with the same name may be distinguished using `CLIENT` (caller)
183
+ // and `SERVER` (callee) to identify queueing latency associated with the span.
184
+ SpanKind kind = 6;
185
+
186
+ // start_time_unix_nano is the start time of the span. On the client side, this is the time
187
+ // kept by the local machine where the span execution starts. On the server side, this
188
+ // is the time when the server's application handler starts running.
189
+ // Value is UNIX Epoch time in nanoseconds since 00:00:00 UTC on 1 January 1970.
190
+ //
191
+ // This field is semantically required and it is expected that end_time >= start_time.
192
+ fixed64 start_time_unix_nano = 7;
193
+
194
+ // end_time_unix_nano is the end time of the span. On the client side, this is the time
195
+ // kept by the local machine where the span execution ends. On the server side, this
196
+ // is the time when the server application handler stops running.
197
+ // Value is UNIX Epoch time in nanoseconds since 00:00:00 UTC on 1 January 1970.
198
+ //
199
+ // This field is semantically required and it is expected that end_time >= start_time.
200
+ fixed64 end_time_unix_nano = 8;
201
+
202
+ // attributes is a collection of key/value pairs. Note, global attributes
203
+ // like server name can be set using the resource API. Examples of attributes:
204
+ //
205
+ // "/http/user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36"
206
+ // "/http/server_latency": 300
207
+ // "example.com/myattribute": true
208
+ // "example.com/score": 10.239
209
+ //
210
+ // The OpenTelemetry API specification further restricts the allowed value types:
211
+ // https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/common/README.md#attribute
212
+ // Attribute keys MUST be unique (it is not allowed to have more than one
213
+ // attribute with the same key).
214
+ repeated opentelemetry.proto.common.v1.KeyValue attributes = 9;
215
+
216
+ // dropped_attributes_count is the number of attributes that were discarded. Attributes
217
+ // can be discarded because their keys are too long or because there are too many
218
+ // attributes. If this value is 0, then no attributes were dropped.
219
+ uint32 dropped_attributes_count = 10;
220
+
221
+ // Event is a time-stamped annotation of the span, consisting of user-supplied
222
+ // text description and key-value pairs.
223
+ message Event {
224
+ // time_unix_nano is the time the event occurred.
225
+ fixed64 time_unix_nano = 1;
226
+
227
+ // name of the event.
228
+ // This field is semantically required to be set to non-empty string.
229
+ string name = 2;
230
+
231
+ // attributes is a collection of attribute key/value pairs on the event.
232
+ // Attribute keys MUST be unique (it is not allowed to have more than one
233
+ // attribute with the same key).
234
+ repeated opentelemetry.proto.common.v1.KeyValue attributes = 3;
235
+
236
+ // dropped_attributes_count is the number of dropped attributes. If the value is 0,
237
+ // then no attributes were dropped.
238
+ uint32 dropped_attributes_count = 4;
239
+ }
240
+
241
+ // events is a collection of Event items.
242
+ repeated Event events = 11;
243
+
244
+ // dropped_events_count is the number of dropped events. If the value is 0, then no
245
+ // events were dropped.
246
+ uint32 dropped_events_count = 12;
247
+
248
+ // A pointer from the current span to another span in the same trace or in a
249
+ // different trace. For example, this can be used in batching operations,
250
+ // where a single batch handler processes multiple requests from different
251
+ // traces or when the handler receives a request from a different project.
252
+ message Link {
253
+ // A unique identifier of a trace that this linked span is part of. The ID is a
254
+ // 16-byte array.
255
+ bytes trace_id = 1;
256
+
257
+ // A unique identifier for the linked span. The ID is an 8-byte array.
258
+ bytes span_id = 2;
259
+
260
+ // The trace_state associated with the link.
261
+ string trace_state = 3;
262
+
263
+ // attributes is a collection of attribute key/value pairs on the link.
264
+ // Attribute keys MUST be unique (it is not allowed to have more than one
265
+ // attribute with the same key).
266
+ repeated opentelemetry.proto.common.v1.KeyValue attributes = 4;
267
+
268
+ // dropped_attributes_count is the number of dropped attributes. If the value is 0,
269
+ // then no attributes were dropped.
270
+ uint32 dropped_attributes_count = 5;
271
+
272
+ // Flags, a bit field.
273
+ //
274
+ // Bits 0-7 (8 least significant bits) are the trace flags as defined in W3C Trace
275
+ // Context specification. To read the 8-bit W3C trace flag, use
276
+ // `flags & SPAN_FLAGS_TRACE_FLAGS_MASK`.
277
+ //
278
+ // See https://www.w3.org/TR/trace-context-2/#trace-flags for the flag definitions.
279
+ //
280
+ // Bits 8 and 9 represent the 3 states of whether the link is remote.
281
+ // The states are (unknown, is not remote, is remote).
282
+ // To read whether the value is known, use `(flags & SPAN_FLAGS_CONTEXT_HAS_IS_REMOTE_MASK) != 0`.
283
+ // To read whether the link is remote, use `(flags & SPAN_FLAGS_CONTEXT_IS_REMOTE_MASK) != 0`.
284
+ //
285
+ // Readers MUST NOT assume that bits 10-31 (22 most significant bits) will be zero.
286
+ // When creating new spans, bits 10-31 (most-significant 22-bits) MUST be zero.
287
+ //
288
+ // [Optional].
289
+ fixed32 flags = 6;
290
+ }
291
+
292
+ // links is a collection of Links, which are references from this span to a span
293
+ // in the same or different trace.
294
+ repeated Link links = 13;
295
+
296
+ // dropped_links_count is the number of dropped links after the maximum size was
297
+ // enforced. If this value is 0, then no links were dropped.
298
+ uint32 dropped_links_count = 14;
299
+
300
+ // An optional final status for this span. Semantically when Status isn't set, it means
301
+ // span's status code is unset, i.e. assume STATUS_CODE_UNSET (code = 0).
302
+ Status status = 15;
303
+ }
304
+
305
+ // The Status type defines a logical error model that is suitable for different
306
+ // programming environments, including REST APIs and RPC APIs.
307
+ message Status {
308
+ reserved 1;
309
+
310
+ // A developer-facing human readable error message.
311
+ string message = 2;
312
+
313
+ // For the semantics of status codes see
314
+ // https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/api.md#set-status
315
+ enum StatusCode {
316
+ // The default status.
317
+ STATUS_CODE_UNSET = 0;
318
+ // The Span has been validated by an Application developer or Operator to
319
+ // have completed successfully.
320
+ STATUS_CODE_OK = 1;
321
+ // The Span contains an error.
322
+ STATUS_CODE_ERROR = 2;
323
+ };
324
+
325
+ // The status code.
326
+ StatusCode code = 3;
327
+ }
328
+
329
+ // SpanFlags represents constants used to interpret the
330
+ // Span.flags field, which is protobuf 'fixed32' type and is to
331
+ // be used as bit-fields. Each non-zero value defined in this enum is
332
+ // a bit-mask. To extract the bit-field, for example, use an
333
+ // expression like:
334
+ //
335
+ // (span.flags & SPAN_FLAGS_TRACE_FLAGS_MASK)
336
+ //
337
+ // See https://www.w3.org/TR/trace-context-2/#trace-flags for the flag definitions.
338
+ //
339
+ // Note that Span flags were introduced in version 1.1 of the
340
+ // OpenTelemetry protocol. Older Span producers do not set this
341
+ // field, consequently consumers should not rely on the absence of a
342
+ // particular flag bit to indicate the presence of a particular feature.
343
+ enum SpanFlags {
344
+ // The zero value for the enum. Should not be used for comparisons.
345
+ // Instead use bitwise "and" with the appropriate mask as shown above.
346
+ SPAN_FLAGS_DO_NOT_USE = 0;
347
+
348
+ // Bits 0-7 are used for trace flags.
349
+ SPAN_FLAGS_TRACE_FLAGS_MASK = 0x000000FF;
350
+
351
+ // Bits 8 and 9 are used to indicate that the parent span or link span is remote.
352
+ // Bit 8 (`HAS_IS_REMOTE`) indicates whether the value is known.
353
+ // Bit 9 (`IS_REMOTE`) indicates whether the span or link is remote.
354
+ SPAN_FLAGS_CONTEXT_HAS_IS_REMOTE_MASK = 0x00000100;
355
+ SPAN_FLAGS_CONTEXT_IS_REMOTE_MASK = 0x00000200;
356
+
357
+ // Bits 10-31 are reserved for future use.
358
+ }
@@ -0,0 +1,78 @@
1
+ // Vendored from: https://github.com/open-telemetry/opentelemetry-proto/blob/v1.7.0/opentelemetry/proto/collector/trace/v1/trace_service.proto
2
+ // Copyright 2019, OpenTelemetry Authors
3
+ //
4
+ // Licensed under the Apache License, Version 2.0 (the "License");
5
+ // you may not use this file except in compliance with the License.
6
+ // You may obtain a copy of the License at
7
+ //
8
+ // http://www.apache.org/licenses/LICENSE-2.0
9
+ //
10
+ // Unless required by applicable law or agreed to in writing, software
11
+ // distributed under the License is distributed on an "AS IS" BASIS,
12
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ // See the License for the specific language governing permissions and
14
+ // limitations under the License.
15
+
16
+ syntax = "proto3";
17
+
18
+ package opentelemetry.proto.collector.trace.v1;
19
+
20
+ import "trace.proto";
21
+
22
+ option csharp_namespace = "OpenTelemetry.Proto.Collector.Trace.V1";
23
+ option java_multiple_files = true;
24
+ option java_package = "io.opentelemetry.proto.collector.trace.v1";
25
+ option java_outer_classname = "TraceServiceProto";
26
+ option go_package = "go.opentelemetry.io/proto/otlp/collector/trace/v1";
27
+
28
+ // Service that can be used to push spans between one Application instrumented with
29
+ // OpenTelemetry and a collector, or between a collector and a central collector (in this
30
+ // case spans are sent/received to/from multiple Applications).
31
+ service TraceService {
32
+ rpc Export(ExportTraceServiceRequest) returns (ExportTraceServiceResponse) {}
33
+ }
34
+
35
+ message ExportTraceServiceRequest {
36
+ // An array of ResourceSpans.
37
+ // For data coming from a single resource this array will typically contain one
38
+ // element. Intermediary nodes (such as OpenTelemetry Collector) that receive
39
+ // data from multiple origins typically batch the data before forwarding further and
40
+ // in that case this array will contain multiple elements.
41
+ repeated opentelemetry.proto.trace.v1.ResourceSpans resource_spans = 1;
42
+ }
43
+
44
+ message ExportTraceServiceResponse {
45
+ // The details of a partially successful export request.
46
+ //
47
+ // If the request is only partially accepted
48
+ // (i.e. when the server accepts only parts of the data and rejects the rest)
49
+ // the server MUST initialize the `partial_success` field and MUST
50
+ // set the `rejected_<signal>` with the number of items it rejected.
51
+ //
52
+ // Servers MAY also make use of the `partial_success` field to convey
53
+ // warnings/suggestions to senders even when the request was fully accepted.
54
+ // In such cases, the `rejected_<signal>` MUST have a value of `0` and
55
+ // the `error_message` MUST be non-empty.
56
+ //
57
+ // A `partial_success` message with an empty value (rejected_<signal> = 0 and
58
+ // `error_message` = "") is equivalent to it not being set/present. Senders
59
+ // SHOULD interpret it the same way as in the full success case.
60
+ ExportTracePartialSuccess partial_success = 1;
61
+ }
62
+
63
+ message ExportTracePartialSuccess {
64
+ // The number of rejected spans.
65
+ //
66
+ // A `rejected_<signal>` field holding a `0` value indicates that the
67
+ // request was fully accepted.
68
+ int64 rejected_spans = 1;
69
+
70
+ // A developer-facing human-readable message in English. It should be used
71
+ // either to explain why the server rejected parts of the data during a partial
72
+ // success or to convey warnings/suggestions during a full success. The message
73
+ // should offer guidance on how users can address such issues.
74
+ //
75
+ // error_message is an optional field. An error_message with an empty value
76
+ // is equivalent to it not being set.
77
+ string error_message = 2;
78
+ }
@@ -0,0 +1,70 @@
1
+ 'use strict'
2
+
3
+ const { VERSION } = require('../../../../../version')
4
+ const OtlpHttpTraceExporter = require('./otlp_http_trace_exporter')
5
+
6
+ /**
7
+ * @typedef {import('../../config/config-base')} Config
8
+ * @typedef {import('../../opentracing/tracer')} DatadogTracer
9
+ */
10
+
11
+ /**
12
+ * OpenTelemetry Trace Export for dd-trace-js
13
+ *
14
+ * This module provides OTLP trace export support that integrates with
15
+ * the existing Datadog tracing pipeline. When enabled, the OTLP exporter
16
+ * replaces the default Datadog Agent exporter at tracer initialization time.
17
+ *
18
+ * Key Components:
19
+ * - OtlpHttpTraceExporter: Exports spans via OTLP over HTTP/JSON (port 4318)
20
+ * - OtlpTraceTransformer: Transforms DD-formatted spans to OTLP JSON format
21
+ *
22
+ * When enabled, traces are exported exclusively via OTLP. The original
23
+ * Datadog Agent exporter is replaced.
24
+ *
25
+ * @package
26
+ */
27
+
28
+ /**
29
+ * Builds resource attributes from the tracer configuration.
30
+ *
31
+ * @param {Config} config - Tracer configuration instance
32
+ * @returns {import('@opentelemetry/api').Attributes} Resource attributes
33
+ */
34
+ function buildResourceAttributes (config) {
35
+ const resourceAttributes = {
36
+ 'service.name': config.service,
37
+ 'telemetry.sdk.name': 'datadog',
38
+ 'telemetry.sdk.version': VERSION,
39
+ 'telemetry.sdk.language': 'nodejs',
40
+ }
41
+
42
+ if (config.env) resourceAttributes['deployment.environment.name'] = config.env
43
+ if (config.version) resourceAttributes['service.version'] = config.version
44
+
45
+ const { service, version, env, ...filteredTags } = config.tags
46
+ Object.assign(resourceAttributes, filteredTags)
47
+
48
+ return resourceAttributes
49
+ }
50
+
51
+ /**
52
+ * Creates the OTLP HTTP/JSON trace exporter.
53
+ *
54
+ * @param {Config} config - Tracer configuration instance
55
+ * @returns {OtlpHttpTraceExporter} The OTLP HTTP/JSON exporter
56
+ */
57
+ function createOtlpTraceExporter (config) {
58
+ return new OtlpHttpTraceExporter(
59
+ config.OTEL_EXPORTER_OTLP_TRACES_ENDPOINT,
60
+ config.OTEL_EXPORTER_OTLP_TRACES_HEADERS,
61
+ config.OTEL_EXPORTER_OTLP_TRACES_TIMEOUT,
62
+ buildResourceAttributes(config)
63
+ )
64
+ }
65
+
66
+ module.exports = {
67
+ OtlpHttpTraceExporter,
68
+ buildResourceAttributes,
69
+ createOtlpTraceExporter,
70
+ }
@@ -0,0 +1,74 @@
1
+ 'use strict'
2
+
3
+ const OtlpHttpExporterBase = require('../otlp/otlp_http_exporter_base')
4
+ const { SAMPLING_PRIORITY_KEY } = require('../../constants')
5
+ const { AUTO_KEEP } = require('../../../../../ext/priority')
6
+ const OtlpTraceTransformer = require('./otlp_transformer')
7
+
8
+ /**
9
+ * OtlpHttpTraceExporter exports DD-formatted spans via OTLP over HTTP/JSON.
10
+ *
11
+ * This implementation follows the OTLP HTTP specification:
12
+ * https://opentelemetry.io/docs/specs/otlp/#otlphttp
13
+ *
14
+ * It receives DD-formatted spans (from span_format.js), transforms them
15
+ * to OTLP ExportTraceServiceRequest JSON format, and sends them to the
16
+ * configured OTLP endpoint via HTTP POST.
17
+ *
18
+ * TODO: Add batch handling similar to the OpenTelemetry SDK Batch Processor
19
+ * (https://opentelemetry.io/docs/specs/otel/trace/sdk/#batching-processor).
20
+ * Currently each finished trace is sent as its own HTTP request, which is
21
+ * unsuitable for high-traffic production environments. The config values
22
+ * `otelBatchTimeout`, `otelMaxExportBatchSize`, and `otelMaxQueueSize`
23
+ * (OTEL_BSP_*) are already defined and should drive that implementation.
24
+ *
25
+ * @class OtlpHttpTraceExporter
26
+ * @augments OtlpHttpExporterBase
27
+ */
28
+ class OtlpHttpTraceExporter extends OtlpHttpExporterBase {
29
+ #transformer
30
+
31
+ /**
32
+ * Creates a new OtlpHttpTraceExporter instance.
33
+ *
34
+ * @param {string} url - OTLP endpoint URL
35
+ * @param {Record<string, string>|undefined} headers - Additional HTTP headers parsed from the
36
+ * corresponding `OTEL_EXPORTER_OTLP_*_HEADERS` env by the MAP parser.
37
+ * @param {number} timeout - Request timeout in milliseconds
38
+ * @param {import('@opentelemetry/api').Attributes} resourceAttributes - Resource attributes
39
+ */
40
+ constructor (url, headers, timeout, resourceAttributes) {
41
+ super(url, headers, timeout, 'http/json', 'traces')
42
+ this.#transformer = new OtlpTraceTransformer(resourceAttributes)
43
+ }
44
+
45
+ /**
46
+ * Exports DD-formatted spans via OTLP over HTTP.
47
+ *
48
+ * @param {import('./otlp_transformer').DDFormattedSpan[]} spans - Array of DD-formatted spans to export
49
+ * @returns {void}
50
+ */
51
+ export (spans) {
52
+ if (spans.length === 0) {
53
+ return
54
+ }
55
+
56
+ // Drop unsampled traces — OTLP endpoints have no agent-side sampling.
57
+ const priority = spans[0]?.metrics?.[SAMPLING_PRIORITY_KEY]
58
+ if (priority !== undefined && priority < AUTO_KEEP) {
59
+ return
60
+ }
61
+
62
+ const additionalTags = [`spans:${spans.length}`]
63
+ this.recordTelemetry('otel.traces_export_attempts', 1, additionalTags)
64
+
65
+ const payload = this.#transformer.transformSpans(spans)
66
+ this.sendPayload(payload, (result) => {
67
+ if (result.code === 0) {
68
+ this.recordTelemetry('otel.traces_export_successes', 1, additionalTags)
69
+ }
70
+ })
71
+ }
72
+ }
73
+
74
+ module.exports = OtlpHttpTraceExporter