Skip to content

Commit

Permalink
feat: add example of using ResourceBuilder
Browse files Browse the repository at this point in the history
  • Loading branch information
pitoniak32 committed Nov 24, 2024
1 parent 7beb6bf commit e501d4f
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions examples/metrics-advanced/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,14 @@ fn init_meter_provider() -> opentelemetry_sdk::metrics::SdkMeterProvider {
.with_temporality(Temporality::Delta)
.build();

let resource = Resource::builder()
.with_key_value(KeyValue::new("service.name", "metrics-advanced-example"))
.build();

let reader = PeriodicReader::builder(exporter, runtime::Tokio).build();
let provider = SdkMeterProvider::builder()
.with_reader(reader)
.with_resource(Resource::new([KeyValue::new(
"service.name",
"metrics-advanced-example",
)]))
.with_resource(resource)
.with_view(my_view_rename_and_unit)
.with_view(my_view_drop_attributes)
.with_view(my_view_change_aggregation)
Expand Down

0 comments on commit e501d4f

Please sign in to comment.