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

feature: experimental tracing support #131

Merged
merged 6 commits into from
Dec 3, 2023
Merged

Conversation

rustatian
Copy link
Member

@rustatian rustatian commented Dec 3, 2023

Reason for This PR

closes: roadrunner-server/roadrunner#1782

Description of Changes

  • Experimental support for the OTLP tracing. ./rr -e to activate: link
  • Headers passed to the PHP worker are (example):
"Traceparent":["00-2678b910f57fe3320587f4126a390868-6b87f1600005b643-01"],"Uber-Trace-Id":["2678b910f57fe3320587f4126a390868:6b87f1600005b643:0:1"]

License Acceptance

By submitting this pull request, I confirm that my contribution is made under
the terms of the MIT license.

PR Checklist

[Author TODO: Meet these criteria.]
[Reviewer TODO: Verify that these criteria are met. Request changes if not]

  • All commits in this PR are signed (git commit -s).
  • The reason for this PR is clearly provided (issue no. or explanation).
  • The description of changes is clear and encompassing.
  • Any required documentation changes (code and docs) are included in this PR.
  • Any user-facing changes are mentioned in CHANGELOG.md.
  • All added/changed functionality is tested.

Summary by CodeRabbit

  • New Features

    • Search functionality now available with a new search bar for improved navigation and user experience.
    • OpenTelemetry integration for enhanced tracing and monitoring capabilities.
    • Experimental mode toggle added to the configuration interface.
  • Enhancements

    • Updated gRPC service configuration for better network performance and protocol management.
    • Improved test environment setup in CI/CD pipeline for more reliable and efficient testing.
  • Bug Fixes

    • Adjusted destroy timeout settings in gRPC configurations to ensure proper resource cleanup.
  • Documentation

    • Updated comments and documentation for better clarity and understanding of the codebase.
  • Refactor

    • Codebase refactoring for better structure and maintainability.
  • Tests

    • Expanded test coverage with new tests for gRPC initialization and OpenTelemetry functionality.

Please note that some internal code changes and file names have been omitted for confidentiality.

Signed-off-by: Valery Piashchynski <piashchynski.valery@gmail.com>
@rustatian rustatian added the enhancement New feature or request label Dec 3, 2023
@rustatian rustatian requested a review from wolfy-j December 3, 2023 15:44
@rustatian rustatian self-assigned this Dec 3, 2023
Copy link

coderabbitai bot commented Dec 3, 2023

Walkthrough

The codebase has been updated to introduce OpenTelemetry (OTLP) support for gRPC, focusing on trace collection and configuration. Changes include the addition of new interfaces and fields for experimental features and tracing, adjustments to gRPC server creation to accommodate tracing, and updates to configuration files and tests to support these enhancements.

Changes

File Pattern Change Summary
common/interfaces.go, plugin.go, server.go Added support for experimental features and tracing with OpenTelemetry.
tests/configs/... Updated gRPC service configurations and introduced OpenTelemetry settings.
tests/grpc_plugin_test.go Enhanced tests to include gRPC connections and OpenTelemetry related verifications.
.github/workflows/linux.yml Modified CI/CD pipeline to include Docker-related setup and delays.

Assessment against linked issues

Objective Addressed Explanation
OTLP support for gRPC (#1782)

Poem

In the code where rabbits hop, 🐇💻
Traces flow, they do not stop. 🌐✨
With OTLP now in place,
gRPC moves at a swifter pace. 🚀🐾


Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • If you reply to a review comment from CodeRabbit, the bot will automatically respond.
  • To engage with CodeRabbit bot directly around the specific lines of code in the PR, mention @coderabbitai in your review comment
  • Note: Review comments are made on code diffs or files, not on the PR overview.
  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Note: For conversation with the bot, please use the review comments on code diffs or files.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

Copy link

@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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 9d71a1f and 8328d09.
Files ignored due to filter (4)
  • go.mod
  • go.sum
  • tests/go.mod
  • tests/go.sum
Files selected for processing (7)
  • common/interfaces.go (1 hunks)
  • plugin.go (4 hunks)
  • server.go (1 hunks)
  • status.go (1 hunks)
  • tests/configs/.rr-grpc-init.yaml (1 hunks)
  • tests/configs/.rr-grpc-otel.yaml (1 hunks)
  • tests/grpc_plugin_test.go (1 hunks)
Files skipped from review due to trivial changes (1)
  • status.go
Additional comments: 17
common/interfaces.go (1)
  • 24-25: The addition of the Experimental method to the Configurer interface is consistent with the PR's objective to introduce experimental features. However, this change will require all types that implement the Configurer interface to add an implementation for the Experimental method, which could be a breaking change for existing code. Ensure that all implementations of this interface have been updated accordingly.
plugin.go (7)
  • 10-10: The addition of the OpenTelemetry SDK trace import aligns with the PR's objective to introduce OTLP tracing support.

  • 35-37: The introduction of the Tracer interface is consistent with the PR's objective to standardize tracing behavior.

  • 49-52: The addition of experimental and tracer fields to the Plugin struct aligns with the PR's objective to support experimental OTLP tracing.

  • 121-121: The assignment of a new TracerProvider to p.tracer in the Init method is consistent with the PR's objective to initialize tracing support.

  • 261-263: The update to the Collects method to accept a Tracer interface is consistent with the PR's objective to integrate tracing into the plugin's dependencies.

  • 122-122: The setting of the experimental field based on the cfg.Experimental() method aligns with the PR's objective to conditionally enable experimental features.

  • 32-55: > 💡 NOTE

Codebase verification is a beta feature.

The Configurer interface has been successfully updated to include the Experimental() method as required. The interface definition in ./common/interfaces.go confirms the addition of the Experimental() method.

server.go (1)
  • 48-56: The addition of OpenTelemetry instrumentation to the gRPC server options is consistent with the PR objective and the provided summaries. The use of p.experimental to conditionally add the otelgrpc.NewServerHandler with p.tracer as a parameter aligns with the intended experimental support for OTLP tracing. Ensure that p.tracer is properly initialized before this point and that all necessary configurations are in place for the tracer provider to function correctly.
tests/configs/.rr-grpc-init.yaml (2)
  • 11-18: The changes to the GRPC service configuration in the .rr-grpc-init.yaml file are consistent with the summary provided. The listen address and the proto file have been updated as described.

  • 11-18: > 💡 NOTE

Codebase verification is a beta feature.

The GRPC service configuration changes have been successfully updated to reflect the new listen address and proto file. Additionally, the OTLP tracing support has been configured as indicated by the presence of otelgrpc.NewServerHandler in server.go. The experimental features toggle is referenced in tests/grpc_plugin_test.go and plugin.go, suggesting that the experimental OTLP tracing support is considered in the codebase. Tracing implementation details are found in plugin.go, which includes the Tracer interface and its usage.

tests/configs/.rr-grpc-otel.yaml (3)
  • 22-29: The otel configuration section is well-defined with service details and an exporter set to stderr. However, ensure that the stderr exporter is only used for debugging purposes and that a more suitable exporter is configured for production environments.

  • 28-28: The insecure field is set to false, which suggests that security is a consideration. Verify if additional security configurations are required or if they are set elsewhere.

  • 1-29: The configuration file does not include any explicit reference to the experimental flag or command line option (./rr -e) that is supposed to activate the experimental OTLP tracing support. Confirm if this is intentional or if there should be a configuration option to enable the experimental mode.

tests/grpc_plugin_test.go (3)
  • 106-115: The changes to TestGrpcInit correctly implement a gRPC connection and a ping operation, which aligns with the PR objective to introduce OTLP tracing support and test its functionality.

  • 185-207: The changes to TestGrpcOtel correctly implement a gRPC connection, a ping operation, and verification of log entries related to OpenTelemetry, which aligns with the PR objective to introduce OTLP tracing support and test its functionality.

  • 130-134: Clarify whether the experimental mode for OTLP tracing is intended to be enabled only through configuration files or if it can also be toggled at runtime using the ./rr -e command as mentioned in the PR objective.

Signed-off-by: Valery Piashchynski <piashchynski.valery@gmail.com>
Copy link

@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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 8328d09 and 4978a0f.
Files selected for processing (4)
  • plugin.go (4 hunks)
  • proxy/proxy.go (4 hunks)
  • server.go (2 hunks)
  • tests/grpc_plugin_test.go (1 hunks)
Files skipped from review as they are similar to previous changes (2)
  • server.go
  • tests/grpc_plugin_test.go
Additional comments: 11
plugin.go (5)
  • 6-15: The new imports for OpenTelemetry-related packages align with the PR's objective to introduce experimental OTLP tracing support.

  • 37-39: The introduction of the Tracer interface is consistent with the PR's objective to standardize tracing operations.

  • 41-58: The addition of experimental, tracer, and prop fields to the Plugin struct aligns with the PR's objective to support experimental OTLP tracing.

  • 124-129: The Init method's updates to initialize the tracer and set the experimental flag are in line with the PR's objective to support OTLP tracing.

  • 262-268: The addition of a new dependency fitting for the Tracer interface in the Collects method is consistent with the PR's objective to integrate tracing capabilities.

proxy/proxy.go (6)
  • 16-22: The import of go.opentelemetry.io/otel/propagation aligns with the PR's objective to introduce OTLP tracing support.

  • 65-71: The addition of the prop field to the Proxy struct is consistent with the PR's objective to support OTLP tracing.

  • 77-84: The update to the NewProxy function signature to include the prop parameter is consistent with the PR's objective to support OTLP tracing.

  • 248-254: The addition of the prop.Inject call within the makePayload method aligns with the PR's objective to pass trace information to the PHP worker.

  • 67-71: The use of mu *sync.RWMutex in the Proxy struct and its proper locking and unlocking in the invoke method suggests that the changes are designed to be thread-safe.

  • 248-254: The secure use of the prop.Inject method to inject trace information into the ctxMD map, which is then marshaled and sent to the PHP worker, ensures that sensitive trace information is not leaked externally.

Signed-off-by: Valery Piashchynski <piashchynski.valery@gmail.com>
Signed-off-by: Valery Piashchynski <piashchynski.valery@gmail.com>
Signed-off-by: Valery Piashchynski <piashchynski.valery@gmail.com>
Copy link

@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.

Review Status

Actionable comments generated: 3

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 4978a0f and 4a34082.
Files ignored due to filter (4)
  • go.mod
  • go.sum
  • tests/env/docker-compose-otel.yaml
  • tests/env/otel-collector-config.yml
Files selected for processing (3)
  • .github/workflows/linux.yml (2 hunks)
  • tests/configs/.rr-grpc-otel.yaml (1 hunks)
  • tests/grpc_plugin_test.go (1 hunks)
Additional comments: 7
.github/workflows/linux.yml (2)
  • 95-103: > Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [78-102]

The PR objective mentions the addition of experimental OTLP tracing support, but the hunks show changes related to Docker setup and sleep commands for test environment setup. Please verify that the changes are consistent with the PR's objective.

  • 95-103: > Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [84-97]

The steps for setting up mkcert and generating certificates are added, which is not mentioned in the PR objective or the generated summary. Ensure that these changes are intended and documented.

tests/configs/.rr-grpc-otel.yaml (2)
  • 1-31: The summary provided does not match the changes in the hunk. The hunk shows a configuration file for a gRPC server with OTLP settings, but the summary discusses experimental OTLP tracing support in a server codebase.

  • 1-31: The configuration settings for OTLP in the tests/configs/.rr-grpc-otel.yaml file appear to be correctly formatted and include necessary parameters such as service_name, service_version, service_namespace, service_instance_id, insecure, compress, exporter, and endpoint.

tests/grpc_plugin_test.go (3)
  • 122-209: The changes in the TestGrpcOtel function align with the PR objective of adding experimental OTLP tracing support. The test now includes a gRPC connection setup, a ping operation, and verification of log entries related to OpenTelemetry, which suggests that the OTLP tracing functionality is being tested as expected.

  • 106-120: The updates to the TestGrpcInit function, which include establishing a gRPC connection and performing a ping operation, are correctly reflected in the summary.

  • 203-208: The checks for specific strings in the HTTP response body are appropriate for validating the presence of OTLP trace information in the TestGrpcOtel function.

Signed-off-by: Valery Piashchynski <piashchynski.valery@gmail.com>
Copy link

@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.

Review Status

Actionable comments generated: 3

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 4a34082 and 5ea707a.
Files selected for processing (15)
  • .github/workflows/linux.yml (2 hunks)
  • tests/configs/.rr-grpc-init-duplicate-2.yaml (1 hunks)
  • tests/configs/.rr-grpc-init-duplicate.yaml (1 hunks)
  • tests/configs/.rr-grpc-init-multiple.yaml (1 hunks)
  • tests/configs/.rr-grpc-init.yaml (2 hunks)
  • tests/configs/.rr-grpc-metrics.yaml (1 hunks)
  • tests/configs/.rr-grpc-otel.yaml (1 hunks)
  • tests/configs/.rr-grpc-rq-exception.yaml (1 hunks)
  • tests/configs/.rr-grpc-rq-issue1193.yaml (1 hunks)
  • tests/configs/.rr-grpc-rq-multiple.yaml (1 hunks)
  • tests/configs/.rr-grpc-rq-otlp.yaml (3 hunks)
  • tests/configs/.rr-grpc-rq-tls-rootca.yaml (1 hunks)
  • tests/configs/.rr-grpc-rq-tls.yaml (1 hunks)
  • tests/configs/.rr-grpc-rq.yaml (1 hunks)
  • tests/grpc_plugin_test.go (3 hunks)
Files skipped from review due to trivial changes (2)
  • tests/configs/.rr-grpc-rq-issue1193.yaml
  • tests/configs/.rr-grpc-rq.yaml
Files skipped from review as they are similar to previous changes (2)
  • .github/workflows/linux.yml
  • tests/configs/.rr-grpc-init.yaml
Additional comments: 16
tests/configs/.rr-grpc-init-duplicate-2.yaml (1)
  • 35-35: The change from an integer to a string with a time unit for destroy_timeout is consistent with the PR objective to standardize time units in configuration settings.
tests/configs/.rr-grpc-init-duplicate.yaml (1)
  • 59-62: The change from an integer value to a string with a time unit for destroy_timeout is consistent with the PR objective to standardize time units in configuration settings.
tests/configs/.rr-grpc-init-multiple.yaml (1)
  • 32-35: The change to destroy_timeout from 60 to 60s aligns with the PR objective to standardize time units in configuration settings. This should ensure consistency and clarity in configuration parameters.
tests/configs/.rr-grpc-metrics.yaml (1)
  • 33-36: The changes to the destroy_timeout parameter from an integer to a string with a time unit are consistent with the PR objective of standardizing time units in configuration settings.
tests/configs/.rr-grpc-otel.yaml (1)
  • 1-35: The configuration file .rr-grpc-otel.yaml is well-formed and aligns with the PR objective of adding experimental OTLP tracing support. The otel section is correctly configured to enable tracing with appropriate service identification and endpoint settings. Ensure that the insecure flag is intentional and only used in development or testing environments.
tests/configs/.rr-grpc-rq-exception.yaml (1)
  • 62-65: The change from an integer to a string with a time unit for destroy_timeout is consistent with the PR objective to standardize time units in configuration settings.
tests/configs/.rr-grpc-rq-multiple.yaml (1)
  • 63-66: The changes to the destroy_timeout parameter from an integer to a string with a time unit are consistent with the PR objective to standardize time units in configuration settings.
tests/configs/.rr-grpc-rq-otlp.yaml (4)
  • 29-42: > Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [16-42]

The summary mentions the removal of max_connection_idle, max_connection_age, and max_connection_age_grace settings, but these are not shown in the provided hunks. Please verify if these settings were indeed removed and if the summary needs to be updated.

  • 12-13: The change in logging level from "error" to "debug" is correctly reflected in the hunk.

  • 32-32: The summary states that destroy_timeout was modified from 60 to 60 seconds, but the hunk shows it already includes a time unit. Please verify if this is a change from a previous value without a time unit or if the summary needs to be updated.

  • 38-42: The addition of OpenTelemetry resource configurations is correctly reflected in the hunk.

tests/configs/.rr-grpc-rq-tls-rootca.yaml (1)
  • 67-70: The changes to the destroy_timeout parameter from an integer to a string with a time unit are consistent with the PR objective to standardize time units in configuration settings.
tests/configs/.rr-grpc-rq-tls.yaml (1)
  • 67-68: The change from an integer value to a string with a time unit for destroy_timeout is consistent with the PR objective to standardize time units in configuration settings.
tests/grpc_plugin_test.go (3)
  • 192-192: The previous comment about replacing time.Sleep with a more reliable synchronization mechanism is still valid.

  • 1127-1136: The configuration for the Test_GrpcRqOtlp test function has been updated to enable experimental features, which aligns with the PR objective to introduce experimental OTLP tracing support.

  • 1203-1206: The test captures stderr to a buffer to check for specific log entries related to OTLP tracing. This is a good approach to validate that the tracing functionality is working as expected.

@rustatian rustatian merged commit 7cee267 into master Dec 3, 2023
@rustatian rustatian deleted the feature/otel-metrics branch December 3, 2023 16:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[💡 FEATURE REQUEST]: OTLP support for gRPC
1 participant