Skip to content

Commit 979df69

Browse files
committed
Docs
1 parent a3a62af commit 979df69

File tree

2 files changed

+35
-11
lines changed

2 files changed

+35
-11
lines changed

opentelemetry/src/common.rs

+34-10
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,12 @@ impl InstrumentationLibrary {
507507

508508
/// Create a new builder to create an [InstrumentationLibrary]
509509
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+
}
511516
}
512517
}
513518

@@ -534,30 +539,49 @@ pub struct InstrumentationLibraryBuilder {
534539
}
535540

536541
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+
/// ```
546551
pub fn with_version(mut self, version: impl Into<Cow<'static, str>>) -> Self {
547552
self.version = Some(version.into());
548553
self
549554
}
550555

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+
/// ```
551565
pub fn with_schema_url(mut self, schema_url: impl Into<Cow<'static, str>>) -> Self {
552566
self.schema_url = Some(schema_url.into());
553567
self
554568
}
555569

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+
/// ```
556579
pub fn with_attributes(mut self, attributes: impl Into<Vec<KeyValue>>) -> Self {
557580
self.attributes = Some(attributes.into());
558581
self
559582
}
560583

584+
/// Create a new [InstrumentationLibrary] from this configuration
561585
pub fn build(self) -> InstrumentationLibrary {
562586
InstrumentationLibrary {
563587
name: self.name,

opentelemetry/src/trace/tracer_provider.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ pub trait TracerProvider {
115115
fn tracer_builder(&self, name: impl Into<Cow<'static, str>>) -> TracerBuilder<'_, Self> {
116116
TracerBuilder {
117117
provider: self,
118-
library_builder: InstrumentationLibraryBuilder::new(name),
118+
library_builder: InstrumentationLibrary::builder(name),
119119
}
120120
}
121121

0 commit comments

Comments
 (0)