-
Notifications
You must be signed in to change notification settings - Fork 79
Expand file tree
/
Copy pathlib.rs
More file actions
762 lines (721 loc) · 29.8 KB
/
lib.rs
File metadata and controls
762 lines (721 loc) · 29.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
// SPDX-License-Identifier: Apache-2.0
//! This crate provides the "emit" library for emitting OTLP signals generated from registries.
use metrics::emit_metrics_for_registry;
use miette::Diagnostic;
use opentelemetry::global;
use opentelemetry_otlp::{ExporterBuildError, MetricExporter, WithExportConfig};
use opentelemetry_sdk::metrics::SdkMeterProvider;
use opentelemetry_sdk::Resource;
use opentelemetry_sdk::{metrics::PeriodicReader, trace::SdkTracerProvider};
use serde::Serialize;
use spans::emit_trace_for_registry;
use weaver_common::diagnostic::{DiagnosticMessage, DiagnosticMessages};
use weaver_forge::registry::ResolvedRegistry;
use weaver_forge::v2::registry::ForgeResolvedRegistry;
use crate::logs::{emit_logs_for_registry, emit_logs_for_registry_v2};
use crate::metrics::emit_metrics_for_registry_v2;
use crate::spans::emit_trace_for_registry_v2;
pub mod attributes;
pub mod logs;
pub mod metrics;
pub mod spans;
/// The default OTLP endpoint.
pub const DEFAULT_OTLP_ENDPOINT: &str = "http://localhost:4317";
const WEAVER_SERVICE_NAME: &str = "weaver";
/// An error that can occur while emitting a semantic convention registry.
#[derive(thiserror::Error, Debug, Clone, PartialEq, Serialize, Diagnostic)]
#[non_exhaustive]
pub enum Error {
/// Generic emit error.
#[error("Fatal error during emit. {error}")]
EmitError {
/// The error that occurred.
error: String,
},
/// Tracer provider error.
#[error("Tracer provider error. Check your Otel configuration. {error}")]
TracerProviderError {
/// The error that occurred.
error: String,
},
/// Metric provider error.
#[error("Metric provider error. Check your Otel configuration. {error}")]
MetricProviderError {
/// The error that occurred.
error: String,
},
/// Log provider error.
#[error("Log provider error. Check your Otel configuration. {error}")]
LogProviderError {
/// The error that occurred.
error: String,
},
}
impl From<Error> for DiagnosticMessages {
fn from(error: Error) -> Self {
DiagnosticMessages::new(vec![DiagnosticMessage::new(error)])
}
}
/// Initialise a grpc OTLP exporter, sends to by default http://localhost:4317
/// but can be overridden with the standard OTEL_EXPORTER_OTLP_ENDPOINT env var.
fn init_tracer_provider(endpoint: &String) -> Result<SdkTracerProvider, ExporterBuildError> {
let exporter = opentelemetry_otlp::SpanExporter::builder()
.with_tonic()
.with_endpoint(endpoint)
.build()?;
Ok(SdkTracerProvider::builder()
.with_resource(
Resource::builder()
.with_service_name(WEAVER_SERVICE_NAME)
.build(),
)
.with_batch_exporter(exporter)
.build())
}
/// Initialise a stdout exporter for debug
fn init_stdout_tracer_provider() -> SdkTracerProvider {
SdkTracerProvider::builder()
.with_resource(
Resource::builder()
.with_service_name(WEAVER_SERVICE_NAME)
.build(),
)
.with_simple_exporter(opentelemetry_stdout::SpanExporter::default())
.build()
}
/// Initialise a grpc OTLP exporter for metrics, sends to by default http://localhost:4317
/// but can be overridden with the standard OTEL_EXPORTER_OTLP_ENDPOINT env var.
fn init_meter_provider(endpoint: &String) -> Result<SdkMeterProvider, ExporterBuildError> {
let resource = Resource::builder()
.with_service_name(WEAVER_SERVICE_NAME)
.build();
let exporter = MetricExporter::builder()
.with_tonic()
.with_endpoint(endpoint)
.build()?;
let reader = PeriodicReader::builder(exporter).build();
Ok(SdkMeterProvider::builder()
.with_resource(resource)
.with_reader(reader)
.build())
}
/// Initialise a stdout exporter for debug
fn init_stdout_meter_provider() -> SdkMeterProvider {
let resource = Resource::builder()
.with_service_name(WEAVER_SERVICE_NAME)
.build();
let exporter = opentelemetry_stdout::MetricExporter::default();
let reader = PeriodicReader::builder(exporter).build();
SdkMeterProvider::builder()
.with_resource(resource)
.with_reader(reader)
.build()
}
/// Initialise a grpc OTLP exporter for logs, sends to by default http://localhost:4317
/// but can be overridden with the standard OTEL_EXPORTER_OTLP_ENDPOINT env var.
fn init_logger_provider(
endpoint: &String,
) -> Result<opentelemetry_sdk::logs::SdkLoggerProvider, ExporterBuildError> {
let resource = Resource::builder()
.with_service_name(WEAVER_SERVICE_NAME)
.build();
let exporter = opentelemetry_otlp::LogExporter::builder()
.with_tonic()
.with_endpoint(endpoint)
.build()?;
Ok(opentelemetry_sdk::logs::SdkLoggerProvider::builder()
.with_resource(resource)
.with_batch_exporter(exporter)
.build())
}
/// Initialise a stdout exporter for debug
fn init_stdout_logger_provider() -> opentelemetry_sdk::logs::SdkLoggerProvider {
let resource = Resource::builder()
.with_service_name(WEAVER_SERVICE_NAME)
.build();
opentelemetry_sdk::logs::SdkLoggerProvider::builder()
.with_resource(resource)
.with_simple_exporter(opentelemetry_stdout::LogExporter::default())
.build()
}
/// The configuration for the tracer provider.
#[derive(Debug)]
pub enum ExporterConfig {
/// Emit to stdout.
Stdout,
/// Emit to OTLP.
Otlp {
/// The endpoint to emit to.
endpoint: String,
},
}
/// Enum for the registry: ResolvedRegistry or ForgeResolvedRegistry
#[derive(Debug)]
pub enum RegistryVersion<'a> {
/// v1 ResolvedRegistry
V1(&'a ResolvedRegistry),
/// v2 ForgeResolvedRegistry
V2(&'a ForgeResolvedRegistry),
}
/// Emit the signals from the registry to the configured exporter.
pub fn emit(
registry: RegistryVersion<'_>,
registry_path: &str,
exporter_config: &ExporterConfig,
) -> Result<(), Error> {
let rt = tokio::runtime::Runtime::new().map_err(|e| Error::EmitError {
error: e.to_string(),
})?;
rt.block_on(async {
// Emit spans
let tracer_provider = match exporter_config {
ExporterConfig::Stdout => init_stdout_tracer_provider(),
ExporterConfig::Otlp { endpoint } => {
init_tracer_provider(endpoint).map_err(|e| Error::TracerProviderError {
error: e.to_string(),
})?
}
};
global::set_tracer_provider(tracer_provider.clone());
match registry {
RegistryVersion::V1(reg) => emit_trace_for_registry(reg, registry_path),
RegistryVersion::V2(reg) => emit_trace_for_registry_v2(reg, registry_path),
}
tracer_provider
.force_flush()
.map_err(|e| Error::TracerProviderError {
error: e.to_string(),
})?;
// Emit metrics
let meter_provider = match exporter_config {
ExporterConfig::Stdout => init_stdout_meter_provider(),
ExporterConfig::Otlp { endpoint } => {
init_meter_provider(endpoint).map_err(|e| Error::MetricProviderError {
error: e.to_string(),
})?
}
};
global::set_meter_provider(meter_provider.clone());
match registry {
RegistryVersion::V1(reg) => emit_metrics_for_registry(reg),
RegistryVersion::V2(reg) => emit_metrics_for_registry_v2(reg),
}
meter_provider
.shutdown()
.map_err(|e| Error::MetricProviderError {
error: e.to_string(),
})?;
// Emit logs
let logger_provider = match exporter_config {
ExporterConfig::Stdout => init_stdout_logger_provider(),
ExporterConfig::Otlp { endpoint } => {
init_logger_provider(endpoint).map_err(|e| Error::LogProviderError {
error: e.to_string(),
})?
}
};
match registry {
RegistryVersion::V1(reg) => emit_logs_for_registry(reg, &logger_provider),
RegistryVersion::V2(reg) => emit_logs_for_registry_v2(reg, &logger_provider),
}
logger_provider
.shutdown()
.map_err(|e| Error::LogProviderError {
error: e.to_string(),
})?;
Ok(())
})
}
#[cfg(test)]
mod tests {
use super::*;
use weaver_forge::registry::{ResolvedGroup, ResolvedRegistry};
use weaver_resolved_schema::attribute::Attribute;
use weaver_semconv::{
attribute::{
AttributeType, BasicRequirementLevelSpec, Examples, PrimitiveOrArrayTypeSpec,
RequirementLevel,
},
group::{GroupType, InstrumentSpec, SpanKindSpec},
stability::Stability,
};
// Test the emit command for stdout
#[test]
fn test_emit_stdout() {
let registry = ResolvedRegistry {
registry_url: "TEST".to_owned(),
groups: vec![
ResolvedGroup {
id: "test.comprehensive.internal".to_owned(),
r#type: GroupType::Span,
brief: "".to_owned(),
note: "".to_owned(),
prefix: "".to_owned(),
extends: None,
stability: Some(Stability::Stable),
deprecated: None,
attributes: vec![Attribute {
name: "test.string".to_owned(),
r#type: AttributeType::PrimitiveOrArray(PrimitiveOrArrayTypeSpec::String),
examples: Some(Examples::Strings(vec![
"value1".to_owned(),
"value2".to_owned(),
])),
brief: "".to_owned(),
tag: None,
requirement_level: RequirementLevel::Recommended {
text: "".to_owned(),
},
sampling_relevant: None,
note: "".to_owned(),
stability: Some(Stability::Stable),
deprecated: None,
prefix: false,
tags: None,
value: None,
annotations: None,
role: Default::default(),
}],
span_kind: Some(SpanKindSpec::Internal),
events: vec![],
metric_name: None,
instrument: None,
unit: None,
metric_requirement_level: None,
name: None,
lineage: None,
display_name: None,
body: None,
entity_associations: vec![],
annotations: None,
},
ResolvedGroup {
id: "test.updowncounter".to_owned(),
r#type: GroupType::Metric,
brief: "test.updowncounter".to_owned(),
note: "".to_owned(),
prefix: "".to_owned(),
entity_associations: vec![],
extends: None,
stability: Some(Stability::Development),
deprecated: None,
attributes: vec![],
span_kind: None,
events: vec![],
metric_name: Some("test.updowncounter".to_owned()),
instrument: Some(InstrumentSpec::UpDownCounter),
unit: Some("1".to_owned()),
metric_requirement_level: Some(BasicRequirementLevelSpec::Recommended),
name: None,
lineage: None,
display_name: None,
body: None,
annotations: None,
},
ResolvedGroup {
id: "test.counter".to_owned(),
r#type: GroupType::Metric,
brief: "test.counter".to_owned(),
note: "".to_owned(),
prefix: "".to_owned(),
entity_associations: vec![],
extends: None,
stability: Some(Stability::Development),
deprecated: None,
attributes: vec![],
span_kind: None,
events: vec![],
metric_name: Some("test.counter".to_owned()),
instrument: Some(InstrumentSpec::Counter),
unit: Some("1".to_owned()),
metric_requirement_level: Some(BasicRequirementLevelSpec::Recommended),
name: None,
lineage: None,
display_name: None,
body: None,
annotations: None,
},
ResolvedGroup {
id: "test.gauge".to_owned(),
r#type: GroupType::Metric,
brief: "test.gauge".to_owned(),
note: "".to_owned(),
prefix: "".to_owned(),
entity_associations: vec![],
extends: None,
stability: Some(Stability::Development),
deprecated: None,
attributes: vec![],
span_kind: None,
events: vec![],
metric_name: Some("test.gauge".to_owned()),
instrument: Some(InstrumentSpec::Gauge),
unit: Some("1".to_owned()),
metric_requirement_level: Some(BasicRequirementLevelSpec::Recommended),
name: None,
lineage: None,
display_name: None,
body: None,
annotations: None,
},
ResolvedGroup {
id: "test.histogram".to_owned(),
r#type: GroupType::Metric,
brief: "test.histogram".to_owned(),
note: "".to_owned(),
prefix: "".to_owned(),
entity_associations: vec![],
extends: None,
stability: Some(Stability::Development),
deprecated: None,
attributes: vec![],
span_kind: None,
events: vec![],
metric_name: Some("test.histogram".to_owned()),
instrument: Some(InstrumentSpec::Histogram),
unit: Some("1".to_owned()),
metric_requirement_level: Some(BasicRequirementLevelSpec::Recommended),
name: None,
lineage: None,
display_name: None,
body: None,
annotations: None,
},
ResolvedGroup {
id: "test.updowncounter.double".to_owned(),
r#type: GroupType::Metric,
brief: "test.updowncounter.double".to_owned(),
note: "".to_owned(),
prefix: "".to_owned(),
entity_associations: vec![],
extends: None,
stability: Some(Stability::Development),
deprecated: None,
attributes: vec![],
span_kind: None,
events: vec![],
metric_name: Some("test.updowncounter.double".to_owned()),
instrument: Some(InstrumentSpec::UpDownCounter),
unit: Some("1".to_owned()),
name: None,
metric_requirement_level: Some(BasicRequirementLevelSpec::Recommended),
lineage: None,
display_name: None,
body: None,
annotations: None,
},
ResolvedGroup {
id: "test.counter.double".to_owned(),
r#type: GroupType::Metric,
brief: "test.counter.double".to_owned(),
note: "".to_owned(),
prefix: "".to_owned(),
entity_associations: vec![],
extends: None,
stability: Some(Stability::Development),
deprecated: None,
attributes: vec![],
span_kind: None,
events: vec![],
metric_name: Some("test.counter.double".to_owned()),
instrument: Some(InstrumentSpec::Counter),
unit: Some("1".to_owned()),
metric_requirement_level: Some(BasicRequirementLevelSpec::Recommended),
name: None,
lineage: None,
display_name: None,
body: None,
annotations: None,
},
ResolvedGroup {
id: "test.gauge.double".to_owned(),
r#type: GroupType::Metric,
brief: "test.gauge.double".to_owned(),
note: "".to_owned(),
prefix: "".to_owned(),
entity_associations: vec![],
extends: None,
stability: Some(Stability::Development),
deprecated: None,
attributes: vec![],
span_kind: None,
events: vec![],
metric_name: Some("test.gauge.double".to_owned()),
instrument: Some(InstrumentSpec::Gauge),
unit: Some("1".to_owned()),
metric_requirement_level: Some(BasicRequirementLevelSpec::Recommended),
name: None,
lineage: None,
display_name: None,
body: None,
annotations: None,
},
ResolvedGroup {
id: "test.histogram.double".to_owned(),
r#type: GroupType::Metric,
brief: "test.histogram.double".to_owned(),
note: "".to_owned(),
prefix: "".to_owned(),
entity_associations: vec![],
extends: None,
stability: Some(Stability::Development),
deprecated: None,
attributes: vec![],
span_kind: None,
events: vec![],
metric_name: Some("test.histogram.double".to_owned()),
instrument: Some(InstrumentSpec::Histogram),
unit: Some("1".to_owned()),
metric_requirement_level: Some(BasicRequirementLevelSpec::Recommended),
name: None,
lineage: None,
display_name: None,
body: None,
annotations: None,
},
ResolvedGroup {
id: "event.session.start".to_owned(),
r#type: GroupType::Event,
brief: "This event represents a session start".to_owned(),
note: "".to_owned(),
prefix: "".to_owned(),
entity_associations: vec![],
extends: None,
stability: Some(Stability::Stable),
deprecated: None,
attributes: vec![Attribute {
name: "session.id".to_owned(),
r#type: AttributeType::PrimitiveOrArray(PrimitiveOrArrayTypeSpec::String),
examples: Some(Examples::Strings(vec![
"00112233-4455-6677-8899-aabbccddeeff".to_owned(),
])),
brief: "A unique session identifier".to_owned(),
tag: None,
requirement_level: RequirementLevel::Recommended {
text: "".to_owned(),
},
sampling_relevant: None,
note: "".to_owned(),
stability: Some(Stability::Stable),
deprecated: None,
prefix: false,
tags: None,
value: None,
annotations: None,
role: Default::default(),
}],
span_kind: None,
events: vec![],
metric_name: None,
instrument: None,
unit: None,
metric_requirement_level: None,
name: Some("session.start".to_owned()),
lineage: None,
display_name: Some("Session Start Event".to_owned()),
body: None,
annotations: None,
},
],
};
let result = emit(
RegistryVersion::V1(®istry),
"TEST",
&ExporterConfig::Stdout,
);
assert!(result.is_ok());
}
#[test]
fn test_emit_otlp_invalid_endpoint() {
let registry = ResolvedRegistry {
registry_url: "TEST_OTLP_INVALID".to_owned(),
groups: vec![],
};
let result = emit(
RegistryVersion::V1(®istry),
"TEST_OTLP_INVALID",
&ExporterConfig::Otlp {
endpoint: "http:/invalid-endpoint:4317".to_owned(),
},
);
assert!(result.is_err());
// Check the error converts to a diagnostic message
let diagnostic_messages = DiagnosticMessages::from(result.unwrap_err());
assert_eq!(diagnostic_messages.len(), 1);
}
#[test]
fn test_emit_stdout_v2() {
use std::collections::BTreeMap;
use weaver_forge::v2::{
attribute::Attribute as V2Attribute,
event::{Event, EventAttribute},
metric::Metric,
registry::{ForgeResolvedRegistry, Refinements, Registry},
span::{Span, SpanAttribute},
};
use weaver_semconv::{
attribute::{
AttributeType, BasicRequirementLevelSpec, Examples, PrimitiveOrArrayTypeSpec,
RequirementLevel,
},
group::{InstrumentSpec, SpanKindSpec},
stability::Stability,
v2::{signal_id::SignalId, span::SpanName, CommonFields},
};
let registry = ForgeResolvedRegistry {
schema_url: "https://example.com/schemas/1.2.3".try_into().unwrap(),
registry: Registry {
attributes: vec![],
attribute_groups: vec![],
spans: vec![Span {
r#type: SignalId::from("test.comprehensive.internal".to_owned()),
kind: SpanKindSpec::Internal,
name: SpanName {
note: "test span".to_owned(),
},
attributes: vec![SpanAttribute {
base: V2Attribute {
key: "test.string".to_owned(),
r#type: AttributeType::PrimitiveOrArray(
PrimitiveOrArrayTypeSpec::String,
),
examples: Some(Examples::Strings(vec![
"value1".to_owned(),
"value2".to_owned(),
])),
common: CommonFields {
brief: "Test attribute".to_owned(),
note: String::new(),
stability: Stability::Stable,
deprecated: None,
annotations: BTreeMap::new(),
},
provenance: Default::default(),
},
requirement_level: RequirementLevel::Basic(
BasicRequirementLevelSpec::Recommended,
),
sampling_relevant: None,
}],
entity_associations: vec![],
common: CommonFields {
brief: "Test span".to_owned(),
note: String::new(),
stability: Stability::Stable,
deprecated: None,
annotations: BTreeMap::new(),
},
provenance: Default::default(),
}],
metrics: vec![
Metric {
name: SignalId::from("test.updowncounter".to_owned()),
instrument: InstrumentSpec::UpDownCounter,
unit: "1".to_owned(),
attributes: vec![],
entity_associations: vec![],
common: CommonFields {
brief: "test.updowncounter".to_owned(),
note: String::new(),
stability: Stability::Development,
deprecated: None,
annotations: BTreeMap::new(),
},
provenance: Default::default(),
},
Metric {
name: SignalId::from("test.counter".to_owned()),
instrument: InstrumentSpec::Counter,
unit: "1".to_owned(),
attributes: vec![],
entity_associations: vec![],
common: CommonFields {
brief: "test.counter".to_owned(),
note: String::new(),
stability: Stability::Development,
deprecated: None,
annotations: BTreeMap::new(),
},
provenance: Default::default(),
},
Metric {
name: SignalId::from("test.gauge".to_owned()),
instrument: InstrumentSpec::Gauge,
unit: "1".to_owned(),
attributes: vec![],
entity_associations: vec![],
common: CommonFields {
brief: "test.gauge".to_owned(),
note: String::new(),
stability: Stability::Development,
deprecated: None,
annotations: BTreeMap::new(),
},
provenance: Default::default(),
},
Metric {
name: SignalId::from("test.histogram".to_owned()),
instrument: InstrumentSpec::Histogram,
unit: "1".to_owned(),
attributes: vec![],
entity_associations: vec![],
common: CommonFields {
brief: "test.histogram".to_owned(),
note: String::new(),
stability: Stability::Development,
deprecated: None,
annotations: BTreeMap::new(),
},
provenance: Default::default(),
},
],
events: vec![Event {
name: SignalId::from("session.start".to_owned()),
attributes: vec![EventAttribute {
base: V2Attribute {
key: "session.id".to_owned(),
r#type: AttributeType::PrimitiveOrArray(
PrimitiveOrArrayTypeSpec::String,
),
examples: Some(Examples::Strings(vec![
"00112233-4455-6677-8899-aabbccddeeff".to_owned(),
])),
common: CommonFields {
brief: "A unique session identifier".to_owned(),
note: String::new(),
stability: Stability::Stable,
deprecated: None,
annotations: BTreeMap::new(),
},
provenance: Default::default(),
},
requirement_level: RequirementLevel::Basic(
BasicRequirementLevelSpec::Recommended,
),
}],
entity_associations: vec![],
common: CommonFields {
brief: "This event represents a session start".to_owned(),
note: String::new(),
stability: Stability::Stable,
deprecated: None,
annotations: BTreeMap::new(),
},
provenance: Default::default(),
}],
entities: vec![],
},
refinements: Refinements {
metrics: vec![],
spans: vec![],
events: vec![],
},
};
let result = emit(
RegistryVersion::V2(®istry),
"TEST_V2",
&ExporterConfig::Stdout,
);
assert!(result.is_ok());
}
}