Skip to content

feat(logging): add direct Kafka logging support via tracing-kafka crate #75

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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

gopikrishna000
Copy link
Contributor

@gopikrishna000 gopikrishna000 commented Jul 8, 2025

Description

This PR introduces a generic tracing-kafka crate that enables centralized logging to Kafka for any service in the workspace.

Key features:

  • Generic, reusable Kafka logging layer with builder pattern API
  • Fire-and-forget design ensures logging never blocks the application
  • Feature-gated
  • Supports static fields (service name, build version) for consistent log enrichment

Motivation and Context

Currently, we use Vector for log collection, which has limitations:

  • Log rotation issues causing data loss
  • Two-step process (file → Vector → Kafka) adds complexity and latency
  • Limited control over log formatting and routing

This change provides direct Kafka integration, giving us:

  • Single-step logging (app → Kafka)
  • Full control over log format and delivery
  • Simplified plug and use crate

Additional Changes

How did you test it?

Start Kafka locally

# Start Zookeeper
docker run -d --name zookeeper-test -p 2181:2181 \
  -e ZOOKEEPER_CLIENT_PORT=2181 \
  -e ZOOKEEPER_TICK_TIME=2000 \
  confluentinc/cp-zookeeper:7.5.0

# Start Kafka
docker run -d --name kafka-test -p 9092:9092 \
  --link zookeeper-test:zookeeper \
  -e KAFKA_BROKER_ID=1 \
  -e KAFKA_ZOOKEEPER_CONNECT=zookeeper:2181 \
  -e KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://localhost:9092 \
  -e KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR=1 \
  confluentinc/cp-kafka:7.5.0

Run with Kafka logging

cargo run --features kafka

Consume logs

docker exec kafka-test kafka-console-consumer \
  --bootstrap-server localhost:9092 \
  --topic connector-service-logs \
  --from-beginning

Log from server
image

Log from local kafka topic

image

@gopikrishna000 gopikrishna000 requested review from a team as code owners July 8, 2025 14:16
@gopikrishna000 gopikrishna000 changed the title Feat/tracing kafka layer feat(logging): add direct Kafka logging support via tracing-kafka crate Jul 8, 2025
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.

3 participants