@@ -507,7 +507,12 @@ impl InstrumentationLibrary {
507
507
508
508
/// Create a new builder to create an [InstrumentationLibrary]
509
509
pub fn builder ( name : impl Into < Cow < ' static , str > > ) -> InstrumentationLibraryBuilder {
510
- InstrumentationLibraryBuilder :: new ( name)
510
+ InstrumentationLibraryBuilder {
511
+ name : name. into ( ) ,
512
+ version : None ,
513
+ schema_url : None ,
514
+ attributes : None ,
515
+ }
511
516
}
512
517
}
513
518
@@ -534,30 +539,49 @@ pub struct InstrumentationLibraryBuilder {
534
539
}
535
540
536
541
impl InstrumentationLibraryBuilder {
537
- pub fn new ( name : impl Into < Cow < ' static , str > > ) -> Self {
538
- InstrumentationLibraryBuilder {
539
- name : name . into ( ) ,
540
- version : None ,
541
- schema_url : None ,
542
- attributes : None ,
543
- }
544
- }
545
-
542
+ /// Configure the version for the instrumentation library
543
+ ///
544
+ /// # Examples
545
+ ///
546
+ /// ```
547
+ /// let library = opentelemetry::InstrumentationLibrary::builder()
548
+ /// .with_version("v0.1.0")
549
+ /// .build();
550
+ /// ```
546
551
pub fn with_version ( mut self , version : impl Into < Cow < ' static , str > > ) -> Self {
547
552
self . version = Some ( version. into ( ) ) ;
548
553
self
549
554
}
550
555
556
+ /// Configure the Schema URL for the instrumentation library
557
+ ///
558
+ /// # Examples
559
+ ///
560
+ /// ```
561
+ /// let library = opentelemetry::InstrumentationLibrary::builder()
562
+ /// .with_schema_url("https://opentelemetry.io/schemas/1.17.0")
563
+ /// .build();
564
+ /// ```
551
565
pub fn with_schema_url ( mut self , schema_url : impl Into < Cow < ' static , str > > ) -> Self {
552
566
self . schema_url = Some ( schema_url. into ( ) ) ;
553
567
self
554
568
}
555
569
570
+ /// Configure the attributes for the instrumentation library
571
+ ///
572
+ /// # Examples
573
+ ///
574
+ /// ```
575
+ /// let library = opentelemetry::InstrumentationLibrary::builder()
576
+ /// .with_attributes(vec![KeyValue::new("k", "v"))
577
+ /// .build();
578
+ /// ```
556
579
pub fn with_attributes ( mut self , attributes : impl Into < Vec < KeyValue > > ) -> Self {
557
580
self . attributes = Some ( attributes. into ( ) ) ;
558
581
self
559
582
}
560
583
584
+ /// Create a new [InstrumentationLibrary] from this configuration
561
585
pub fn build ( self ) -> InstrumentationLibrary {
562
586
InstrumentationLibrary {
563
587
name : self . name ,
0 commit comments