Skip to content

Commit 2fc2325

Browse files
Copilotlalitb
andcommitted
Fix import/module path errors in transform files
Co-authored-by: lalitb <[email protected]>
1 parent 0aaf7e9 commit 2fc2325

File tree

3 files changed

+26
-31
lines changed

3 files changed

+26
-31
lines changed

opentelemetry-otlp/src/transform/logs.rs

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,28 @@
22
pub mod tonic {
33
use opentelemetry_proto::tonic::{
44
common::v1::{
5-
any_value::Value, AnyValue, ArrayValue, InstrumentationScope, KeyValue,
5+
any_value::Value, AnyValue, ArrayValue, KeyValue,
66
KeyValueList,
77
},
88
logs::v1::{LogRecord, ResourceLogs, ScopeLogs, SeverityNumber},
99
resource::v1::Resource,
1010
};
11-
use crate::transform::common::{to_nanos, tonic::ResourceAttributesWithSchema};
11+
use crate::transform::common::{
12+
to_nanos,
13+
tonic::{ResourceAttributesWithSchema, instrumentation_scope_from_scope_ref_and_target},
14+
};
1215
use opentelemetry::logs::{AnyValue as LogsAnyValue, Severity};
1316
use opentelemetry_sdk::logs::LogBatch;
1417
use std::borrow::Cow;
1518
use std::collections::HashMap;
1619

17-
impl From<LogsAnyValue> for AnyValue {
18-
fn from(value: LogsAnyValue) -> Self {
19-
AnyValue {
20-
value: Some(value.into()),
21-
}
20+
fn any_value_from_logs_any_value(value: LogsAnyValue) -> AnyValue {
21+
AnyValue {
22+
value: Some(value_from_logs_any_value(value)),
2223
}
2324
}
2425

25-
impl From<LogsAnyValue> for Value {
26-
fn from(value: LogsAnyValue) -> Self {
26+
fn value_from_logs_any_value(value: LogsAnyValue) -> Value {
2727
match value {
2828
LogsAnyValue::Double(f) => Value::DoubleValue(f),
2929
LogsAnyValue::Int(i) => Value::IntValue(i),
@@ -32,26 +32,21 @@ pub mod tonic {
3232
LogsAnyValue::ListAny(v) => Value::ArrayValue(ArrayValue {
3333
values: v
3434
.into_iter()
35-
.map(|v| AnyValue {
36-
value: Some(v.into()),
37-
})
35+
.map(|v| any_value_from_logs_any_value(v))
3836
.collect(),
3937
}),
4038
LogsAnyValue::Map(m) => Value::KvlistValue(KeyValueList {
4139
values: m
4240
.into_iter()
4341
.map(|(key, value)| KeyValue {
4442
key: key.into(),
45-
value: Some(AnyValue {
46-
value: Some(value.into()),
47-
}),
43+
value: Some(any_value_from_logs_any_value(value)),
4844
})
4945
.collect(),
5046
}),
5147
LogsAnyValue::Bytes(v) => Value::BytesValue(*v),
5248
_ => unreachable!("Nonexistent value type"),
5349
}
54-
}
5550
}
5651

5752
impl From<&opentelemetry_sdk::logs::SdkLogRecord> for LogRecord {
@@ -93,9 +88,7 @@ pub mod tonic {
9388
.attributes_iter()
9489
.map(|kv| KeyValue {
9590
key: kv.0.to_string(),
96-
value: Some(AnyValue {
97-
value: Some(kv.1.clone().into()),
98-
}),
91+
value: Some(any_value_from_logs_any_value(kv.1.clone())),
9992
})
10093
.collect()
10194
},
@@ -156,7 +149,7 @@ pub mod tonic {
156149
.schema_url()
157150
.map(ToOwned::to_owned)
158151
.unwrap_or_default(),
159-
scope: Some(super::common::tonic::instrumentation_scope_from_scope_ref_and_target(instrumentation, log_record.target().cloned())),
152+
scope: Some(instrumentation_scope_from_scope_ref_and_target(instrumentation, log_record.target().cloned())),
160153
log_records: vec![log_record.into()],
161154
}],
162155
}
@@ -193,10 +186,10 @@ pub mod tonic {
193186
let scope_logs = scope_map
194187
.into_iter()
195188
.map(|(key, log_data)| ScopeLogs {
196-
scope: Some(InstrumentationScope::from((
189+
scope: Some(instrumentation_scope_from_scope_ref_and_target(
197190
log_data.first().unwrap().1,
198191
Some(key.into_owned().into()),
199-
))),
192+
)),
200193
schema_url: resource.schema_url.clone().unwrap_or_default(),
201194
log_records: log_data
202195
.into_iter()

opentelemetry-otlp/src/transform/metrics.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@ pub mod tonic {
3636
},
3737
resource::v1::Resource as TonicResource,
3838
};
39-
use crate::transform::common::to_nanos;
39+
use crate::transform::common::{
40+
to_nanos,
41+
tonic::instrumentation_scope_from_scope_ref_and_target,
42+
};
4043

4144
pub fn exemplar_value_from_u64(value: u64) -> exemplar::Value {
4245
exemplar::Value::AsInt(i64::try_from(value).unwrap_or_default())
@@ -127,7 +130,7 @@ pub mod tonic {
127130
impl From<&SdkScopeMetrics> for TonicScopeMetrics {
128131
fn from(sm: &SdkScopeMetrics) -> Self {
129132
TonicScopeMetrics {
130-
scope: Some(super::common::tonic::instrumentation_scope_from_scope_ref_and_target(sm.scope(), None)),
133+
scope: Some(instrumentation_scope_from_scope_ref_and_target(sm.scope(), None)),
131134
metrics: sm.metrics().map(Into::into).collect(),
132135
schema_url: sm
133136
.scope()

opentelemetry-otlp/src/transform/trace.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ pub mod tonic {
44
use opentelemetry_proto::tonic::trace::v1::{span, status, ResourceSpans, ScopeSpans, Span, Status};
55
use crate::transform::common::{
66
to_nanos,
7-
tonic::{Attributes, ResourceAttributesWithSchema},
7+
tonic::{Attributes, ResourceAttributesWithSchema, instrumentation_scope_from_scope_and_target, instrumentation_scope_from_scope_ref_and_target},
88
};
99
use opentelemetry::trace;
1010
use opentelemetry::trace::{Link, SpanId, SpanKind};
@@ -90,8 +90,7 @@ pub mod tonic {
9090
}
9191
}
9292

93-
impl ResourceSpans {
94-
pub fn new(source_span: SpanData, resource: &ResourceAttributesWithSchema) -> Self {
93+
pub fn new_resource_spans(source_span: SpanData, resource: &ResourceAttributesWithSchema) -> ResourceSpans {
9594
let span_kind: span::SpanKind = source_span.span_kind.into();
9695
ResourceSpans {
9796
resource: Some(Resource {
@@ -106,7 +105,7 @@ pub mod tonic {
106105
.schema_url()
107106
.map(ToOwned::to_owned)
108107
.unwrap_or_default(),
109-
scope: Some(super::common::tonic::instrumentation_scope_from_scope_and_target(source_span.instrumentation_scope, None)),
108+
scope: Some(instrumentation_scope_from_scope_and_target(source_span.instrumentation_scope, None)),
110109
spans: vec![Span {
111110
trace_id: source_span.span_context.trace_id().to_bytes().to_vec(),
112111
span_id: source_span.span_context.span_id().to_bytes().to_vec(),
@@ -149,7 +148,6 @@ pub mod tonic {
149148
}],
150149
}
151150
}
152-
}
153151

154152
pub fn group_spans_by_resource_and_scope(
155153
spans: Vec<SpanData>,
@@ -169,7 +167,7 @@ pub mod tonic {
169167
let scope_spans = scope_map
170168
.into_iter()
171169
.map(|(instrumentation, span_records)| ScopeSpans {
172-
scope: Some(super::common::tonic::instrumentation_scope_from_scope_ref_and_target(instrumentation, None)),
170+
scope: Some(instrumentation_scope_from_scope_ref_and_target(instrumentation, None)),
173171
schema_url: resource.schema_url.clone().unwrap_or_default(),
174172
spans: span_records
175173
.into_iter()
@@ -189,7 +187,8 @@ pub mod tonic {
189187
schema_url: resource.schema_url.clone().unwrap_or_default(),
190188
}]
191189
}
192-
}
190+
191+
} // End of tonic module
193192

194193
#[cfg(test)]
195194
mod tests {

0 commit comments

Comments
 (0)