Skip to content

Commit

Permalink
otel: split exporters for traces and metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
nosahama committed Feb 12, 2025
1 parent f01f1cd commit a8cb79c
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 12 deletions.
3 changes: 2 additions & 1 deletion container/compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ services:
KARAPACE_KAFKA_RETRIABLE_ERRORS_SILENCED: true
KARAPACE_TAGS__APP: karapace-schema-registry
KARAPACE_TELEMETRY__OTEL_ENDPOINT_URL: http://opentelemetry-collector:4317
KARAPACE_TELEMETRY__OTEL_EXPORTER: OTLP
KARAPACE_TELEMETRY__OTEL_METRICS_EXPORTER: OTLP
KARAPACE_TELEMETRY__OTEL_TRACES_EXPORTER: OTLP
KARAPACE_TELEMETRY__RESOURCE_SERVICE_NAME: karapace-schema-registry
KARAPACE_TELEMETRY__RESOURCE_SERVICE_INSTANCE_ID: sr1
KARAPACE_TELEMETRY__RESOURCE_TELEMETRY_SDK_NAME: opentelemetry
Expand Down
3 changes: 2 additions & 1 deletion src/karapace/core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ class KarapaceTelemetryOTelExporter(str, enum.Enum):

class KarapaceTelemetry(BaseModel):
otel_endpoint_url: str | None = None
otel_exporter: KarapaceTelemetryOTelExporter = KarapaceTelemetryOTelExporter.NOOP
otel_traces_exporter: KarapaceTelemetryOTelExporter = KarapaceTelemetryOTelExporter.NOOP
otel_metrics_exporter: KarapaceTelemetryOTelExporter = KarapaceTelemetryOTelExporter.NOOP
metrics_export_interval_milliseconds: int = 10000
resource_service_name: str = "karapace"
resource_service_instance_id: str = "karapace"
Expand Down
2 changes: 1 addition & 1 deletion src/karapace/core/instrumentation/meter.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def get_meter(config: Config = Provide[KarapaceContainer.config]) -> metrics.Met

@staticmethod
def get_metric_exporter(config: Config) -> MetricExporter:
match config.telemetry.otel_exporter:
match config.telemetry.otel_metrics_exporter:
case KarapaceTelemetryOTelExporter.NOOP:
return NOOPMetricExporter()
case KarapaceTelemetryOTelExporter.CONSOLE:
Expand Down
2 changes: 1 addition & 1 deletion src/karapace/core/instrumentation/tracer.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def get_tracer(config: Config = Provide[KarapaceContainer.config]) -> trace.Trac

@staticmethod
def get_span_exporter(config: Config) -> SpanExporter:
match config.telemetry.otel_exporter:
match config.telemetry.otel_traces_exporter:
case KarapaceTelemetryOTelExporter.NOOP:
return NOOPSpanExporter()
case KarapaceTelemetryOTelExporter.CONSOLE:
Expand Down
File renamed without changes.
8 changes: 4 additions & 4 deletions tests/unit/core/instrumentation/test_meter.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def test_get_metric_exporter_noop(karapace_container: KarapaceContainer) -> None
new_config={
"telemetry": KarapaceTelemetry(
otel_endpoint_url="http://otel:4317",
otel_exporter="NOOP",
otel_metrics_exporter="NOOP",
)
}
)
Expand All @@ -38,7 +38,7 @@ def test_get_metric_exporter_console(karapace_container: KarapaceContainer) -> N
new_config={
"telemetry": KarapaceTelemetry(
otel_endpoint_url="http://otel:4317",
otel_exporter="CONSOLE",
otel_metrics_exporter="CONSOLE",
)
}
)
Expand All @@ -51,7 +51,7 @@ def test_get_metric_exporter_otlp(karapace_container: KarapaceContainer) -> None
new_config={
"telemetry": KarapaceTelemetry(
otel_endpoint_url="http://otel:4317",
otel_exporter="OTLP",
otel_metrics_exporter="OTLP",
)
}
)
Expand Down Expand Up @@ -83,7 +83,7 @@ def test_get_metric_reader_with_otel_endpoint(karapace_container: KarapaceContai
new_config={
"telemetry": KarapaceTelemetry(
otel_endpoint_url="http://otel:4317",
otel_exporter="OTLP",
otel_metrics_exporter="OTLP",
)
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def test_get_span_exporter_noop(karapace_container: KarapaceContainer) -> None:
new_config={
"telemetry": KarapaceTelemetry(
otel_endpoint_url="http://otel:4317",
otel_exporter="NOOP",
otel_traces_exporter="NOOP",
)
}
)
Expand All @@ -55,7 +55,7 @@ def test_get_span_exporter_console(karapace_container: KarapaceContainer) -> Non
new_config={
"telemetry": KarapaceTelemetry(
otel_endpoint_url="http://otel:4317",
otel_exporter="CONSOLE",
otel_traces_exporter="CONSOLE",
)
}
)
Expand All @@ -68,7 +68,7 @@ def test_get_span_exporter_otlp(karapace_container: KarapaceContainer) -> None:
new_config={
"telemetry": KarapaceTelemetry(
otel_endpoint_url="http://otel:4317",
otel_exporter="OTLP",
otel_traces_exporter="OTLP",
)
}
)
Expand All @@ -83,7 +83,7 @@ def test_get_span_processor_with_otel_endpoint(karapace_container: KarapaceConta
new_config={
"telemetry": KarapaceTelemetry(
otel_endpoint_url="http://otel:4317",
otel_exporter="OTLP",
otel_traces_exporter="OTLP",
)
}
)
Expand Down

0 comments on commit a8cb79c

Please sign in to comment.