Skip to content

Commit

Permalink
[fixes broken contrib tests] Add metrics renaming changes to contrib (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
AzfaarQureshi authored Nov 19, 2020
1 parent 6c7731d commit cd0be91
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 29 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
- 'release/*'
pull_request:
env:
CORE_REPO_SHA: 47483865854c7adae7455f8441dab7f814f4ce2a
CORE_REPO_SHA: 3b813eb9921e709538dd1b07fa7a5f93600fbec1

jobs:
build:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,17 @@ class OpenTelemetryClientInterceptor(
def __init__(self, tracer, exporter, interval):
self._tracer = tracer

self._meter = None
self._accumulator = None
if exporter and interval:
self._meter = metrics.get_meter(__name__)
self._accumulator = metrics.get_meter(__name__)
self.controller = PushController(
meter=self._meter, exporter=exporter, interval=interval
accumulator=self._accumulator,
exporter=exporter,
interval=interval,
)
self._metrics_recorder = TimedMetricRecorder(self._meter, "client")
self._metrics_recorder = TimedMetricRecorder(
self._accumulator, "client",
)

def _start_span(self, method):
return self._tracer.start_as_current_span(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ def __init__(
config: typing.Optional[typing.Dict[str, typing.List[str]]] = None,
):
self._labels = {} if labels is None else labels
self.meter = metrics.get_meter(__name__)
self.accumulator = metrics.get_meter(__name__)
self.controller = PushController(
meter=self.meter, exporter=exporter, interval=interval
accumulator=self.accumulator, exporter=exporter, interval=interval
)
self._python_implementation = python_implementation().lower()
if config is None:
Expand Down Expand Up @@ -155,159 +155,159 @@ def __init__(
self._runtime_cpu_time_labels = self._labels.copy()
self._runtime_gc_count_labels = self._labels.copy()

self.meter.register_sumobserver(
self.accumulator.register_sumobserver(
callback=self._get_system_cpu_time,
name="system.cpu.time",
description="System CPU time",
unit="seconds",
value_type=float,
)

self.meter.register_valueobserver(
self.accumulator.register_valueobserver(
callback=self._get_system_cpu_utilization,
name="system.cpu.utilization",
description="System CPU utilization",
unit="1",
value_type=float,
)

self.meter.register_valueobserver(
self.accumulator.register_valueobserver(
callback=self._get_system_memory_usage,
name="system.memory.usage",
description="System memory usage",
unit="bytes",
value_type=int,
)

self.meter.register_valueobserver(
self.accumulator.register_valueobserver(
callback=self._get_system_memory_utilization,
name="system.memory.utilization",
description="System memory utilization",
unit="1",
value_type=float,
)

self.meter.register_valueobserver(
self.accumulator.register_valueobserver(
callback=self._get_system_swap_usage,
name="system.swap.usage",
description="System swap usage",
unit="pages",
value_type=int,
)

self.meter.register_valueobserver(
self.accumulator.register_valueobserver(
callback=self._get_system_swap_utilization,
name="system.swap.utilization",
description="System swap utilization",
unit="1",
value_type=float,
)

# self.meter.register_sumobserver(
# self.accumulator.register_sumobserver(
# callback=self._get_system_swap_page_faults,
# name="system.swap.page_faults",
# description="System swap page faults",
# unit="faults",
# value_type=int,
# )

# self.meter.register_sumobserver(
# self.accumulator.register_sumobserver(
# callback=self._get_system_swap_page_operations,
# name="system.swap.page_operations",
# description="System swap page operations",
# unit="operations",
# value_type=int,
# )

self.meter.register_sumobserver(
self.accumulator.register_sumobserver(
callback=self._get_system_disk_io,
name="system.disk.io",
description="System disk IO",
unit="bytes",
value_type=int,
)

self.meter.register_sumobserver(
self.accumulator.register_sumobserver(
callback=self._get_system_disk_operations,
name="system.disk.operations",
description="System disk operations",
unit="operations",
value_type=int,
)

self.meter.register_sumobserver(
self.accumulator.register_sumobserver(
callback=self._get_system_disk_time,
name="system.disk.time",
description="System disk time",
unit="seconds",
value_type=float,
)

self.meter.register_sumobserver(
self.accumulator.register_sumobserver(
callback=self._get_system_disk_merged,
name="system.disk.merged",
description="System disk merged",
unit="1",
value_type=int,
)

# self.meter.register_valueobserver(
# self.accumulator.register_valueobserver(
# callback=self._get_system_filesystem_usage,
# name="system.filesystem.usage",
# description="System filesystem usage",
# unit="bytes",
# value_type=int,
# )

# self.meter.register_valueobserver(
# self.accumulator.register_valueobserver(
# callback=self._get_system_filesystem_utilization,
# name="system.filesystem.utilization",
# description="System filesystem utilization",
# unit="1",
# value_type=float,
# )

self.meter.register_sumobserver(
self.accumulator.register_sumobserver(
callback=self._get_system_network_dropped_packets,
name="system.network.dropped_packets",
description="System network dropped_packets",
unit="packets",
value_type=int,
)

self.meter.register_sumobserver(
self.accumulator.register_sumobserver(
callback=self._get_system_network_packets,
name="system.network.packets",
description="System network packets",
unit="packets",
value_type=int,
)

self.meter.register_sumobserver(
self.accumulator.register_sumobserver(
callback=self._get_system_network_errors,
name="system.network.errors",
description="System network errors",
unit="errors",
value_type=int,
)

self.meter.register_sumobserver(
self.accumulator.register_sumobserver(
callback=self._get_system_network_io,
name="system.network.io",
description="System network io",
unit="bytes",
value_type=int,
)

self.meter.register_updownsumobserver(
self.accumulator.register_updownsumobserver(
callback=self._get_system_network_connections,
name="system.network.connections",
description="System network connections",
unit="connections",
value_type=int,
)

self.meter.register_sumobserver(
self.accumulator.register_sumobserver(
callback=self._get_runtime_memory,
name="runtime.{}.memory".format(self._python_implementation),
description="Runtime {} memory".format(
Expand All @@ -317,7 +317,7 @@ def __init__(
value_type=int,
)

self.meter.register_sumobserver(
self.accumulator.register_sumobserver(
callback=self._get_runtime_cpu_time,
name="runtime.{}.cpu_time".format(self._python_implementation),
description="Runtime {} CPU time".format(
Expand All @@ -327,7 +327,7 @@ def __init__(
value_type=float,
)

self.meter.register_sumobserver(
self.accumulator.register_sumobserver(
callback=self._get_runtime_gc_count,
name="runtime.{}.gc_count".format(self._python_implementation),
description="Runtime {} GC count".format(
Expand Down

0 comments on commit cd0be91

Please sign in to comment.