Skip to content

Commit 027c1f8

Browse files
authored
fix(sdk): meter_with_version should accept optional parameter for optional parameters. (#752)
1 parent 087fd80 commit 027c1f8

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

opentelemetry-api/src/global/metrics.rs

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,16 +61,28 @@ pub fn meter_provider() -> GlobalMeterProvider {
6161
///
6262
/// If the name is an empty string, the provider will use a default name.
6363
///
64-
/// This is a more convenient way of expressing `global::meter_provider().meter(name)`.
64+
/// This is a more convenient way of expressing `global::meter_provider().meter(name, None, None)`.
6565
pub fn meter(name: &'static str) -> Meter {
6666
meter_provider().meter(name, None, None)
6767
}
6868

69-
/// Creates a [`Meter`] with the name and version.
69+
/// Creates a [`Meter`] with the name, version and schema url.
70+
///
71+
/// - name SHOULD uniquely identify the instrumentation scope, such as the instrumentation library (e.g. io.opentelemetry.contrib.mongodb), package, module or class name.
72+
/// - version specifies the version of the instrumentation scope if the scope has a version
73+
/// - schema url specifies the Schema URL that should be recorded in the emitted telemetry.
74+
///
75+
/// This is a convenient way of `global::meter_provider().meter(...)`
76+
/// # Example
77+
/// ```rust
78+
/// use opentelemetry_api::global::meter_with_version;
79+
/// let meter = meter_with_version("io.opentelemetry", Some("0.17"), Some("https://opentelemetry.io/schemas/1.2.0"));
80+
/// ```
81+
///
7082
pub fn meter_with_version(
7183
name: &'static str,
72-
version: &'static str,
73-
schema_url: &'static str,
84+
version: Option<&'static str>,
85+
schema_url: Option<&'static str>,
7486
) -> Meter {
75-
meter_provider().meter(name, Some(version), Some(schema_url))
87+
meter_provider().meter(name, version, schema_url)
7688
}

0 commit comments

Comments
 (0)