From 159b1b57d3be5e7e2f6a4c0ae4e9e8c7e9de619d Mon Sep 17 00:00:00 2001 From: Alex Boten Date: Wed, 15 Feb 2023 15:34:12 -0800 Subject: [PATCH] update prototype to test out otlp, added insecure field Signed-off-by: Alex Boten --- json_schema/schema/schema.json | 6 ++++-- prototypes/python/otel.py | 8 ++++---- prototypes/python/prototype.py | 4 ++-- prototypes/python/requirements.txt | 1 + 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/json_schema/schema/schema.json b/json_schema/schema/schema.json index 2139f5c..7fc86bc 100644 --- a/json_schema/schema/schema.json +++ b/json_schema/schema/schema.json @@ -145,11 +145,13 @@ }, "default_histogram_aggregation": { "type": "string" + }, + "insecure": { + "type": "boolean" } }, "required": [ - "endpoint", - "protocol" + "endpoint" ], "title": "Otlp" }, diff --git a/prototypes/python/otel.py b/prototypes/python/otel.py index 5b517b3..8e939fd 100644 --- a/prototypes/python/otel.py +++ b/prototypes/python/otel.py @@ -40,12 +40,12 @@ def _resource(self): # _get_exporter returns an exporter class for the signal def _get_exporter(self, signal: str, name: str): - # if name not in self._config.get("sdk").get(signal).get("exporters"): - # raise Exception(f"exporter {name} not specified for {signal} signal") + if name not in self._config.get("sdk").get(signal).get("exporters"): + raise Exception(f"exporter {name} not specified for {signal} signal") exporter = _import_config_component(name, f"opentelemetry_{signal}_exporter") if issubclass(exporter, SpanExporter): - return exporter + return exporter(**self._config.get("sdk").get(signal).get("exporters").get(name)) raise RuntimeError(f"{name} is not a {signal} exporter") def set_tracer_provider(self): @@ -57,7 +57,7 @@ def set_tracer_provider(self): logging.debug("adding span processor %s", processor) try: # TODO: pass in exporter arguments - processor = BatchSpanProcessor(self._get_exporter("traces", processor.get("args").get("exporter"))()) + processor = BatchSpanProcessor(self._get_exporter("traces", processor.get("args").get("exporter"))) provider.add_span_processor(processor) except ModuleNotFoundError as exc: logging.error("module not found", exc) diff --git a/prototypes/python/prototype.py b/prototypes/python/prototype.py index bbe2d2d..510d988 100644 --- a/prototypes/python/prototype.py +++ b/prototypes/python/prototype.py @@ -15,8 +15,8 @@ def main(): tracer = get_tracer("config-prototype") with tracer.start_as_current_span("operation-a"): - with tracer.start_as_current_span("operation-a"): - with tracer.start_as_current_span("operation-a"): + with tracer.start_as_current_span("operation-b"): + with tracer.start_as_current_span("operation-c"): logging.debug("you should see traces after this line") main() \ No newline at end of file diff --git a/prototypes/python/requirements.txt b/prototypes/python/requirements.txt index ee36367..214cfbe 100644 --- a/prototypes/python/requirements.txt +++ b/prototypes/python/requirements.txt @@ -2,5 +2,6 @@ jsonschema pyyaml opentelemetry-api opentelemetry-sdk +opentelemetry-exporter-otlp opentelemetry-exporter-jaeger opentelemetry-exporter-zipkin \ No newline at end of file