mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-26 12:15:20 +01:00
Merge pull request #15674 from ninjadq/add_validation_for_tracing
Add validation for tracing
This commit is contained in:
commit
18c236d3cd
@ -161,8 +161,10 @@ class JaegerExporter:
|
||||
self.agent_port = config.get('agent_port')
|
||||
|
||||
def validate(self):
|
||||
if not self.endpoint and self.agent_host is None:
|
||||
raise Exception('Jaeger Colector Endpoint or Agent host not set')
|
||||
if not self.endpoint and not self.agent_host:
|
||||
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:
|
||||
def __init__(self, config: dict):
|
||||
@ -192,9 +194,13 @@ class Trace:
|
||||
self.attributes = config.get('attributes') or {}
|
||||
|
||||
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')
|
||||
if self.jaeger.enabled:
|
||||
JaegerExporter(self.jaeger).validate()
|
||||
if self.otel.enabled:
|
||||
OtelExporter(self.otel).validate()
|
||||
elif self.jaeger.enabled and self.otel.enabled:
|
||||
raise Exception('Only can have one trace exporter at a time')
|
||||
elif self.jaeger.enabled:
|
||||
self.jaeger.validate()
|
||||
elif self.otel.enabled:
|
||||
self.otel.validate()
|
||||
|
@ -76,6 +76,8 @@ def validate(conf: dict, **kwargs):
|
||||
# TODO:
|
||||
# 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():
|
||||
if not versions_file_path.is_file():
|
||||
|
Loading…
Reference in New Issue
Block a user