Skip to content

Conversation

@NipunaMadhushan
Copy link
Contributor

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

Describe the solutions that this feature/fix will introduce to resolve the problems described above

Approach

Describe how you are implementing the solutions. Include an animated GIF or screenshot if the change affects the UI (email [email protected] to review all UI text). Include a link to a Markdown file or Google doc if the feature write-up is too long to paste here.

User stories

Summary of user stories addressed by this change>

Release note

Brief description of the new feature or bug fix as it will appear in the release notes

Documentation

Link(s) to product documentation that addresses the changes of this PR. If no doc impact, enter “N/A” plus brief explanation of why there’s no doc impact

Training

Link to the PR for changes to the training content in https://github.com/wso2/WSO2-Training, if applicable

Certification

Type “Sent” when you have provided new/updated certification questions, plus four answers for each question (correct answer highlighted in bold), based on this change. Certification questions/answers should be sent to [email protected] and NOT pasted in this PR. If there is no impact on certification exams, type “N/A” and explain why.

Marketing

Link to drafts of marketing content that will describe and promote this feature, including product page changes, technical articles, blog posts, videos, etc., if applicable

Automation tests

  • Unit tests

    Code coverage information

  • Integration tests

    Details about the test cases and coverage

Security checks

Samples

Provide high-level details about the samples related to this feature

Related PRs

List any other related PRs

Migrations (if applicable)

Describe migration steps and platforms on which migration has been tested

Test environment

List all JDK versions, operating systems, databases, and browser/versions on which this feature/fix was tested

Learning

Describe the research phase and any blog posts, patterns, libraries, or add-ons you used to solve the problem.

Comment on lines +35 to +38
public function main() returns error? {

if defaultObservabilityBackend == "opensearch" {
check observabilityBackendListener.attach(observability:opensearchService, "/");

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

Suggested change
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, "/");

Comment on lines +38 to +41
check observabilityBackendListener.attach(observability:opensearchService, "/");
check observabilityBackendListener.'start();
runtime:registerListener(observabilityBackendListener);
log:printInfo("Observability backend service is running at " + defaultObservabilityServiceHost + ":" + defaultObservabilityServicePort.toString());

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

Suggested change
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");
}

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

Suggested change
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");

Comment on lines +250 to +252
string queryJson = logQuery.toJsonString();

// Execute the search request

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

Suggested change
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");

Comment on lines 54 to 58

// Get authorization header
string|http:HeaderNotFoundError authHeader = request.getHeader("Authorization");
if authHeader is http:HeaderNotFoundError {
return error("Authorization header is required for fetching logs");

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

Suggested change
// 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");
}

Comment on lines 63 to 66

// 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);

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

Suggested change
// 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, {

Copy link

@wso2-engineering wso2-engineering bot left a 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

⚠️ Warning: AI-Generated Review Comments

  • 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.
Comment Accepted (Y/N) Reason
#### Log Improvement Suggestion No: 1
#### Log Improvement Suggestion No: 2
#### Log Improvement Suggestion No: 3
#### Log Improvement Suggestion No: 4
#### Log Improvement Suggestion No: 5
#### Log Improvement Suggestion No: 6

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.

1 participant