Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: open telemetry traces setup #1009

Merged

Conversation

nosahama
Copy link
Contributor

@nosahama nosahama commented Dec 16, 2024

About this change - What it does

We add open telemetry traces to schema-registry.

  • more context related files are moved to the schema_registry module, this also affects the PR coverage:
    • src/karapace/schema_registry.pysrc/schema_registry/registry.py
    • src/karapace/schema_reader.pysrc/schema_registry/reader.py
    • src/schema_registry/schema_registry_apis.pysrc/schema_registry/controller.py
  • some minor changes to the DI wiring
  • only the _health endpoint is traced, we can build up from here
    • we wire the functions called by the health endpoint so they show up in the health check traces as seen in the screenshot below
  • with the DI wiring, it'd be easier to add traces to all parts of the system, but still a challenge never the less

Example traces from the /_health endpoint

Screenshot 2024-12-16 at 20 41 51

API span data

Screenshot 2024-12-16 at 20 42 18

Healthcheck endpoint handler span data

Note: the entries under Logs are not logs from the python logging module or any other configured logger, but these are OTel span events, OTel logs and metrics will be added in future iterations.
Screenshot 2024-12-16 at 20 43 21

Now with KafkaSchemaReader.ready() traced, we can clearly see from the UI that MasterCoordinator.get_coordinator_status() calls KafkaSchemaReader.ready() which was also called somewhere at the beginning of the endpoint handler.

@nosahama nosahama requested review from a team as code owners December 16, 2024 15:56
@nosahama nosahama force-pushed the nosahama/EC-674/otel-traces-basic-setup branch 2 times, most recently from 57b07bc to abe7bc7 Compare December 16, 2024 16:37
Copy link

github-actions bot commented Dec 16, 2024

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  src/karapace
  config.py
  offset_watcher.py 27-30
  src/karapace/coordinator
  master_coordinator.py 152-157
  src/karapace/kafka
  admin.py 191-194
  src/schema_registry
  __main__.py 8-10, 20-22, 27-28, 36-44, 63-65
  container.py
  controller.py
  factory.py 18-20, 61
  reader.py 377-380
  registry.py
  src/schema_registry/middlewares
  __init__.py 10, 37
  src/schema_registry/routers
  compatibility.py 11
  config.py 12-13
  health.py 8-13, 40-50, 59-93
  master_availability.py 12
  mode.py 11
  schemas.py 10
  subjects.py 12-13
  src/schema_registry/telemetry
  __init__.py
  container.py 16
  middleware.py
  setup.py
  tracer.py
Project Total  

This report was generated by python-coverage-comment-action

@nosahama nosahama force-pushed the nosahama/EC-674/otel-traces-basic-setup branch 2 times, most recently from e990750 to f2c52ed Compare December 17, 2024 09:16
@nosahama
Copy link
Contributor Author

87131a0 shows how to add tracing to KafkaAdminClient.describe_topics()
Screenshot 2024-12-17 at 12 16 24

@nosahama nosahama force-pushed the nosahama/EC-674/otel-traces-basic-setup branch 7 times, most recently from 48fd46f to f10aa3d Compare December 19, 2024 11:23
@nosahama nosahama force-pushed the nosahama/EC-674/otel-traces-basic-setup branch from f10aa3d to b0e4b63 Compare December 19, 2024 12:00
@jjaakola-aiven jjaakola-aiven merged commit d945983 into jjaakola-aiven-fastapi Dec 20, 2024
10 checks passed
@jjaakola-aiven jjaakola-aiven deleted the nosahama/EC-674/otel-traces-basic-setup branch December 20, 2024 07:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants