-
Notifications
You must be signed in to change notification settings - Fork 4
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 : enable observability #132
Conversation
WalkthroughThis pull request introduces configuration enhancements for a chatbot application. A new Changes
Possibly related PRs
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Nitpick comments (2)
chatbot/chatbot-ollama-springai/src/main/java/com/example/chatbot/config/SwaggerConfig.java (1)
10-10
: Add JavaDoc or explanatory comment
Consider adding a brief JavaDoc or code comment on the class to describe its purpose and usage. This helps future maintainers understand the file’s role in generating the API docs.chatbot/chatbot-ollama-springai/src/main/resources/application.properties (1)
21-25
: Management endpoints, tracing, and metrics
Exposing all management endpoints (management.endpoints.web.exposure.include=*
) is convenient for development but may pose security concerns in production. Consider restricting these endpoints or securing them with proper authentication.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (5)
.gitpod.yml
is excluded by!**/*.yml
.vscode/launch.json
is excluded by!**/*.json
chatbot/chatbot-ollama-springai/docker/docker-compose.yml
is excluded by!**/*.yml
chatbot/chatbot-ollama-springai/pom.xml
is excluded by!**/*.xml
chatbot/chatbot-ollama-springai/src/main/resources/logback-spring.xml
is excluded by!**/*.xml
📒 Files selected for processing (2)
chatbot/chatbot-ollama-springai/src/main/java/com/example/chatbot/config/SwaggerConfig.java
(1 hunks)chatbot/chatbot-ollama-springai/src/main/resources/application.properties
(1 hunks)
🔇 Additional comments (6)
chatbot/chatbot-ollama-springai/src/main/java/com/example/chatbot/config/SwaggerConfig.java (4)
1-1
: Ensure package scope is intended
Since SwaggerConfig
is declared at package level (no public
modifier), confirm that only classes within com.example.chatbot.config
need to access it. If you intend for other packages or external modules to use this config, consider making it public
.
3-5
: Good usage of OpenAPI annotations
The imports for OpenAPIDefinition
, Info
, and Server
are straightforward, aligning well with modern Spring-based OpenAPI usage.
8-8
: Configuration best practices
Annotating the class with @Configuration(proxyBeanMethods = false)
is an efficient practice as it avoids the overhead of using CGLIB proxies for bean methods. This is recommended for configuration classes that do not need proxying.
9-9
: Comprehensive API metadata
Defining the API title and version clearly sets up a good foundation for documentation. Including the server URL "/"
ensures all endpoints are discovered correctly.
chatbot/chatbot-ollama-springai/src/main/resources/application.properties (2)
6-6
: Case-sensitive property change
Changing spring.ai.ollama.init.pull-model-strategy
to WHEN_MISSING
(uppercase) is valid as long as the underlying code or library expects this exact case. Verify that the application logic respects the new capitalization.
13-13
: Schema validation approach
Enabling spring.ai.vectorstore.pgvector.schema-validation
ensures the schema is validated for PgVector usage, which can prevent runtime surprises. Confirm you have the correct migration scripts or schema definitions in place.
##Observability | ||
spring.ai.vectorstore.observations.include-query-response=true | ||
spring.ai.chat.observations.include-completion=true | ||
spring.ai.chat.observations.include-prompt=true | ||
spring.ai.chat.client.observations.include-input=true | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Observability enhancements
The newly introduced properties for including query responses, completions, prompts, and inputs signal a robust approach to observability. Ensure that any sensitive or personally identifiable information is properly sanitized before being logged or recorded.
Data leakage risk can be mitigated by anonymizing or obfuscating PII in logs to safeguard user privacy.
spring.datasource.url=jdbc:postgresql://localhost:5432/appdb | ||
spring.datasource.username=appuser | ||
spring.datasource.password=secret |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Handle credentials securely
Storing DB credentials (spring.datasource.username
and spring.datasource.password
) in plain text can pose a security risk. In production environments, consider using environment variables or a secret store (e.g., HashiCorp Vault or AWS Secrets Manager).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
♻️ Duplicate comments (1)
chatbot/chatbot-ollama-springai/src/main/resources/application.properties (1)
28-30
: 🛠️ Refactor suggestionExternalize database credentials
Database credentials should not be stored in plain text in properties files.
Consider these Spring Boot security best practices:
- Use environment variables:
spring.datasource.url=${DB_URL:jdbc:postgresql://localhost:5432/appdb} spring.datasource.username=${DB_USER} spring.datasource.password=${DB_PASSWORD}
- Or use Spring Cloud Config Server with encryption:
spring.config.import=configserver: spring.cloud.config.uri=http://config-server:8888
- Or use Jasypt for property encryption:
<dependency> <groupId>com.github.ulisesbocchio</groupId> <artifactId>jasypt-spring-boot-starter</artifactId> </dependency>spring.datasource.password=ENC(encrypted_password_here)
🧹 Nitpick comments (1)
chatbot/chatbot-ollama-springai/src/main/resources/application.properties (1)
20-24
: Restrict management endpoint exposure for productionSeveral security and performance considerations:
- Exposing all management endpoints (
*
) could be a security risk- 100% tracing sampling might impact performance
- OTLP endpoints are hardcoded to localhost
Consider:
- Limiting exposed endpoints in production:
# Development management.endpoints.web.exposure.include=health,info,metrics,prometheus # Add endpoint security management.endpoints.web.base-path=/actuator management.endpoints.web.exposure.exclude=env,beans
- Adjusting sampling rate per environment:
# Development management.tracing.sampling.probability=1.0 # Production management.tracing.sampling.probability=0.1
- Externalizing OTLP configuration:
management.otlp.tracing.endpoint=${OTLP_ENDPOINT:http://localhost:4318/v1/traces} management.otlp.logging.endpoint=${OTLP_ENDPOINT:http://localhost:4318/v1/logs}
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
chatbot/chatbot-ollama-springai/src/main/resources/application.properties
(1 hunks)
🔇 Additional comments (2)
chatbot/chatbot-ollama-springai/src/main/resources/application.properties (2)
6-6
: LGTM: Enum value correction
The change to uppercase WHEN_MISSING
aligns with Spring's enum value conventions.
14-19
: Consider adding data masking configuration
While the observability settings are comprehensive, consider adding configuration options to mask sensitive data in:
- Query responses
- Chat completions
- Prompts
- User inputs
Let's check if Spring AI provides masking capabilities:
#!/bin/bash
# Search for masking/sanitization configuration options
rg -i "mask|sanitize|sensitive|pii" --type properties
No description provided.