Skip to content

Commit

Permalink
Tidy resource attrs for meterprovider
Browse files Browse the repository at this point in the history
  • Loading branch information
tammy-baylis-swi committed Oct 19, 2023
1 parent d9225b0 commit 4a39ae2
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions solarwinds_apm/configurator.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,18 +299,22 @@ def _configure_metrics_exporter(
reader = PeriodicExportingMetricReader(exporter)
metric_readers.append(reader)

# This is not the only Resource we create in distro;
# should consolidate later?
# Use configured Resource attributes then merge with
# custom service.name and sw.trace_span_mode
resource = (
trace.get_tracer_provider()
.get_tracer(__name__)
.resource
)
sw_resource = Resource.create(
{
"sw.trace_span_mode": "otel",
"service.name": apm_config.service_name,
}
).merge(resource)

# TODO If customer provides OTEL_RESOURCE_ATTRIBUTES then merge
# with service.name and sw.trace_span_mode
provider = MeterProvider(
resource=Resource.create(
{
"sw.trace_span_mode": "otel",
"service.name": apm_config.service_name,
}
),
resource=sw_resource,
metric_readers=metric_readers,
)
metrics.set_meter_provider(provider)
Expand Down

0 comments on commit 4a39ae2

Please sign in to comment.