How riandyrn/otelchi works
Primary System Components
• Middleware/Instrumentation Library: This is the core of the project – middleware.go and related metric files provide the instrumentation logic.
• OpenTelemetry Integration: Highlight how the library captures and sends traces and metrics. Include components that relate to the OpenTelemetry Collector or backend (even if these are external).
• go-chi Router Integration: Indicate how otelchi ties into go-chi for handling HTTP requests.
• Example Applications: Represent both “basic” and “multi-services” examples to show real-world integration. In multi-services, separate components for front-end and back-end services, plus utilities (healthcheck, metrics, tracer) should be illustrated.
• Build, Test, and CI/CD: Note the existence of workflows (.github/workflows) and test directories that validate the functionality. This reflects continuous integration and quality assurance processes.
• Configuration and Versioning: Show auxiliary components like config.go and version/version.go that support configuration and versioning for the library.
Relationships and Interactions
• How HTTP requests flow from the go-chi router into the middleware where the instrumentation hooks (tracing and metrics) are activated.
• In the multi-services case, show services (front-svc and back-svc) communicating possibly over defined interfaces (REST APIs), with instrumentation applied to both.
Architectural Patterns and Design Principles
• Layered or modular design: Separate your instrumentation logic from the business logic of the application. Even though this project is a library, understanding its modularity is key.
• Middleware pattern: Clearly represent how the middleware intercepts HTTP requests/responses, applying OpenTelemetry instrumentation.
• Dependency inversion: Highlight how this library is built to easily be injected into any go-chi application.
Technologies and Frameworks
• Go as the programming language (evidenced by go.mod, go.sum, and main.go files).
• The go-chi router (as the integration point for handling HTTP requests).
• OpenTelemetry for both traces and metrics instrumentation.
• Docker and docker-compose in the examples for containerization and orchestration.
• Continuous integration tools associated with workflows in .github/workflows.
Final Touches
• Reference the actual file structure and README descriptions where appropriate to back up each component you’ve drawn.
• Ease of integration: The middleware is designed as a drop-in component for any go-chi-based service, which is a critical selling point of otelchi.