Skip to content

Commit

Permalink
build: bump opentelemetry dependencies (#62)
Browse files Browse the repository at this point in the history
Signed-off-by: tison <[email protected]>
  • Loading branch information
tisonkun authored Sep 19, 2024
1 parent 8ebe7f3 commit d92d148
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -87,17 +87,17 @@ version = "0.7"
[dependencies.opentelemetry]
features = ["logs"]
optional = true
version = "0.24"
version = "0.25"

[dependencies.opentelemetry-otlp]
features = ["logs", "grpc-tonic", "http-json", "http-proto"]
optional = true
version = "0.17"
version = "0.25"

[dependencies.opentelemetry_sdk]
features = ["logs", "rt-tokio"]
optional = true
version = "0.24"
version = "0.25"

## Examples
[[example]]
Expand Down
18 changes: 14 additions & 4 deletions src/append/opentelemetry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,26 @@ impl OpentelemetryLogBuilder {
}

/// Add a label to the resource.
pub fn add_label(mut self, key: impl Into<Cow<'static, str>>, value: impl Into<Cow<'static, str>>) -> Self {
pub fn add_label(
mut self,
key: impl Into<Cow<'static, str>>,
value: impl Into<Cow<'static, str>>,
) -> Self {
self.labels.push((key.into(), value.into()));
self
}

/// Build the [`OpentelemetryLog`] appender.
pub fn build(self) -> Result<OpentelemetryLog, opentelemetry::logs::LogError> {
let OpentelemetryLogBuilder { name, endpoint, protocol, labels } = self;
let OpentelemetryLogBuilder {
name,
endpoint,
protocol,
labels,
} = self;

let collector_timeout = Duration::from_secs(opentelemetry_otlp::OTEL_EXPORTER_OTLP_TIMEOUT_DEFAULT);
let collector_timeout =
Duration::from_secs(opentelemetry_otlp::OTEL_EXPORTER_OTLP_TIMEOUT_DEFAULT);
let exporter = match protocol {
Protocol::Grpc => opentelemetry_otlp::new_exporter()
.tonic()
Expand Down Expand Up @@ -141,7 +151,7 @@ impl Append for OpentelemetryLog {
let mut record = LogRecord::default();
record.observed_timestamp = Some(SystemTime::now());
record.severity_number = Some(log_level_to_otel_severity(log_record.level()));
record.severity_text = Some(log_record.level().as_str().into());
record.severity_text = Some(log_record.level().as_str());
record.target = Some(log_record.target().to_string().into());
record.body = Some(AnyValue::from(log_record.args().to_string()));

Expand Down
1 change: 0 additions & 1 deletion src/append/rolling_file/non_blocking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ impl NonBlocking {
}

pub(super) fn send(&self, record: Vec<u8>) -> anyhow::Result<()> {
// TODO(tisonkun): consider drop the message if the channel is full
self.sender
.send(Message::Record(record))
.context("failed to send log message")
Expand Down

0 comments on commit d92d148

Please sign in to comment.