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
//! Provides instrumentation information for both tracing and metric.
//! See `OTEPS-0083` for details.
//!
//! [OTEPS-0083](https://github.com/open-telemetry/oteps/blob/master/text/0083-component.md)

use std::borrow::Cow;

/// InstrumentationLibrary contains information about instrumentation library.
///
/// See `Instrumentation Libraries` for more information.
///
/// [`Instrumentation Libraries`](https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/overview.md#instrumentation-libraries)
#[derive(Debug, Default, Hash, Clone, PartialEq, Eq)]
#[non_exhaustive]
pub struct InstrumentationLibrary {
    /// instrumentation library name, cannot be empty
    pub name: Cow<'static, str>,
    /// instrumentation library version, can be empty
    pub version: Option<Cow<'static, str>>,
}

impl InstrumentationLibrary {
    /// Create an InstrumentationLibrary from name and version.
    pub fn new<T>(name: T, version: Option<T>) -> InstrumentationLibrary
    where
        T: Into<Cow<'static, str>>,
    {
        InstrumentationLibrary {
            name: name.into(),
            version: version.map(Into::into),
        }
    }
}