Skip to content

Commit

Permalink
insecure
Browse files Browse the repository at this point in the history
  • Loading branch information
chaen committed May 28, 2024
1 parent de1acd6 commit 81bf845
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions diracx-routers/src/diracx/routers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ class OTELSettings(ServiceSettingsBase, env_prefix="DIRACX_OTEL_"):
enabled: bool = False
application_name: str = "diracx"
grpc_endpoint: str = ""
grpc_insecure: bool = False


def instrument_otel(app: FastAPI) -> None:
Expand Down Expand Up @@ -103,14 +104,20 @@ def instrument_otel(app: FastAPI) -> None:
# default otel-collector-grpc
tracer_provider.add_span_processor(

Check warning on line 105 in diracx-routers/src/diracx/routers/__init__.py

View check run for this annotation

Codecov / codecov/patch

diracx-routers/src/diracx/routers/__init__.py#L105

Added line #L105 was not covered by tests
BatchSpanProcessor(
OTLPSpanExporterGRPC(endpoint=otel_settings.grpc_endpoint, insecure=True)
OTLPSpanExporterGRPC(
endpoint=otel_settings.grpc_endpoint,
insecure=otel_settings.grpc_insecure,
)
)
)
trace.set_tracer_provider(tracer_provider)

Check warning on line 113 in diracx-routers/src/diracx/routers/__init__.py

View check run for this annotation

Codecov / codecov/patch

diracx-routers/src/diracx/routers/__init__.py#L113

Added line #L113 was not covered by tests

# metric_reader = PeriodicExportingMetricReader(ConsoleMetricExporter(),export_interval_millis=1000)
metric_reader = PeriodicExportingMetricReader(

Check warning on line 116 in diracx-routers/src/diracx/routers/__init__.py

View check run for this annotation

Codecov / codecov/patch

diracx-routers/src/diracx/routers/__init__.py#L116

Added line #L116 was not covered by tests
OTLPMetricExporter(endpoint=otel_settings.grpc_endpoint, insecure=True),
OTLPMetricExporter(
endpoint=otel_settings.grpc_endpoint,
insecure=otel_settings.grpc_insecure,
),
export_interval_millis=3000,
)
meter_provider = MeterProvider(metric_readers=[metric_reader])
Expand All @@ -126,7 +133,10 @@ def instrument_otel(app: FastAPI) -> None:
logger_provider = LoggerProvider(resource=resource)
_logs.set_logger_provider(logger_provider)

Check warning on line 134 in diracx-routers/src/diracx/routers/__init__.py

View check run for this annotation

Codecov / codecov/patch

diracx-routers/src/diracx/routers/__init__.py#L133-L134

Added lines #L133 - L134 were not covered by tests

otlp_exporter = OTLPLogExporter(endpoint=otel_settings.grpc_endpoint, insecure=True)
otlp_exporter = OTLPLogExporter(

Check warning on line 136 in diracx-routers/src/diracx/routers/__init__.py

View check run for this annotation

Codecov / codecov/patch

diracx-routers/src/diracx/routers/__init__.py#L136

Added line #L136 was not covered by tests
endpoint=otel_settings.grpc_endpoint,
insecure=otel_settings.grpc_insecure,
)
logger_provider.add_log_record_processor(BatchLogRecordProcessor(otlp_exporter))
handler = LoggingHandler(level=logging.DEBUG, logger_provider=logger_provider)
handler.setFormatter(logging.Formatter(DEFAULT_LOGGING_FORMAT))

Check warning on line 142 in diracx-routers/src/diracx/routers/__init__.py

View check run for this annotation

Codecov / codecov/patch

diracx-routers/src/diracx/routers/__init__.py#L140-L142

Added lines #L140 - L142 were not covered by tests
Expand Down

0 comments on commit 81bf845

Please sign in to comment.