From 820dcc744ef2a18f286cc0b66e0a9d9a6717bf56 Mon Sep 17 00:00:00 2001 From: Idriss Neumann Date: Tue, 5 Nov 2024 17:16:10 +0100 Subject: [PATCH] Add tls check option configurable --- .docker/otel-collector-config.yaml | 10 ++++++---- VERSION | 2 +- ansible-imalive/defaults/main.yml | 2 +- ansible-imalive/templates/.env.imalive.j2 | 4 ++++ helm/templates/deployment.yaml | 5 +++++ src/utils/otel.py | 9 +++++---- 6 files changed, 22 insertions(+), 10 deletions(-) diff --git a/.docker/otel-collector-config.yaml b/.docker/otel-collector-config.yaml index f832d69..156afc2 100644 --- a/.docker/otel-collector-config.yaml +++ b/.docker/otel-collector-config.yaml @@ -2,15 +2,17 @@ receivers: otlp: protocols: grpc: + endpoint: 0.0.0.0:4317 http: + endpoint: 0.0.0.0:4318 exporters: - logging: + debug: prometheus: endpoint: "0.0.0.0:8889" const_labels: otel: otel - otlp: + otlp/jaeger: endpoint: "jaeger:4317" tls: insecure: true @@ -25,8 +27,8 @@ service: exporters: [prometheus] traces: receivers: [otlp] - exporters: [otlp] + exporters: [otlp/jaeger] logs: receivers: [otlp] processors: [batch] - exporters: [logging] + exporters: [debug] diff --git a/VERSION b/VERSION index 041792e..80c4caf 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -4.0.13 +4.0.14 diff --git a/ansible-imalive/defaults/main.yml b/ansible-imalive/defaults/main.yml index 81bd976..29111f2 100644 --- a/ansible-imalive/defaults/main.yml +++ b/ansible-imalive/defaults/main.yml @@ -1,5 +1,5 @@ --- -imalive_api_version: 4.0.11 +imalive_api_version: 4.0.14 imalive_port: 8099 imalive_wait_time: 300 imalive_force_recreate: true diff --git a/ansible-imalive/templates/.env.imalive.j2 b/ansible-imalive/templates/.env.imalive.j2 index 814ab99..0a51ff2 100644 --- a/ansible-imalive/templates/.env.imalive.j2 +++ b/ansible-imalive/templates/.env.imalive.j2 @@ -5,6 +5,10 @@ IMALIVE_NODE_NAME={{ node_name }} OTEL_COLLECTOR_ENDPOINT={{ imalive_otel_collector_endpoint }} {% endif %} +{% if imalive_otel_collector_tls_check is defined and imalive_otel_collector_tls_check %} +OTEL_COLLECTOR_TLS_CHECK={{ imalive_otel_collector_tls_check }} +{% endif %} + {% if imalive_otel_collector_username is defined and imalive_otel_collector_username %} OTEL_COLLECTOR_USERNAME={{ imalive_otel_collector_username }} {% endif %} diff --git a/helm/templates/deployment.yaml b/helm/templates/deployment.yaml index 65636a3..b35be50 100644 --- a/helm/templates/deployment.yaml +++ b/helm/templates/deployment.yaml @@ -41,6 +41,11 @@ spec: value: {{ $.Values.otlp_endpoint | quote }} {{ end }} + {{ if $.Values.otlp_tls_check }} + - name: OTEL_COLLECTOR_TLS_CHECK + value: {{ $.Values.otlp_tls_check | quote }} + {{ end }} + {{ if $.Values.otlp_username }} - name: OTEL_COLLECTOR_USERNAME value: {{ $.Values.otlp_username | quote }} diff --git a/src/utils/otel.py b/src/utils/otel.py index a1c3c43..32d02af 100644 --- a/src/utils/otel.py +++ b/src/utils/otel.py @@ -19,12 +19,13 @@ from opentelemetry.exporter.otlp.proto.grpc.metric_exporter import OTLPMetricExporter from opentelemetry.exporter.otlp.proto.grpc._log_exporter import OTLPLogExporter -from utils.common import is_enabled, is_not_empty +from utils.common import is_enabled, is_false, is_not_empty _otel_tracer = trace.get_tracer(__name__) _otel_collector_endpoint = os.getenv('OTEL_COLLECTOR_ENDPOINT') _otel_service_name = "imalive-{}".format(os.getenv('IMALIVE_NODE_NAME', "anode")) _otel_service_version = os.getenv('VERSION', '0.1') +_otel_collector_tls_disable_check = is_false(os.getenv('OTEL_COLLECTOR_TLS_CHECK', 'false')) _otel_collector_username = os.getenv('OTEL_COLLECTOR_USERNAME') _otel_collector_password = os.getenv('OTEL_COLLECTOR_PASSWORD') @@ -56,16 +57,16 @@ def init_otel_tracer(): trace.set_tracer_provider(TracerProvider(resource=_otel_resource)) if is_enabled(_otel_collector_endpoint): - trace.get_tracer_provider().add_span_processor(BatchSpanProcessor(OTLPSpanExporter(endpoint=_otel_collector_endpoint, credentials=credentials, insecure=True))) + trace.get_tracer_provider().add_span_processor(BatchSpanProcessor(OTLPSpanExporter(endpoint=_otel_collector_endpoint, credentials=credentials, insecure=_otel_collector_tls_disable_check))) def init_otel_metrics(): if is_enabled(_otel_collector_endpoint): - otlp_exporter = OTLPMetricExporter(endpoint=_otel_collector_endpoint, credentials=credentials, insecure=True) + otlp_exporter = OTLPMetricExporter(endpoint=_otel_collector_endpoint, credentials=credentials, insecure=_otel_collector_tls_disable_check) set_meter_provider(MeterProvider(resource=_otel_resource, metric_readers=[PeriodicExportingMetricReader(otlp_exporter, export_interval_millis=5000)])) def init_otel_logger(): if is_enabled(_otel_collector_endpoint): - otlp_exporter = OTLPLogExporter(endpoint=_otel_collector_endpoint, credentials=credentials, insecure=True) + otlp_exporter = OTLPLogExporter(endpoint=_otel_collector_endpoint, credentials=credentials, insecure=_otel_collector_tls_disable_check) _logger_provider.add_log_record_processor(BatchLogRecordProcessor(otlp_exporter)) handler = LoggingHandler(level=logging.NOTSET, logger_provider=_logger_provider) logging.getLogger().addHandler(handler)