Skip to content

Commit

Permalink
Removed telemetry stuff from this branch
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanhellander committed Dec 5, 2023
1 parent 26925ed commit ee4d74a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 151 deletions.
6 changes: 2 additions & 4 deletions fedn/cli/run_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,10 @@ def run_cmd(ctx):
@click.option('--heartbeat-interval', required=False, default=2)
@click.option('--reconnect-after-missed-heartbeat', required=False, default=30)
@click.option('--verbosity', required=False, default='INFO', type=click.Choice(['CRITICAL', 'ERROR', 'WARNING', 'INFO', 'DEBUG'], case_sensitive=False))
@click.option('--telemetry', required=False, default=False)
@click.pass_context
def client_cmd(ctx, discoverhost, discoverport, token, name, client_id, local_package, force_ssl, dry_run, secure, preshared_cert,
verify, preferred_combiner, validator, trainer, init, logfile, heartbeat_interval, reconnect_after_missed_heartbeat,
verbosity, telemetry):
verbosity):
"""
:param ctx:
Expand All @@ -132,7 +131,6 @@ def client_cmd(ctx, discoverhost, discoverport, token, name, client_id, local_pa
:param hearbeat_interval
:param reconnect_after_missed_heartbeat
:param verbosity
:param telemetry
:return:
"""
remote = False if local_package else True
Expand All @@ -145,7 +143,7 @@ def client_cmd(ctx, discoverhost, discoverport, token, name, client_id, local_pa
'client_id': client_id, 'remote_compute_context': remote, 'force_ssl': force_ssl, 'dry_run': dry_run, 'secure': secure,
'preshared_cert': preshared_cert, 'verify': verify, 'preferred_combiner': preferred_combiner,
'validator': validator, 'trainer': trainer, 'init': init, 'logfile': logfile, 'heartbeat_interval': heartbeat_interval,
'reconnect_after_missed_heartbeat': reconnect_after_missed_heartbeat, 'verbosity': verbosity, 'telemetry': telemetry}
'reconnect_after_missed_heartbeat': reconnect_after_missed_heartbeat, 'verbosity': verbosity}

if init:
apply_config(config)
Expand Down
92 changes: 0 additions & 92 deletions fedn/fedn/common/log_config.py
Original file line number Diff line number Diff line change
@@ -1,60 +1,8 @@
import logging
import logging.config
from functools import wraps

import urllib3

try:
import os
import platform
import socket

import psutil
from opentelemetry import trace
from opentelemetry.exporter.jaeger.thrift import JaegerExporter
from opentelemetry.sdk.resources import Resource
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import BatchSpanProcessor
from opentelemetry.semconv.resource import ResourceAttributes

telemetry_enabled = True
except ImportError:
telemetry_enabled = False


def get_system_info():
system_info = [
["os.name", os.name],
["platform.system", platform.system()],
["platform.release", platform.release()],
["hostname", socket.gethostname()],
["ip_address", socket.gethostbyname(socket.gethostname())],
["cpu_count", psutil.cpu_count(logical=True)],
["total_memory", psutil.virtual_memory().total],
["total_disk", psutil.disk_usage('/').total],
]
return system_info


# Configure the tracer to export traces to Jaeger
resource = Resource.create({ResourceAttributes.SERVICE_NAME: "FEDn Client"})
tracer_provider = TracerProvider(resource=resource)
trace.set_tracer_provider(tracer_provider)

# Create a JaegerExporter
jaeger_exporter = JaegerExporter(
agent_host_name='localhost',
agent_port=6831,
)

# Add the Jaeger exporter to the tracer provider
tracer_provider.add_span_processor(
BatchSpanProcessor(jaeger_exporter)
)

tracer = None


urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
logging.getLogger("urllib3").setLevel(logging.ERROR)

Expand All @@ -66,46 +14,6 @@ def get_system_info():
handler.setFormatter(formatter)


def add_trace(name=""):
def decorator(func):
@wraps(func)
def wrapper(*args, **kwargs):
self = args[0]
name = func.__name__
if tracer:

with tracer.start_as_current_span(name) as span:
# print("name={}....{}".format(name, attributes))
if self.trace_attribs:
for attrib in self.trace_attribs:
span.set_attribute(attrib[0], attrib[1])
# system_attribs = get_system_info()
# print(system_attribs)
# for attrib in system_attribs:
# span.set_attribute(attrib[0], attrib[1])
return func(*args, **kwargs)
else:
return func(*args, **kwargs)
return wrapper
return decorator


def get_tracer():
global tracer
return tracer


def enable_tracing():
global tracer
tracer = trace.get_tracer(__name__)


def log_remote(server='localhost:8000', path='/log'):
http_handler = logging.handlers.HTTPHandler(server, '/log', method='POST')
http_handler.setLevel(logging.WARNING)
logger.addHandler(http_handler)


def set_log_level_from_string(level_str):
"""
Set the log level based on a string input.
Expand Down
Loading

0 comments on commit ee4d74a

Please sign in to comment.