opentelemetry_spanprocessor_any/sdk/instrumentation.rs
1//! Provides instrumentation information for both tracing and metric.
2//! See `OTEPS-0083` for details.
3//!
4//! [OTEPS-0083](https://github.com/open-telemetry/oteps/blob/master/text/0083-component.md)
5
6use std::borrow::Cow;
7
8/// InstrumentationLibrary contains information about instrumentation library.
9///
10/// See `Instrumentation Libraries` for more information.
11///
12/// [`Instrumentation Libraries`](https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/overview.md#instrumentation-libraries)
13#[derive(Debug, Default, Hash, Clone, PartialEq, Eq)]
14#[non_exhaustive]
15pub struct InstrumentationLibrary {
16 /// instrumentation library name, cannot be empty
17 pub name: Cow<'static, str>,
18 /// instrumentation library version, can be empty
19 pub version: Option<Cow<'static, str>>,
20}
21
22impl InstrumentationLibrary {
23 /// Create an InstrumentationLibrary from name and version.
24 pub fn new<T>(name: T, version: Option<T>) -> InstrumentationLibrary
25 where
26 T: Into<Cow<'static, str>>,
27 {
28 InstrumentationLibrary {
29 name: name.into(),
30 version: version.map(Into::into),
31 }
32 }
33}