@@ -91,32 +91,58 @@ pub struct DatadogTracingBuilder {
91
91
}
92
92
93
93
impl DatadogTracingBuilder {
94
+ /// Sets the datadog specific configuration
95
+ ///
96
+ /// Default: dd_trace::Config::builder().build()
94
97
pub fn with_config ( mut self , config : dd_trace:: Config ) -> Self {
95
98
self . config = Some ( config) ;
96
99
self
97
100
}
98
101
102
+ /// Sets the resource passed to the SDK. See [opentelemetry_sdk::Resource]
103
+ ///
104
+ /// Default: Config::builder().build()
99
105
pub fn with_resource ( mut self , resource : opentelemetry_sdk:: Resource ) -> Self {
100
106
self . resource = Some ( resource) ;
101
107
self
102
108
}
103
109
110
+ /// Initializes the Tracer Provider, and the Text Map Propagator and install
111
+ /// them globally
104
112
pub fn init ( self ) -> SdkTracerProvider {
105
- let config = self
106
- . config
107
- . unwrap_or_else ( || dd_trace:: Config :: builder ( ) . build ( ) ) ;
108
- let ( tracer_provider, propagator) =
109
- make_tracer ( Arc :: new ( config) , self . tracer_provider , self . resource ) ;
113
+ let ( tracer_provider, propagator) = self . init_local ( ) ;
110
114
111
115
opentelemetry:: global:: set_text_map_propagator ( propagator) ;
112
116
opentelemetry:: global:: set_tracer_provider ( tracer_provider. clone ( ) ) ;
113
117
tracer_provider
114
118
}
119
+
120
+ /// Initialize the Tracer Provider, and the Text Map Propagator without doing a global
121
+ /// installation
122
+ ///
123
+ /// You will need to set them up yourself, at a latter point if you want to use global tracing
124
+ /// methods and library integrations
125
+ ///
126
+ /// # Example
127
+ ///
128
+ /// ```rust
129
+ /// let (tracer_provider, propagator) = datadog_opentelemetry::tracing().init_local();
130
+ ///
131
+ /// opentelemetry::global::set_text_map_propagator(propagator);
132
+ /// opentelemetry::global::set_tracer_provider(tracer_provider.clone());
133
+ /// ```
134
+ pub fn init_local ( self ) -> ( SdkTracerProvider , DatadogPropagator ) {
135
+ let config = self
136
+ . config
137
+ . unwrap_or_else ( || dd_trace:: Config :: builder ( ) . build ( ) ) ;
138
+ make_tracer ( Arc :: new ( config) , self . tracer_provider , self . resource )
139
+ }
115
140
}
116
141
117
142
impl DatadogTracingBuilder {
118
143
// Methods forwarded to the otel tracer provider builder
119
144
145
+ /// See [opentelemetry_sdk::trace::TracerProviderBuilder::with_span_processor]
120
146
pub fn with_span_processor < T : opentelemetry_sdk:: trace:: SpanProcessor + ' static > (
121
147
mut self ,
122
148
processor : T ,
@@ -126,12 +152,14 @@ impl DatadogTracingBuilder {
126
152
}
127
153
128
154
/// Specify the number of events to be recorded per span.
155
+ /// See [opentelemetry_sdk::trace::TracerProviderBuilder::with_max_events_per_span]
129
156
pub fn with_max_events_per_span ( mut self , max_events : u32 ) -> Self {
130
157
self . tracer_provider = self . tracer_provider . with_max_events_per_span ( max_events) ;
131
158
self
132
159
}
133
160
134
161
/// Specify the number of attributes to be recorded per span.
162
+ /// See [opentelemetry_sdk::trace::TracerProviderBuilder::with_max_attributes_per_span]
135
163
pub fn with_max_attributes_per_span ( mut self , max_attributes : u32 ) -> Self {
136
164
self . tracer_provider = self
137
165
. tracer_provider
@@ -140,12 +168,14 @@ impl DatadogTracingBuilder {
140
168
}
141
169
142
170
/// Specify the number of events to be recorded per span.
171
+ /// See [opentelemetry_sdk::trace::TracerProviderBuilder::with_max_links_per_span]
143
172
pub fn with_max_links_per_span ( mut self , max_links : u32 ) -> Self {
144
173
self . tracer_provider = self . tracer_provider . with_max_links_per_span ( max_links) ;
145
174
self
146
175
}
147
176
148
177
/// Specify the number of attributes one event can have.
178
+ /// See [opentelemetry_sdk::trace::TracerProviderBuilder::with_max_attributes_per_event]
149
179
pub fn with_max_attributes_per_event ( mut self , max_attributes : u32 ) -> Self {
150
180
self . tracer_provider = self
151
181
. tracer_provider
@@ -154,6 +184,7 @@ impl DatadogTracingBuilder {
154
184
}
155
185
156
186
/// Specify the number of attributes one link can have.
187
+ /// See [opentelemetry_sdk::trace::TracerProviderBuilder::with_max_attributes_per_link]
157
188
pub fn with_max_attributes_per_link ( mut self , max_attributes : u32 ) -> Self {
158
189
self . tracer_provider = self
159
190
. tracer_provider
@@ -162,6 +193,7 @@ impl DatadogTracingBuilder {
162
193
}
163
194
164
195
/// Specify all limit via the span_limits
196
+ /// See [opentelemetry_sdk::trace::TracerProviderBuilder::with_span_limits]
165
197
pub fn with_span_limits ( mut self , span_limits : opentelemetry_sdk:: trace:: SpanLimits ) -> Self {
166
198
self . tracer_provider = self . tracer_provider . with_span_limits ( span_limits) ;
167
199
self
0 commit comments