mirror of
https://github.com/goharbor/harbor
synced 2024-09-20 14:56:25 +00:00
Add validation for tracing
* add validation of tracing in validating process Signed-off-by: Qian Deng <dengq@vmware.com>
This commit is contained in:
parent
fc1db450b2
commit
3c23926bdc
|
@ -161,8 +161,10 @@ class JaegerExporter:
|
||||||
self.agent_port = config.get('agent_port')
|
self.agent_port = config.get('agent_port')
|
||||||
|
|
||||||
def validate(self):
|
def validate(self):
|
||||||
if not self.endpoint and self.agent_host is None:
|
if not self.endpoint and not self.agent_host:
|
||||||
raise Exception('Jaeger Colector Endpoint or Agent host not set')
|
raise Exception('Jaeger Colector Endpoint or Agent host not set, must set one')
|
||||||
|
if self.endpoint and self.agent_host:
|
||||||
|
raise Exception('Jaeger Colector Endpoint and Agent host both set, only can set one')
|
||||||
|
|
||||||
class OtelExporter:
|
class OtelExporter:
|
||||||
def __init__(self, config: dict):
|
def __init__(self, config: dict):
|
||||||
|
@ -192,9 +194,13 @@ class Trace:
|
||||||
self.attributes = config.get('attributes') or {}
|
self.attributes = config.get('attributes') or {}
|
||||||
|
|
||||||
def validate(self):
|
def validate(self):
|
||||||
if not self.jaeger.enabled and not self.enabled:
|
if not self.enabled:
|
||||||
|
return
|
||||||
|
if not self.jaeger.enabled and not self.otel.enabled:
|
||||||
raise Exception('Trace enabled but no trace exporter set')
|
raise Exception('Trace enabled but no trace exporter set')
|
||||||
if self.jaeger.enabled:
|
elif self.jaeger.enabled and self.otel.enabled:
|
||||||
JaegerExporter(self.jaeger).validate()
|
raise Exception('Only can have one trace exporter at a time')
|
||||||
if self.otel.enabled:
|
elif self.jaeger.enabled:
|
||||||
OtelExporter(self.otel).validate()
|
self.jaeger.validate()
|
||||||
|
elif self.otel.enabled:
|
||||||
|
self.otel.validate()
|
||||||
|
|
|
@ -76,6 +76,8 @@ def validate(conf: dict, **kwargs):
|
||||||
# TODO:
|
# TODO:
|
||||||
# If user enable trust cert dir, need check if the files in this dir is readable.
|
# If user enable trust cert dir, need check if the files in this dir is readable.
|
||||||
|
|
||||||
|
if conf.get('trace'):
|
||||||
|
conf['trace'].validate()
|
||||||
|
|
||||||
def parse_versions():
|
def parse_versions():
|
||||||
if not versions_file_path.is_file():
|
if not versions_file_path.is_file():
|
||||||
|
|
Loading…
Reference in New Issue
Block a user