-
Notifications
You must be signed in to change notification settings - Fork 12
Create pluggable observability backend architecture for fetching observability data #74
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
base: icp2
Are you sure you want to change the base?
Conversation
| public function main() returns error? { | ||
|
|
||
| if defaultObservabilityBackend == "opensearch" { | ||
| check observabilityBackendListener.attach(observability:opensearchService, "/"); |
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.
Log Improvement Suggestion No: 1
| public function main() returns error? { | |
| if defaultObservabilityBackend == "opensearch" { | |
| check observabilityBackendListener.attach(observability:opensearchService, "/"); | |
| public function main() returns error? { | |
| if defaultObservabilityBackend == "opensearch" { | |
| log:printInfo("Starting observability backend service with OpenSearch configuration"); | |
| check observabilityBackendListener.attach(observability:opensearchService, "/"); |
| check observabilityBackendListener.attach(observability:opensearchService, "/"); | ||
| check observabilityBackendListener.'start(); | ||
| runtime:registerListener(observabilityBackendListener); | ||
| log:printInfo("Observability backend service is running at " + defaultObservabilityServiceHost + ":" + defaultObservabilityServicePort.toString()); |
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.
Log Improvement Suggestion No: 2
| check observabilityBackendListener.attach(observability:opensearchService, "/"); | |
| check observabilityBackendListener.'start(); | |
| runtime:registerListener(observabilityBackendListener); | |
| log:printInfo("Observability backend service is running at " + defaultObservabilityServiceHost + ":" + defaultObservabilityServicePort.toString()); | |
| check observabilityBackendListener.attach(observability:opensearchService, "/"); | |
| check observabilityBackendListener.'start(); | |
| runtime:registerListener(observabilityBackendListener); | |
| log:printInfo("Observability backend service started successfully"); | |
| log:printInfo("Observability backend service is running at " + defaultObservabilityServiceHost + ":" + defaultObservabilityServicePort.toString()); |
| function init() { | ||
| log:printInfo("Observability service started with OpenSearch backend"); | ||
| } | ||
|
|
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.
Log Improvement Suggestion No: 3
| resource function post logs(@http:Header {name: "X-API-Key"} string? apiKeyHeader, @http:Payload types:LogEntryRequest logRequest) returns types:LogEntriesResponse|http:BadRequest|error { | |
| log:printInfo("Received log query request"); |
| string queryJson = logQuery.toJsonString(); | ||
|
|
||
| // Execute the search request |
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.
Log Improvement Suggestion No: 4
| string queryJson = logQuery.toJsonString(); | |
| // Execute the search request | |
| http:Response response = check opensearchClient->post(path = "/ballerina-application-logs-*/_search", | |
| message = queryJson, | |
| headers = {"Content-Type": "application/json"}); | |
| log:printDebug("OpenSearch query executed successfully for log entries"); |
|
|
||
| // Get authorization header | ||
| string|http:HeaderNotFoundError authHeader = request.getHeader("Authorization"); | ||
| if authHeader is http:HeaderNotFoundError { | ||
| return error("Authorization header is required for fetching logs"); |
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.
Log Improvement Suggestion No: 5
| // Get authorization header | |
| string|http:HeaderNotFoundError authHeader = request.getHeader("Authorization"); | |
| if authHeader is http:HeaderNotFoundError { | |
| return error("Authorization header is required for fetching logs"); | |
| // Get authorization header | |
| string|http:HeaderNotFoundError authHeader = request.getHeader("Authorization"); | |
| if authHeader is http:HeaderNotFoundError { | |
| log:printError("Authorization header not found in request"); | |
| return error("Authorization header is required for fetching logs"); | |
| } |
|
|
||
| // Build base OpenSearch query with common filters | ||
| isolated function buildBaseQuery(types:LogEntryRequest logRequest, types:UserContext userContext) returns map<json>|error { | ||
| map<json> query = { | ||
| "query": { | ||
| "bool": { | ||
| "must": [], | ||
| "filter": [] | ||
| } | ||
| } | ||
| }; | ||
| // Validate and filter log request based on user access | ||
| types:LogEntryRequest validatedLogRequest = check getUserValidatedLogRequest(logRequest, userContext); | ||
|
|
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.
Log Improvement Suggestion No: 6
| // Build base OpenSearch query with common filters | |
| isolated function buildBaseQuery(types:LogEntryRequest logRequest, types:UserContext userContext) returns map<json>|error { | |
| map<json> query = { | |
| "query": { | |
| "bool": { | |
| "must": [], | |
| "filter": [] | |
| } | |
| } | |
| }; | |
| // Validate and filter log request based on user access | |
| types:LogEntryRequest validatedLogRequest = check getUserValidatedLogRequest(logRequest, userContext); | |
| // Validate and filter log request based on user access | |
| types:LogEntryRequest validatedLogRequest = check getUserValidatedLogRequest(logRequest, userContext); | |
| log:printInfo("Processing log request for user: " + userContext.username); | |
| http:Response|error response = observabilityBackendClient->post("/logs", validatedLogRequest, { |
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.
AI Agent Log Improvement Checklist
- The log-related comments and suggestions in this review were generated by an AI tool to assist with identifying potential improvements. Purpose of reviewing the code for log improvements is to improve the troubleshooting capabilities of our products.
- Please make sure to manually review and validate all suggestions before applying any changes. Not every code suggestion would make sense or add value to our purpose. Therefore, you have the freedom to decide which of the suggestions are helpful.
✅ Before merging this pull request:
- Review all AI-generated comments for accuracy and relevance.
- Complete and verify the table below. We need your feedback to measure the accuracy of these suggestions and the value they add. If you are rejecting a certain code suggestion, please mention the reason briefly in the suggestion for us to capture it.
Purpose
This will allow the users to provide custom observability backends.
Front-end server will communicate with the back-end observability service and the observability service will fetch the data from the custom observability backend provided with the configuration.
By default, the OpenSearch backend will be hosted inside the ICP server.
For creating custom observability backends, users can use the OpenAPI specification created for observability backend.
Goals
Approach
User stories
Release note
Documentation
Training
Certification
Marketing
Automation tests
Security checks
Samples
Related PRs
Migrations (if applicable)
Test environment
Learning