Description
Summary : Unable to see traces on NewRelic via service.name but via trace.id
Description
I am using opentelemetry-otlp to send traces to otel-collector and then otel-collector-config has an endpoint to send data to NewRelic.
I am following below example to send data to otel-collector and get the logs shown as shown in the example.
https://github.com/open-telemetry/opentelemetry-rust/tree/main/opentelemetry-otlp/examples/basic-otlp
And using this example to send traces data to newrelic.
https://github.com/newrelic/newrelic-opentelemetry-examples/tree/main/other-examples/collector/nr-config
I am able to see trace data using trace.id but not service.name . service.name is present under Resource attributes like mentioned on NewRelic opentelemetry documentation as well.
Resource SchemaURL:
Resource attributes:
-> service.name: Str(basic-otlp-example)
Log output on otel-collector :
Resource SchemaURL:
Resource attributes:
-> service.name: Str(basic-otlp-example)
ScopeSpans #0
ScopeSpans SchemaURL:
InstrumentationScope basic
InstrumentationScope attributes:
-> scope-key: Str(scope-value)
Span #0
Trace ID : f3f6a43579f63734fe866d34d9aa0b88
Parent ID : b66eacd1fcc728d3
ID : af01696ea60b9229
Name : Sub operation...
Kind : Internal
Start time : 2024-05-22 20:25:42.877134 +0000 UTC
End time : 2024-05-22 20:25:42.8771425 +0000 UTC
Status code : Unset
Status message :
Attributes:
-> another.key: Str(yes)
Events:
SpanEvent #0
-> Name: Sub span event
-> Timestamp: 2024-05-22 20:25:42.8771371 +0000 UTC
-> DroppedAttributesCount: 0
Language used : rust
Code Reference (Rust)
static RESOURCE: Lazy<Resource> = Lazy::new(|| {
Resource::new(vec![KeyValue::new(
opentelemetry_semantic_conventions::resource::SERVICE_NAME,
"basic-otlp-example",
)])
});
fn init_tracer_provider() -> Result<sdktrace::TracerProvider, TraceError> {
opentelemetry_otlp::new_pipeline()
.tracing()
.with_exporter(
opentelemetry_otlp::new_exporter()
.tonic()
.with_endpoint("http://localhost:4317"),
)
.with_trace_config(Config::default().with_resource(RESOURCE.clone()))
.install_batch(runtime::Tokio)
}
fn main() {
let tracer_provider = init_tracer_provider().unwrap();
let otel_layer = tracing_opentelemetry::layer().with_layer(tracer_provider.tracer("my-tracer"));
let subscriber = Registry::default()
.with(otel_layer);
tracing_subscriber::set_global_default(subscriber).expect("Failed");
}