Monitoring System 0.1.0
System resource monitoring with pluggable collectors and alerting
Loading...
Searching...
No Matches
test_trace_exporters.cpp
Go to the documentation of this file.
1// BSD 3-Clause License
2// Copyright (c) 2025, 🍀☀🌕🌥 🌊
3// See the LICENSE file in the project root for full license information.
4
5
6#include <gtest/gtest.h>
8// Note: distributed_tracer.h does not exist in include directory
9// #include <kcenon/monitoring/tracing/distributed_tracer.h>
11#include <thread>
12#include <chrono>
13
14using namespace kcenon::monitoring;
15
16class TraceExportersTest : public ::testing::Test {
17protected:
18 void SetUp() override {
19 // Create test spans
21
22 // Create OTEL resource
23 otel_resource_ = create_service_resource("test_service", "1.0.0", "test_namespace");
24 }
25
26 std::vector<trace_span> create_test_spans() {
27 std::vector<trace_span> spans;
28
29 // Root span
30 trace_span root_span;
31 root_span.trace_id = "trace123";
32 root_span.span_id = "span001";
33 root_span.operation_name = "http_request";
34 root_span.service_name = "web_service";
35 root_span.start_time = std::chrono::system_clock::now();
36 root_span.end_time = root_span.start_time + std::chrono::milliseconds(100);
37 root_span.tags["http.method"] = "GET";
38 root_span.tags["http.url"] = "/api/users";
39 root_span.tags["span.kind"] = "server";
40 spans.push_back(root_span);
41
42 // Child span
43 trace_span child_span;
44 child_span.trace_id = "trace123";
45 child_span.span_id = "span002";
46 child_span.parent_span_id = "span001";
47 child_span.operation_name = "database_query";
48 child_span.service_name = "db_service";
49 child_span.start_time = root_span.start_time + std::chrono::milliseconds(10);
50 child_span.end_time = root_span.start_time + std::chrono::milliseconds(80);
51 child_span.tags["db.statement"] = "SELECT * FROM users WHERE id = ?";
52 child_span.tags["db.type"] = "postgresql";
53 child_span.tags["span.kind"] = "client";
54 spans.push_back(child_span);
55
56 return spans;
57 }
58
59 std::vector<trace_span> test_spans_;
61};
62
63TEST_F(TraceExportersTest, TraceExportConfigValidation) {
64 // Valid configuration
65 trace_export_config valid_config;
66 valid_config.endpoint = "http://jaeger:14268/api/traces";
67 valid_config.format = trace_export_format::jaeger_thrift;
68 valid_config.timeout = std::chrono::milliseconds(5000);
69 valid_config.max_batch_size = 100;
70 valid_config.max_queue_size = 1000;
71
72 auto validation = valid_config.validate();
73 EXPECT_TRUE(validation.is_ok());
74
75 // Invalid endpoint
76 trace_export_config invalid_endpoint;
77 invalid_endpoint.endpoint = "";
78 auto endpoint_validation = invalid_endpoint.validate();
79 EXPECT_TRUE(endpoint_validation.is_err());
80 EXPECT_EQ(endpoint_validation.error().code, static_cast<int>(monitoring_error_code::invalid_configuration));
81
82 // Invalid timeout
83 trace_export_config invalid_timeout;
84 invalid_timeout.endpoint = "http://test";
85 invalid_timeout.timeout = std::chrono::milliseconds(0);
86 auto timeout_validation = invalid_timeout.validate();
87 EXPECT_TRUE(timeout_validation.is_err());
88
89 // Invalid batch size
90 trace_export_config invalid_batch;
91 invalid_batch.endpoint = "http://test";
92 invalid_batch.max_batch_size = 0;
93 auto batch_validation = invalid_batch.validate();
94 EXPECT_TRUE(batch_validation.is_err());
95
96 // Invalid queue size
97 trace_export_config invalid_queue;
98 invalid_queue.endpoint = "http://test";
99 invalid_queue.max_batch_size = 100;
100 invalid_queue.max_queue_size = 50;
101 auto queue_validation = invalid_queue.validate();
102 EXPECT_TRUE(queue_validation.is_err());
103}
104
105TEST_F(TraceExportersTest, JaegerSpanConversion) {
106 trace_export_config config;
107 config.endpoint = "http://jaeger:14268/api/traces";
108 config.format = trace_export_format::jaeger_thrift;
109 config.service_name = "test_service";
110
111 jaeger_exporter exporter(config);
112
113 const auto& span = test_spans_[0];
114 auto jaeger_span = exporter.convert_span(span);
115
116 EXPECT_EQ(jaeger_span.trace_id, span.trace_id);
117 EXPECT_EQ(jaeger_span.span_id, span.span_id);
118 EXPECT_EQ(jaeger_span.operation_name, span.operation_name);
119 EXPECT_EQ(jaeger_span.service_name, "test_service"); // Override from config
120
121 // Check tags conversion
122 bool found_http_method = false;
123 bool found_http_url = false;
124 for (const auto& [key, value] : jaeger_span.tags) {
125 if (key == "http.method" && value == "GET") {
126 found_http_method = true;
127 }
128 if (key == "http.url" && value == "/api/users") {
129 found_http_url = true;
130 }
131 }
132 EXPECT_TRUE(found_http_method);
133 EXPECT_TRUE(found_http_url);
134
135 // Check process tags
136 bool found_service_name = false;
137 for (const auto& [key, value] : jaeger_span.process_tags) {
138 if (key == "service.name" && value == "test_service") {
139 found_service_name = true;
140 }
141 }
142 EXPECT_TRUE(found_service_name);
143}
144
145TEST_F(TraceExportersTest, JaegerExporterBasicFunctionality) {
146 trace_export_config config;
147 config.endpoint = "http://jaeger:14268/api/traces";
148 config.format = trace_export_format::jaeger_thrift;
149
150 jaeger_exporter exporter(config);
151
152 // Export spans — stub transport returns error (no real HTTP client)
153 auto export_result = exporter.export_spans(test_spans_);
154 EXPECT_TRUE(export_result.is_err());
155
156 // Check statistics — export failed so failed_exports should increment
157 auto stats = exporter.get_stats();
158 EXPECT_EQ(stats["failed_exports"], 1);
159
160 // Test flush and shutdown (should still work)
161 auto flush_result = exporter.flush();
162 EXPECT_TRUE(flush_result.is_ok());
163
164 auto shutdown_result = exporter.shutdown();
165 EXPECT_TRUE(shutdown_result.is_ok());
166}
167
168TEST_F(TraceExportersTest, ZipkinSpanConversion) {
169 trace_export_config config;
170 config.endpoint = "http://zipkin:9411/api/v2/spans";
171 config.format = trace_export_format::zipkin_json;
172 config.service_name = "test_service";
173
174 zipkin_exporter exporter(config);
175
176 const auto& span = test_spans_[0];
177 auto zipkin_span = exporter.convert_span(span);
178
179 EXPECT_EQ(zipkin_span.trace_id, span.trace_id);
180 EXPECT_EQ(zipkin_span.span_id, span.span_id);
181 EXPECT_EQ(zipkin_span.name, span.operation_name);
182 EXPECT_EQ(zipkin_span.local_endpoint_service_name, "test_service");
183 EXPECT_EQ(zipkin_span.kind, "server"); // From span.kind tag
184
185 // Check tags conversion (span.kind should be excluded)
186 EXPECT_EQ(zipkin_span.tags.count("span.kind"), 0);
187 EXPECT_EQ(zipkin_span.tags.count("http.method"), 1);
188 EXPECT_EQ(zipkin_span.tags["http.method"], "GET");
189}
190
191TEST_F(TraceExportersTest, ZipkinExporterBasicFunctionality) {
192 trace_export_config config;
193 config.endpoint = "http://zipkin:9411/api/v2/spans";
194 config.format = trace_export_format::zipkin_json;
195
196 zipkin_exporter exporter(config);
197
198 // Export spans — stub transport returns error (no real HTTP client)
199 auto export_result = exporter.export_spans(test_spans_);
200 EXPECT_TRUE(export_result.is_err());
201
202 // Check statistics — export failed
203 auto stats = exporter.get_stats();
204 EXPECT_EQ(stats["failed_exports"], 1);
205
206 // Test flush and shutdown (should still work)
207 auto flush_result = exporter.flush();
208 EXPECT_TRUE(flush_result.is_ok());
209
210 auto shutdown_result = exporter.shutdown();
211 EXPECT_TRUE(shutdown_result.is_ok());
212}
213
214TEST_F(TraceExportersTest, OtlpExporterBasicFunctionality) {
215 trace_export_config config;
216 config.endpoint = "http://otlp-collector:4317";
217 config.format = trace_export_format::otlp_grpc;
218
219 otlp_exporter exporter(config, otel_resource_);
220
221 // Export spans
222 auto export_result = exporter.export_spans(test_spans_);
223 EXPECT_TRUE(export_result.is_ok());
224
225 // Check statistics
226 auto stats = exporter.get_stats();
227 EXPECT_EQ(stats["exported_spans"], test_spans_.size());
228 EXPECT_EQ(stats["failed_exports"], 0);
229
230 // Test flush and shutdown
231 auto flush_result = exporter.flush();
232 EXPECT_TRUE(flush_result.is_ok());
233
234 auto shutdown_result = exporter.shutdown();
235 EXPECT_TRUE(shutdown_result.is_ok());
236}
237
238TEST_F(TraceExportersTest, TraceExporterFactory) {
239 // Test Jaeger factory
240 trace_export_config jaeger_config;
241 jaeger_config.endpoint = "http://jaeger:14268";
242 jaeger_config.format = trace_export_format::jaeger_grpc;
243
244 auto jaeger_exporter = trace_exporter_factory::create_exporter(jaeger_config, otel_resource_);
245 EXPECT_TRUE(jaeger_exporter);
246
247 // Test Zipkin factory
248 trace_export_config zipkin_config;
249 zipkin_config.endpoint = "http://zipkin:9411";
250 zipkin_config.format = trace_export_format::zipkin_json;
251
252 auto zipkin_exporter = trace_exporter_factory::create_exporter(zipkin_config, otel_resource_);
253 EXPECT_TRUE(zipkin_exporter);
254
255 // Test OTLP factory
256 trace_export_config otlp_config;
257 otlp_config.endpoint = "http://otlp-collector:4317";
258 otlp_config.format = trace_export_format::otlp_grpc;
259
260 auto otlp_exporter = trace_exporter_factory::create_exporter(otlp_config, otel_resource_);
261 EXPECT_TRUE(otlp_exporter);
262}
263
264TEST_F(TraceExportersTest, SupportedFormatsQuery) {
265 auto jaeger_formats = trace_exporter_factory::get_supported_formats("jaeger");
266 EXPECT_EQ(jaeger_formats.size(), 2);
267 EXPECT_TRUE(std::find(jaeger_formats.begin(), jaeger_formats.end(),
268 trace_export_format::jaeger_thrift) != jaeger_formats.end());
269 EXPECT_TRUE(std::find(jaeger_formats.begin(), jaeger_formats.end(),
270 trace_export_format::jaeger_grpc) != jaeger_formats.end());
271
272 auto zipkin_formats = trace_exporter_factory::get_supported_formats("zipkin");
273 EXPECT_EQ(zipkin_formats.size(), 2);
274 EXPECT_TRUE(std::find(zipkin_formats.begin(), zipkin_formats.end(),
275 trace_export_format::zipkin_json) != zipkin_formats.end());
276 EXPECT_TRUE(std::find(zipkin_formats.begin(), zipkin_formats.end(),
277 trace_export_format::zipkin_protobuf) != zipkin_formats.end());
278
279 auto otlp_formats = trace_exporter_factory::get_supported_formats("otlp");
280 EXPECT_EQ(otlp_formats.size(), 3);
281 EXPECT_TRUE(std::find(otlp_formats.begin(), otlp_formats.end(),
282 trace_export_format::otlp_grpc) != otlp_formats.end());
283
284 auto unknown_formats = trace_exporter_factory::get_supported_formats("unknown");
285 EXPECT_EQ(unknown_formats.size(), 0);
286}
287
288TEST_F(TraceExportersTest, HelperFunctions) {
289 // Test Jaeger helper
290 auto jaeger_exporter = create_jaeger_exporter("http://jaeger:14268",
291 trace_export_format::jaeger_thrift);
292 EXPECT_TRUE(jaeger_exporter);
293
294 // Test Zipkin helper
295 auto zipkin_exporter = create_zipkin_exporter("http://zipkin:9411",
296 trace_export_format::zipkin_protobuf);
297 EXPECT_TRUE(zipkin_exporter);
298
299 // Test OTLP helper
300 auto otlp_exporter = create_otlp_exporter("http://otlp:4317", otel_resource_,
301 trace_export_format::otlp_http_json);
302 EXPECT_TRUE(otlp_exporter);
303}
304
305TEST_F(TraceExportersTest, InvalidFormatHandling) {
306 trace_export_config invalid_jaeger_config;
307 invalid_jaeger_config.endpoint = "http://jaeger:14268";
308 invalid_jaeger_config.format = trace_export_format::zipkin_json; // Wrong format
309
310 jaeger_exporter jaeger_exp(invalid_jaeger_config);
311 auto jaeger_result = jaeger_exp.export_spans(test_spans_);
312 EXPECT_TRUE(jaeger_result.is_err());
313 EXPECT_EQ(jaeger_result.error().code, static_cast<int>(monitoring_error_code::invalid_configuration));
314
315 trace_export_config invalid_zipkin_config;
316 invalid_zipkin_config.endpoint = "http://zipkin:9411";
317 invalid_zipkin_config.format = trace_export_format::jaeger_grpc; // Wrong format
318
319 zipkin_exporter zipkin_exp(invalid_zipkin_config);
320 auto zipkin_result = zipkin_exp.export_spans(test_spans_);
321 EXPECT_TRUE(zipkin_result.is_err());
322 EXPECT_EQ(zipkin_result.error().code, static_cast<int>(monitoring_error_code::invalid_configuration));
323
324 trace_export_config invalid_otlp_config;
325 invalid_otlp_config.endpoint = "http://otlp:4317";
326 invalid_otlp_config.format = trace_export_format::jaeger_thrift; // Wrong format
327
328 otlp_exporter otlp_exp(invalid_otlp_config, otel_resource_);
329 auto otlp_result = otlp_exp.export_spans(test_spans_);
330 EXPECT_TRUE(otlp_result.is_err());
331 EXPECT_EQ(otlp_result.error().code, static_cast<int>(monitoring_error_code::invalid_configuration));
332}
333
334TEST_F(TraceExportersTest, EmptySpansHandling) {
335 std::vector<trace_span> empty_spans;
336
337 trace_export_config config;
338 config.endpoint = "http://test:1234";
339 config.format = trace_export_format::jaeger_grpc;
340
341 jaeger_exporter exporter(config);
342 auto result = exporter.export_spans(empty_spans);
343 // Empty spans may succeed (nothing to send) or fail (stub transport)
344 // Either way, no spans were exported
345 auto stats = exporter.get_stats();
346 EXPECT_EQ(stats["exported_spans"], 0);
347}
348
349TEST_F(TraceExportersTest, LargeSpanBatch) {
350 // Create a large batch of spans
351 std::vector<trace_span> large_batch;
352 for (int i = 0; i < 1000; ++i) {
353 trace_span span;
354 span.trace_id = "trace" + std::to_string(i);
355 span.span_id = "span" + std::to_string(i);
356 span.operation_name = "operation_" + std::to_string(i);
357 span.service_name = "test_service";
358 span.start_time = std::chrono::system_clock::now();
359 span.end_time = span.start_time + std::chrono::milliseconds(1);
360 large_batch.push_back(span);
361 }
362
363 trace_export_config config;
364 config.endpoint = "http://test:1234";
365 config.format = trace_export_format::otlp_grpc;
366 config.max_batch_size = 500; // Smaller than batch size
367
368 otlp_exporter exporter(config, otel_resource_);
369 auto result = exporter.export_spans(large_batch);
370 EXPECT_TRUE(result.is_ok());
371
372 auto stats = exporter.get_stats();
373 EXPECT_EQ(stats["exported_spans"], static_cast<std::size_t>(1000));
374}
375
376// ==============================================================
377// OTLP gRPC Exporter Tests
378// ==============================================================
379
381
383protected:
384 void SetUp() override {
386 }
387};
388
389TEST_F(OtlpGrpcExporterTest, ConfigValidation) {
390 // Valid configuration
391 otlp_grpc_config valid_config;
392 valid_config.endpoint = "localhost:4317";
393 valid_config.timeout = std::chrono::milliseconds(5000);
394 valid_config.max_batch_size = 512;
395
396 auto validation = valid_config.validate();
397 EXPECT_TRUE(validation.is_ok());
398
399 // Invalid endpoint (empty)
400 otlp_grpc_config invalid_endpoint;
401 invalid_endpoint.endpoint = "";
402 auto endpoint_validation = invalid_endpoint.validate();
403 EXPECT_TRUE(endpoint_validation.is_err());
404
405 // Invalid timeout (zero)
406 otlp_grpc_config invalid_timeout;
407 invalid_timeout.endpoint = "localhost:4317";
408 invalid_timeout.timeout = std::chrono::milliseconds(0);
409 auto timeout_validation = invalid_timeout.validate();
410 EXPECT_TRUE(timeout_validation.is_err());
411
412 // Invalid batch size (zero)
413 otlp_grpc_config invalid_batch;
414 invalid_batch.endpoint = "localhost:4317";
415 invalid_batch.max_batch_size = 0;
416 auto batch_validation = invalid_batch.validate();
417 EXPECT_TRUE(batch_validation.is_err());
418}
419
420TEST_F(OtlpGrpcExporterTest, SpanConverterBasic) {
421 // Test span conversion to OTLP format
423 test_spans_,
424 "test_service",
425 "1.0.0",
426 {{"environment", "test"}});
427
428 // Verify payload is non-empty
429 EXPECT_GT(payload.size(), 0u);
430
431 // Verify protobuf wire format structure
432 // First byte should be 0x0A (field 1, length-delimited)
433 EXPECT_EQ(payload[0], 0x0A);
434}
435
436TEST_F(OtlpGrpcExporterTest, SpanConverterEmptySpans) {
437 std::vector<trace_span> empty_spans;
438
440 empty_spans,
441 "test_service",
442 "1.0.0",
443 {});
444
445 // Even with no spans, should have resource data
446 EXPECT_GT(payload.size(), 0u);
447}
448
449TEST_F(OtlpGrpcExporterTest, ExporterWithStubTransport) {
450 otlp_grpc_config config;
451 config.endpoint = "localhost:4317";
452 config.service_name = "test_service";
453 config.service_version = "1.0.0";
454
455 // Create exporter with stub transport for testing
456 auto stub_transport = create_stub_grpc_transport();
457 auto* stub_ptr = stub_transport.get();
458
459 otlp_grpc_exporter exporter(config, std::move(stub_transport));
460
461 // Start exporter (connects to stub)
462 auto start_result = exporter.start();
463 EXPECT_TRUE(start_result.is_ok());
464 EXPECT_TRUE(exporter.is_running());
465
466 // Export spans
467 auto export_result = exporter.export_spans(test_spans_);
468 EXPECT_TRUE(export_result.is_ok());
469
470 // Check stats
471 auto stats = exporter.get_stats();
472 EXPECT_EQ(stats["exported_spans"], test_spans_.size());
473 EXPECT_EQ(stats["dropped_spans"], 0u);
474 EXPECT_EQ(stats["failed_exports"], 0u);
475
476 // Check transport statistics
477 auto transport_stats = stub_ptr->get_statistics();
478 EXPECT_EQ(transport_stats.requests_sent, 1u);
479 EXPECT_GT(transport_stats.bytes_sent, 0u);
480
481 // Shutdown
482 auto shutdown_result = exporter.shutdown();
483 EXPECT_TRUE(shutdown_result.is_ok());
484 EXPECT_FALSE(exporter.is_running());
485}
486
487TEST_F(OtlpGrpcExporterTest, ExporterFailedConnection) {
488 otlp_grpc_config config;
489 config.endpoint = "localhost:4317";
490
491 // Create stub transport that simulates failure
492 auto stub_transport = create_stub_grpc_transport();
493 stub_transport->set_simulate_success(false);
494
495 otlp_grpc_exporter exporter(config, std::move(stub_transport));
496
497 // Start should fail due to connection failure
498 auto start_result = exporter.start();
499 EXPECT_TRUE(start_result.is_err());
500}
501
502TEST_F(OtlpGrpcExporterTest, ExporterRetryBehavior) {
503 otlp_grpc_config config;
504 config.endpoint = "localhost:4317";
505 config.max_retry_attempts = 3;
506 config.initial_backoff = std::chrono::milliseconds(10);
507
508 // Track call count
509 int call_count = 0;
510
511 auto stub_transport = create_stub_grpc_transport();
512 stub_transport->set_response_handler([&call_count](const grpc_request&) {
513 call_count++;
514 grpc_response response;
515 if (call_count < 3) {
516 // Simulate UNAVAILABLE error (retryable)
517 response.status_code = 14;
518 response.status_message = "Service unavailable";
519 } else {
520 // Success on third attempt
521 response.status_code = 0;
522 response.status_message = "OK";
523 }
524 return response;
525 });
526
527 otlp_grpc_exporter exporter(config, std::move(stub_transport));
528
529 auto start_result = exporter.start();
530 EXPECT_TRUE(start_result.is_ok());
531
532 auto export_result = exporter.export_spans(test_spans_);
533 EXPECT_TRUE(export_result.is_ok());
534
535 // Should have retried twice before success
536 EXPECT_EQ(call_count, 3);
537
538 auto stats = exporter.get_stats();
539 EXPECT_EQ(stats["retries"], 2u);
540 EXPECT_EQ(stats["exported_spans"], test_spans_.size());
541}
542
543TEST_F(OtlpGrpcExporterTest, ExporterDetailedStats) {
544 otlp_grpc_config config;
545 config.endpoint = "localhost:4317";
546
547 auto stub_transport = create_stub_grpc_transport();
548 // Set response handler to simulate realistic export time
549 stub_transport->set_response_handler([](const grpc_request&) {
550 // Simulate a small delay to ensure measurable export time
551 std::this_thread::sleep_for(std::chrono::microseconds(100));
552 grpc_response response;
553 response.status_code = 0; // OK
554 response.status_message = "OK";
555 return response;
556 });
557 otlp_grpc_exporter exporter(config, std::move(stub_transport));
558
559 auto start_result = exporter.start();
560 EXPECT_TRUE(start_result.is_ok());
561
562 // Export multiple batches
563 for (int i = 0; i < 3; ++i) {
564 auto result = exporter.export_spans(test_spans_);
565 EXPECT_TRUE(result.is_ok());
566 }
567
568 auto detailed_stats = exporter.get_detailed_stats();
569 EXPECT_EQ(detailed_stats.spans_exported, test_spans_.size() * 3);
570 EXPECT_EQ(detailed_stats.spans_dropped, 0u);
571 EXPECT_EQ(detailed_stats.export_failures, 0u);
572 EXPECT_GT(detailed_stats.total_export_time.count(), 0);
573}
574
575TEST_F(OtlpGrpcExporterTest, FactoryFunctions) {
576 // Test default factory
577 auto exporter1 = create_otlp_grpc_exporter();
578 EXPECT_TRUE(exporter1 != nullptr);
579 EXPECT_EQ(exporter1->config().endpoint, "localhost:4317");
580
581 // Test factory with endpoint
582 auto exporter2 = create_otlp_grpc_exporter("collector:4317");
583 EXPECT_TRUE(exporter2 != nullptr);
584 EXPECT_EQ(exporter2->config().endpoint, "collector:4317");
585
586 // Test factory with config
587 otlp_grpc_config config;
588 config.endpoint = "otlp.example.com:443";
589 config.use_tls = true;
590 config.service_name = "my_service";
591
592 auto exporter3 = create_otlp_grpc_exporter(config);
593 EXPECT_TRUE(exporter3 != nullptr);
594 EXPECT_EQ(exporter3->config().endpoint, "otlp.example.com:443");
595 EXPECT_TRUE(exporter3->config().use_tls);
596 EXPECT_EQ(exporter3->config().service_name, "my_service");
597}
598
599TEST_F(OtlpGrpcExporterTest, ExportEmptySpans) {
600 otlp_grpc_config config;
601 config.endpoint = "localhost:4317";
602
603 auto stub_transport = create_stub_grpc_transport();
604 otlp_grpc_exporter exporter(config, std::move(stub_transport));
605
606 auto start_result = exporter.start();
607 EXPECT_TRUE(start_result.is_ok());
608
609 // Export empty vector should succeed without sending
610 std::vector<trace_span> empty_spans;
611 auto export_result = exporter.export_spans(empty_spans);
612 EXPECT_TRUE(export_result.is_ok());
613
614 auto stats = exporter.get_stats();
615 EXPECT_EQ(stats["exported_spans"], 0u);
616}
std::vector< trace_span > create_test_spans()
std::vector< trace_span > test_spans_
Jaeger trace exporter implementation.
std::unordered_map< std::string, std::size_t > get_stats() const override
Get exporter statistics.
common::VoidResult flush() override
Flush any pending spans.
jaeger_span_data convert_span(const trace_span &span) const
Convert internal span to Jaeger format.
common::VoidResult shutdown() override
Shutdown the exporter.
common::VoidResult export_spans(const std::vector< trace_span > &spans) override
Export a batch of spans.
OpenTelemetry Protocol (OTLP) trace exporter implementation.
common::VoidResult shutdown() override
Shutdown the exporter.
common::VoidResult flush() override
Flush any pending spans.
common::VoidResult export_spans(const std::vector< trace_span > &spans) override
Export a batch of spans.
std::unordered_map< std::string, std::size_t > get_stats() const override
Get exporter statistics.
common::VoidResult shutdown() override
Shutdown the exporter.
otlp_exporter_stats get_detailed_stats() const
Get detailed statistics.
common::VoidResult start()
Start the exporter.
bool is_running() const
Check if exporter is running.
std::unordered_map< std::string, std::size_t > get_stats() const override
Get exporter statistics.
common::VoidResult export_spans(const std::vector< trace_span > &spans) override
Export a batch of spans.
static std::vector< uint8_t > convert_to_otlp(const std::vector< trace_span > &spans, const std::string &service_name, const std::string &service_version, const std::unordered_map< std::string, std::string > &resource_attributes)
Convert spans to OTLP protobuf format.
static std::vector< trace_export_format > get_supported_formats(const std::string &backend)
Get supported formats for a specific backend.
static std::unique_ptr< trace_exporter_interface > create_exporter(const trace_export_config &config, const otel_resource &resource=create_service_resource("monitoring_system", "2.0.0"))
Create a trace exporter based on format.
Zipkin trace exporter implementation.
common::VoidResult export_spans(const std::vector< trace_span > &spans) override
Export a batch of spans.
std::unordered_map< std::string, std::size_t > get_stats() const override
Get exporter statistics.
common::VoidResult shutdown() override
Shutdown the exporter.
common::VoidResult flush() override
Flush any pending spans.
zipkin_span_data convert_span(const trace_span &span) const
Convert internal span to Zipkin format.
std::unique_ptr< stub_grpc_transport > create_stub_grpc_transport()
Create stub gRPC transport for testing.
std::unique_ptr< zipkin_exporter > create_zipkin_exporter(const std::string &endpoint, trace_export_format format=trace_export_format::zipkin_json)
Helper function to create a Zipkin exporter.
std::unique_ptr< otlp_grpc_exporter > create_otlp_grpc_exporter(const std::string &endpoint="localhost:4317")
Create OTLP gRPC exporter with default configuration.
otel_resource create_service_resource(const std::string &service_name, const std::string &service_version="1.0.0", const std::string &service_namespace="")
Create OpenTelemetry resource with service information.
std::unique_ptr< otlp_exporter > create_otlp_exporter(const std::string &endpoint, const otel_resource &resource, trace_export_format format=trace_export_format::otlp_grpc)
Helper function to create an OTLP exporter.
std::unique_ptr< jaeger_exporter > create_jaeger_exporter(const std::string &endpoint, trace_export_format format=trace_export_format::jaeger_grpc)
Helper function to create a Jaeger exporter.
OpenTelemetry compatibility layer for monitoring system integration.
OTLP gRPC trace exporter implementation.
gRPC request configuration
OpenTelemetry resource representation.
Configuration for OTLP gRPC exporter.
std::string service_version
Service version.
std::string endpoint
OTLP receiver endpoint.
std::size_t max_retry_attempts
Maximum retry attempts.
common::VoidResult validate() const
Validate configuration.
std::size_t max_batch_size
Maximum spans per batch.
std::chrono::milliseconds initial_backoff
Initial retry backoff.
std::chrono::milliseconds timeout
Request timeout.
Configuration for trace exporters.
std::chrono::milliseconds timeout
Request timeout.
std::size_t max_queue_size
Maximum queued spans.
std::optional< std::string > service_name
Override service name.
common::VoidResult validate() const
Validate export configuration.
std::size_t max_batch_size
Maximum spans per batch.
Trace span representing a unit of work in distributed tracing.
std::unordered_map< std::string, std::string > tags
std::chrono::system_clock::time_point end_time
std::chrono::system_clock::time_point start_time
TEST_F(TraceExportersTest, TraceExportConfigValidation)
Trace data exporters for various distributed tracing systems.