Skip to content
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

chore: Distributed tracing for client #37101

Merged
merged 6 commits into from
Oct 29, 2024
Merged

Conversation

nidhi-nair
Copy link
Contributor

@nidhi-nair nidhi-nair commented Oct 25, 2024

Description

Use consistent properties for OTLP and propagate to server.

Fixes #Issue Number
or
Fixes Issue URL

Warning

If no issue exists, please create an issue first, and check with the maintainers if the issue is valid.

Automation

/ok-to-test tags="@tag.Sanity"

🔍 Cypress test results

Warning

Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/11568095483
Commit: 0cefb16
Cypress dashboard.
Tags: @tag.Sanity
Spec:
It seems like no tests ran 😔. We are not able to recognize it, please check workflow here.


Tue, 29 Oct 2024 06:03:03 UTC

Communication

Should the DevRel and Marketing teams inform users about this change?

  • Yes
  • No

Summary by CodeRabbit

  • New Features

    • Introduced enhanced observability settings, including deployment name and service instance ID.
    • Added automatic instrumentation for XML HTTP requests to improve telemetry capabilities.
  • Bug Fixes

    • Streamlined telemetry configuration by removing outdated properties and replacing them with updated semantic attributes.
    • Simplified the executeAction method by removing unnecessary telemetry complexity.
    • Refined error handling in the plugin action execution process.
  • Documentation

    • Updated configuration interfaces to reflect new observability properties and modifications to existing configurations.
    • Added observability settings to the public configuration object in the HTML document.
    • Updated Jest configuration to include observability properties for testing.

@nidhi-nair nidhi-nair requested a review from vsvamsi1 October 25, 2024 10:28
@nidhi-nair nidhi-nair requested a review from KelvinOm as a code owner October 25, 2024 10:28
Copy link
Contributor

coderabbitai bot commented Oct 25, 2024

Walkthrough

The changes in this pull request involve updates to the application's telemetry capabilities. Key modifications include the addition of a new dependency for OpenTelemetry instrumentation, updates to existing dependencies, and enhancements to the configuration for observability. The telemetry service's metadata structure has been updated, and several properties have been added or removed to streamline the configuration. Overall, these changes aim to improve the application's telemetry and observability features.

Changes

File Path Change Summary
app/client/package.json - Added dependency: @opentelemetry/auto-instrumentations-web with version ^0.41.0.
- Updated version of @opentelemetry/semantic-conventions from 1.25.1 to ^1.27.0.
app/client/src/UITelemetry/auto-otel-web.ts - Removed semantic attributes and replaced them with new attributes from observability configuration.
- Expanded newRelic configuration to include observability.
- Removed custom CustomW3CTraceContextPropagator, using default instead.
- Added method getWebAutoInstrumentations for automatic instrumentation of XML HTTP requests.
app/client/src/ce/configs/index.ts - Added observability object to INJECTED_CONFIGS interface with properties from environment variables.
- Removed otlpServiceName from newRelic configuration.
app/client/src/ce/configs/types.ts - Added observability property to AppsmithUIConfigs interface.
- Removed otlpServiceName from NewRelic interface.
app/client/public/index.html - Added observability property in window.APPSMITH_FEATURE_CONFIGS with sub-properties for deploymentName and serviceInstanceId.
app/client/src/UITelemetry/generateTraces.ts - Removed function wrapFnWithParentTraceContext.
app/client/src/api/ActionAPI.tsx - Updated executeAction method signature to remove parentSpan.
app/client/src/sagas/ActionExecution/PluginActionSaga.ts - Updated executePluginActionSaga function signature to remove parentSpan.
app/client/jest.config.js - Added observability property in globals with deploymentName and serviceInstanceId.

Possibly related PRs

  • chore: Register OTLP metrics provider #35112: This PR updates the package.json to include the @opentelemetry/semantic-conventions dependency, which is also updated in the main PR, indicating a direct relationship in terms of dependency management.
  • chore: Add OTLP traces to RTS #36788: This PR adds OTLP traces to the RTS, which aligns with the telemetry enhancements made in the main PR, suggesting a focus on improving observability and tracing capabilities.
  • chore: capture performance of parsing api response #37081: This PR introduces telemetry for capturing performance metrics related to parsing API responses, which complements the telemetry improvements in the main PR, indicating a broader effort to enhance monitoring across the application.

Suggested labels

ok-to-test, Performance Pod, Task, Performance infra, Performance

Suggested reviewers

  • rajatagrawal
  • ApekshaBhosale
  • vsvamsi1

Poem

In the code where metrics flow,
New tools and tweaks begin to grow.
Telemetry shines, observability's bright,
With attributes fresh, the future's in sight!
So raise a toast to the lines we write,
For clearer insights, our goals take flight! 🎉


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?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added the skip-changelog Adding this label to a PR prevents it from being listed in the changelog label Oct 25, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Outside diff range and nitpick comments (2)
app/client/src/ce/configs/index.ts (1)

98-101: Consider environment-specific deployment names.

While the defaults look good, consider using different default deployment names for different environments (dev/staging/prod).

-      deploymentName: process.env.APPSMITH_DEPLOYMENT_NAME || "self-hosted",
+      deploymentName: process.env.APPSMITH_DEPLOYMENT_NAME || 
+        `self-hosted-${process.env.NODE_ENV || 'development'}`,
app/client/package.json (1)

Line range hint 75-85: Maintain consistent versioning across OpenTelemetry packages.

Consider pinning all OpenTelemetry packages to specific versions to prevent compatibility issues. Currently mixing fixed versions (1.25.1, 0.52.1) with floating versions (^0.41.0, ^1.27.0).

Apply this diff to maintain consistency:

-    "@opentelemetry/auto-instrumentations-web": "^0.41.0",
+    "@opentelemetry/auto-instrumentations-web": "0.41.0",
-    "@opentelemetry/semantic-conventions": "^1.27.0",
+    "@opentelemetry/semantic-conventions": "1.27.0",
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between cd26aed and 554635b.

⛔ Files ignored due to path filters (1)
  • app/client/yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (4)
  • app/client/package.json (2 hunks)
  • app/client/src/UITelemetry/auto-otel-web.ts (5 hunks)
  • app/client/src/ce/configs/index.ts (4 hunks)
  • app/client/src/ce/configs/types.ts (1 hunks)
🔇 Additional comments (10)
app/client/src/ce/configs/types.ts (2)

23-27: LGTM: Well-structured observability configuration.

The new observability configuration follows OpenTelemetry semantic conventions for resource attributes.


23-27: Verify NewRelic and OpenTelemetry configuration relationship.

Since both NewRelic and OpenTelemetry configurations coexist, let's verify their integration in the codebase.

Also applies to: 28-37

✅ Verification successful

NewRelic and OpenTelemetry configurations are properly integrated

The configurations are correctly implemented with NewRelic acting as the OTLP endpoint for OpenTelemetry:

  • OpenTelemetry is configured to send traces and metrics to NewRelic's OTLP endpoint
  • Observability fields (deploymentName, serviceInstanceId, serviceName) are properly utilized in the telemetry setup
  • Configuration values are appropriately sourced from environment variables with fallbacks
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for usage of both configurations to ensure proper integration
echo "Searching for NewRelic OTLP usage..."
rg -l "otlpEndpoint|otlpLicenseKey" app/client/src

echo -e "\nSearching for observability config usage..."
rg -l "observability.*deploymentName|observability.*serviceInstanceId|observability.*serviceName" app/client/src

Length of output: 502


Script:

#!/bin/bash
# Let's examine the implementation details of these configurations
echo "Checking NewRelic OTLP implementation..."
rg -A 10 "otlpEndpoint|otlpLicenseKey" app/client/src/UITelemetry/auto-otel-web.ts

echo -e "\nChecking observability config usage..."
rg -A 10 "observability" app/client/src/ce/configs/index.ts

echo -e "\nChecking for any OpenTelemetry initialization..."
rg "OpenTelemetry|otel" app/client/src/UITelemetry/

Length of output: 3852

app/client/src/UITelemetry/auto-otel-web.ts (4)

41-43: LGTM! Resource attributes properly configured

The resource attributes are correctly configured using the new semantic conventions.


87-89: LGTM! Consistent resource attribution

Resource attributes are consistently applied across both tracer and meter providers.


73-73: LGTM! Standard W3C propagator is a better choice

Using the standard W3CTraceContextPropagator improves interoperability.

#!/bin/bash
# Verify if custom propagator is completely removed
rg "CustomW3CTraceContextPropagator" --type ts

7-10: Consider stability implications of incubating conventions

The semantic conventions are imported from the incubating package which may be subject to breaking changes in future releases.

Also applies to: 30-33

app/client/src/ce/configs/index.ts (3)

16-19: LGTM: Clean interface addition for observability config.

The new observability interface is well-structured and follows the existing pattern.


179-186: LGTM: Config processing follows established patterns.

The implementation of observability config processing is consistent with the existing codebase patterns.


283-286: 🛠️ Refactor suggestion

Review hardcoded serviceName value.

The serviceName: "frontend" is hardcoded. Consider making it configurable through environment variables for consistency with other properties.

-      serviceName: "frontend",
+      serviceName: process.env.APPSMITH_SERVICE_NAME || "frontend",
app/client/package.json (1)

75-75: Consider security implications of auto-instrumentation.

The new dependency @opentelemetry/auto-instrumentations-web automatically instruments all web requests. Ensure this aligns with your security requirements and doesn't expose sensitive data in traces.

✅ Verification successful

Let me search for OpenTelemetry configuration and setup to better understand how auto-instrumentation is being used.


Auto-instrumentation is properly configured with security considerations

The implementation in UITelemetry/auto-otel-web.ts shows:

  • Explicit resource URLs are ignored in instrumentation configuration
  • Custom PageLoadInstrumentation is used instead of default auto-instrumentation
  • Proper configuration of tracer provider with deployment context
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if there are any existing security policies or configurations for tracing
rg -l "opentelemetry|OTEL|telemetry" | grep -i "security|config|environment"

Length of output: 78


Script:

#!/bin/bash
# Search for OpenTelemetry configuration files and settings
rg -l "opentelemetry|OTEL|telemetry" --type js --type ts --type json

# Look for environment variables or configuration related to telemetry
rg "OTEL_|opentelemetry" .env* *config* 2>/dev/null

# Check for any tracing or instrumentation setup code
rg -A 5 "new TracerProvider|instrumentations:|WebTracerProvider" --type js --type ts

Length of output: 3364

Comment on lines +113 to +117
getWebAutoInstrumentations({
"@opentelemetry/instrumentation-xml-http-request": {
enabled: true,
},
}),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Consider additional XHR instrumentation configuration

While the basic setup is good, consider enhancing the XHR instrumentation with:

  • URL ignore patterns (similar to PageLoadInstrumentation)
  • Custom headers propagation rules
  • Error handling configuration

Example configuration:

 getWebAutoInstrumentations({
   "@opentelemetry/instrumentation-xml-http-request": {
     enabled: true,
+    ignoreUrls: [browserAgentEndpoint, otlpEndpoint, smartlookBaseDomain],
+    propagateTraceHeaderCorsUrls: /.*/,  // Configure URLs where trace headers should be propagated
+    clearTimingResources: true,
   },
 }),

Committable suggestion was skipped due to low confidence.

KelvinOm
KelvinOm previously approved these changes Oct 25, 2024
@dvj1988
Copy link
Contributor

dvj1988 commented Oct 25, 2024

/build-deploy-preview skip-tests=true

Copy link

Deploying Your Preview: https://github.com/appsmithorg/appsmith/actions/runs/11517104531.
Workflow: On demand build Docker image and deploy preview.
skip-tests: true.
env: ``.
PR: 37101.
recreate: .

Copy link

Deploy-Preview-URL: https://ce-37101.dp.appsmith.com

@nidhi-nair
Copy link
Contributor Author

/build-deploy-preview skip-tests=true

Copy link

Deploying Your Preview: https://github.com/appsmithorg/appsmith/actions/runs/11521229053.
Workflow: On demand build Docker image and deploy preview.
skip-tests: true.
env: ``.
PR: 37101.
recreate: .

Copy link

Deploy-Preview-URL: https://ce-37101.dp.appsmith.com

@nidhi-nair
Copy link
Contributor Author

/build-deploy-preview skip-tests=true

Copy link

Deploying Your Preview: https://github.com/appsmithorg/appsmith/actions/runs/11521577149.
Workflow: On demand build Docker image and deploy preview.
skip-tests: true.
env: ``.
PR: 37101.
recreate: .

Copy link
Contributor

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

🧹 Outside diff range and nitpick comments (1)
app/client/public/index.html (1)

231-234: Consider documenting the observability configuration.

The observability configuration looks good, but would benefit from a brief comment explaining:

  • The purpose of these properties
  • The expected format/constraints of serviceInstanceId
  • Why "appsmith-0" was chosen as the default
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 554635b and 732ab2d.

📒 Files selected for processing (1)
  • app/client/public/index.html (1 hunks)
🔇 Additional comments (1)
app/client/public/index.html (1)

232-233: Verify the default values.

Please confirm that:

  1. "self-hosted" is the appropriate default for deploymentName
  2. "appsmith-0" is the intended default for serviceInstanceId
✅ Verification successful

Default values are consistent across the codebase

The verification confirms that both default values are consistently used:

  • "self-hosted" appears as the default deploymentName in multiple configuration files and utilities
  • "appsmith-0" is used as the default serviceInstanceId in the same configuration contexts
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other occurrences of these default values to ensure consistency
rg "self-hosted" --type ts --type js
rg "appsmith-0" --type ts --type js

Length of output: 1220

Copy link

Deploy-Preview-URL: https://ce-37101.dp.appsmith.com

@nidhi-nair
Copy link
Contributor Author

/build-deploy-preview skip-tests=true

Copy link

Deploying Your Preview: https://github.com/appsmithorg/appsmith/actions/runs/11522024377.
Workflow: On demand build Docker image and deploy preview.
skip-tests: true.
env: ``.
PR: 37101.
recreate: .

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Outside diff range and nitpick comments (3)
app/client/src/sagas/ActionExecution/PluginActionSaga.ts (3)

Line range hint 1442-1452: Consider enhancing error type granularity.

The error handling could be more specific by:

  1. Creating distinct error types for different failure scenarios
  2. Adding error codes for better error tracking
-    const isError = isErrorResponse(response);
+    const { errorCode, isError } = isErrorResponse(response);
     yield validateResponse(response);
     payload = createActionExecutionResponse(response);
+    if (isError) {
+      payload.errorCode = errorCode;
+    }

Line range hint 1439-1452: Consider adding rate limiting for action execution.

To prevent abuse, consider implementing rate limiting for action execution, especially for file uploads and resource-intensive operations.


Line range hint 1439-1452: Add JSDoc comments for better documentation.

Consider adding JSDoc comments to document the response format and possible error scenarios.

+/**
+ * Executes the action and handles the response
+ * @param formData - The form data containing action parameters
+ * @param timeout - Optional timeout for the action
+ * @returns {ActionExecutionResponse} - The execution response
+ * @throws {PluginActionExecutionError} - When execution fails
+ */
 response = yield ActionAPI.executeAction(formData, timeout);
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 732ab2d and 576b5da.

📒 Files selected for processing (3)
  • app/client/src/UITelemetry/generateTraces.ts (0 hunks)
  • app/client/src/api/ActionAPI.tsx (1 hunks)
  • app/client/src/sagas/ActionExecution/PluginActionSaga.ts (1 hunks)
💤 Files with no reviewable changes (1)
  • app/client/src/UITelemetry/generateTraces.ts
🧰 Additional context used
🪛 Biome
app/client/src/api/ActionAPI.tsx

[error] 237-237: Using this in a static context can be confusing.

this refers to the class.
Unsafe fix: Use the class name instead.

(lint/complexity/noThisInStatic)

🔇 Additional comments (1)
app/client/src/sagas/ActionExecution/PluginActionSaga.ts (1)

1439-1439: Verify tracing functionality after parameter removal.

The removal of parentSpan parameter from ActionAPI.executeAction call might affect distributed tracing capabilities.

✅ Verification successful

Based on the search results, I can see that the tracing functionality is well-maintained throughout the codebase. Let me verify the specific changes to ActionAPI.executeAction to ensure the tracing is handled correctly.


Let me check how tracing is handled in the ActionAPI implementation.


Let me check the executeAction method implementation specifically.


Let me try a broader search to find the executeAction method.


Removal of parentSpan parameter is safe and aligned with codebase changes

The removal of parentSpan parameter from ActionAPI.executeAction is correct as:

  1. The method now only handles core API execution with formData and timeout
  2. Tracing is properly managed at the saga level where executeAction is called
  3. The codebase shows consistent tracing patterns using startRootSpan and startNestedSpan at appropriate abstraction levels
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other tracing-related code that might be affected
rg -A 5 'parentSpan|OtlpSpan|startRootSpan|endSpan' --type ts

Length of output: 39447


Script:

#!/bin/bash
# Search for ActionAPI.executeAction implementation
ast-grep --pattern 'executeAction($$$) {
  $$$
}'

# Also check the file directly
rg -A 10 "executeAction.*formData.*timeout" --type ts

Length of output: 1044


Script:

#!/bin/bash
# Search for ActionAPI implementation and its executeAction method
rg -A 10 "class ActionAPI" --type ts

Length of output: 796


Script:

#!/bin/bash
# Search for executeAction method in ActionAPI
rg -B 5 -A 15 "executeAction.*formData.*timeout" app/client/src/api/ActionAPI.tsx

Length of output: 83


Script:

#!/bin/bash
# Search for executeAction method with a broader pattern
ast-grep --pattern 'executeAction($$$) {
  $$$
}'

# Also try with ripgrep for any executeAction definition
rg -B 5 -A 15 "static.*executeAction" --type ts

Length of output: 1431

return wrapFnWithParentTraceContext(parentSpan, async () => {
return await this.executeApiCall(executeAction, timeout);
});
return await this.executeApiCall(executeAction, timeout);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Replace this with class name in static context.

Using this in a static method can be confusing and is considered a bad practice.

Apply this fix:

-    return await this.executeApiCall(executeAction, timeout);
+    return await ActionAPI.executeApiCall(executeAction, timeout);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
return await this.executeApiCall(executeAction, timeout);
return await ActionAPI.executeApiCall(executeAction, timeout);
🧰 Tools
🪛 Biome

[error] 237-237: Using this in a static context can be confusing.

this refers to the class.
Unsafe fix: Use the class name instead.

(lint/complexity/noThisInStatic)

Copy link

Deploy-Preview-URL: https://ce-37101.dp.appsmith.com

@nidhi-nair
Copy link
Contributor Author

/build-deploy-preview skip-tests=true

Copy link

Deploying Your Preview: https://github.com/appsmithorg/appsmith/actions/runs/11565878135.
Workflow: On demand build Docker image and deploy preview.
skip-tests: true.
env: ``.
PR: 37101.
recreate: .

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 576b5da and c32f0d5.

📒 Files selected for processing (1)
  • app/client/src/UITelemetry/auto-otel-web.ts (4 hunks)
🔇 Additional comments (3)
app/client/src/UITelemetry/auto-otel-web.ts (3)

7-10: LGTM: Updated semantic convention imports

The migration to standardized OpenTelemetry semantic conventions improves maintainability.


29-32: LGTM: Clean configuration extraction

The destructuring pattern improves code readability and maintainability.


111-115: Previous review comment about XHR configuration remains valid

The suggestion to add URL ignore patterns and header propagation configuration is still relevant for proper distributed tracing implementation.

Comment on lines +40 to +42
[ATTR_DEPLOYMENT_NAME]: deploymentName,
[ATTR_SERVICE_INSTANCE_ID]: serviceInstanceId,
[ATTR_SERVICE_NAME]: serviceName,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Consider extracting duplicate resource configuration

The same resource configuration is duplicated between tracer and meter providers.

Consider extracting the resource configuration:

+const telemetryResource = new Resource({
+  [ATTR_DEPLOYMENT_NAME]: deploymentName,
+  [ATTR_SERVICE_INSTANCE_ID]: serviceInstanceId,
+  [ATTR_SERVICE_NAME]: serviceName,
+});

 const tracerProvider = new WebTracerProvider({
-  resource: new Resource({
-    [ATTR_DEPLOYMENT_NAME]: deploymentName,
-    [ATTR_SERVICE_INSTANCE_ID]: serviceInstanceId,
-    [ATTR_SERVICE_NAME]: serviceName,
-  }),
+  resource: telemetryResource,
 });

 const meterProvider = new MeterProvider({
-  resource: new Resource({
-    [ATTR_DEPLOYMENT_NAME]: deploymentName,
-    [ATTR_SERVICE_INSTANCE_ID]: serviceInstanceId,
-    [ATTR_SERVICE_NAME]: serviceName,
-  }),
+  resource: telemetryResource,

Also applies to: 85-87

Copy link

Deploy-Preview-URL: https://ce-37101.dp.appsmith.com

vsvamsi1
vsvamsi1 previously approved these changes Oct 29, 2024
dvj1988
dvj1988 previously approved these changes Oct 29, 2024
@nidhi-nair nidhi-nair dismissed stale reviews from dvj1988 and vsvamsi1 via 0cefb16 October 29, 2024 05:24
Copy link
Contributor

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

🧹 Outside diff range and nitpick comments (1)
app/client/jest.config.js (1)

102-105: Consider extracting common configuration patterns.

The observability configuration follows the same pattern as other feature configurations. Consider creating a shared configuration schema to ensure consistency across different environments.

This would help:

  • Maintain consistency across environments
  • Validate configuration structure
  • Make updates more maintainable
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between c32f0d5 and 0cefb16.

📒 Files selected for processing (1)
  • app/client/jest.config.js (1 hunks)
🔇 Additional comments (1)
app/client/jest.config.js (1)

102-105: LGTM! Verify consistency with other environments.

The observability configuration is appropriately set up for the Jest test environment.

Let's verify similar configuration exists in other environment files:

✅ Verification successful

Observability configuration is consistent with the application's setup

The observability configuration in jest.config.js aligns with the application-wide observability settings found in:

  • app/client/src/ce/configs/types.ts (type definitions)
  • app/client/src/ce/configs/index.ts (configuration implementation)
  • app/client/src/UITelemetry/auto-otel-web.ts (telemetry usage)

The values match the expected format with deploymentName and serviceInstanceId properties.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for observability configuration patterns in other environment files
rg -g '*.{js,ts,json}' -A 2 'observability.*:.*{' 

Length of output: 153


Script:

#!/bin/bash
# Search for observability configuration patterns in other environment files
rg -g '*.{js,ts,json}' "observability.*deploymentName|observability.*serviceInstanceId" -A 2

Length of output: 691


Script:

#!/bin/bash
# Search for any observability configuration patterns
rg -g '*.{js,ts,json}' "observability" -B 2 -A 2

Length of output: 183064


Script:

#!/bin/bash
# Look for configuration files that might contain observability settings
fd -e js -e json -e ts "config|settings" --type f --exec grep -l "observability" {} \;

Length of output: 117

@nidhi-nair nidhi-nair added the ok-to-test Required label for CI label Oct 29, 2024
@nidhi-nair nidhi-nair merged commit 27bdeb9 into release Oct 29, 2024
30 checks passed
@nidhi-nair nidhi-nair deleted the chore/tracing-client branch October 29, 2024 05:55
github-actions bot pushed a commit to Zeral-Zhang/appsmith that referenced this pull request Nov 20, 2024
@coderabbitai coderabbitai bot mentioned this pull request Dec 24, 2024
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ok-to-test Required label for CI skip-changelog Adding this label to a PR prevents it from being listed in the changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants