Skip to content

Commit

Permalink
otlpmetricsprocessor uses config service_name
Browse files Browse the repository at this point in the history
  • Loading branch information
tammy-baylis-swi committed Oct 18, 2023
1 parent 3f8d287 commit 49e1964
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
6 changes: 3 additions & 3 deletions solarwinds_apm/configurator.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ def _configure_otel_components(
)
self._configure_otlp_metrics_span_processor(
apm_txname_manager,
apm_config,
apm_meters,
)
self._configure_exporter(
Expand Down Expand Up @@ -171,12 +172,14 @@ def _configure_metrics_span_processor(
def _configure_otlp_metrics_span_processor(
self,
apm_txname_manager: SolarWindsTxnNameManager,
apm_config: SolarWindsApmConfig,
apm_meters: SolarWindsMeterManager,
) -> None:
"""Configure SolarWindsOTLPMetricsSpanProcessor"""
trace.get_tracer_provider().add_span_processor(
SolarWindsOTLPMetricsSpanProcessor(
apm_txname_manager,
apm_config,
apm_meters,
)
)
Expand Down Expand Up @@ -287,9 +290,6 @@ def _configure_metrics_exporter(
"Creating PeriodicExportingMetricReader using %s",
exporter_name,
)
# TODO: Does it have to be PeriodicExporting?
# What about pull exporters i.e. Prometheus
# https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/sdk.md#pull-metric-exporter
reader = PeriodicExportingMetricReader(exporter)
metric_readers.append(reader)

Expand Down
6 changes: 4 additions & 2 deletions solarwinds_apm/otlp_metrics_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
if TYPE_CHECKING:
from opentelemetry.sdk.trace import ReadableSpan

from solarwinds_apm.apm_config import SolarWindsApmConfig
from solarwinds_apm.apm_meter_manager import SolarWindsMeterManager
from solarwinds_apm.apm_txname_manager import SolarWindsTxnNameManager

Expand All @@ -37,9 +38,11 @@ class SolarWindsOTLPMetricsSpanProcessor(SpanProcessor):
def __init__(
self,
apm_txname_manager: "SolarWindsTxnNameManager",
apm_config: "SolarWindsApmConfig",
apm_meters: "SolarWindsMeterManager",
) -> None:
self.apm_txname_manager = apm_txname_manager
self.service_name = apm_config.service_name
self.apm_meters = apm_meters

# TODO Assumes SolarWindsInboundMetricsSpanProcessor.on_start
Expand All @@ -57,9 +60,8 @@ def on_end(self, span: "ReadableSpan") -> None:
return

# support ssa and conform to Otel proto common_pb2
# TODO init with ApmConfig to get service_name
meter_attrs = {
"sw.service_name": "flask-metrics-test",
"sw.service_name": self.service_name,
"sw.nonce": random.getrandbits(64) >> 1,
}

Expand Down

0 comments on commit 49e1964

Please sign in to comment.