Skip to main content

get_resource

Function get_resource 

Source
pub fn get_resource(service_name: &str, attributes: &[KeyValue]) -> Resource
Expand description

Creates a resource with the given service name and attributes.

This function builds an OpenTelemetry resource that identifies your service and includes any additional attributes you want to track.

§Arguments

  • service_name - The name of your service
  • attributes - Additional key-value pairs to include in the resource

§Examples

use otel_init::get_resource;
use opentelemetry::KeyValue;

let resource = get_resource(
    "my-service",
    &[KeyValue::new("environment", "production")],
);