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: support standard OTEL exporter protocol environment variables #63

Merged

Conversation

devnev
Copy link
Contributor

@devnev devnev commented Aug 19, 2024

Reason for This PR

OpenTelemetry has some standardised environment variables for choosing which client to use: https://opentelemetry.io/docs/specs/otel/protocol/exporter/#specify-protocol

In Go, these can be consumed using the 1st-party package https://pkg.go.dev/go.opentelemetry.io/contrib/exporters/autoexport, but because this otel plugin already does some custom stuff, I've opted to try reimplementing the semantics of the spec in the plugin.

Description of Changes

In case the client is unset in the config, check the standardised environment variables OTEL_EXPORTER_OTLP_TRACES_PROTOCOL and OTEL_EXPORTER_OTLP_PROTOCOL for a configured protocol.

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

    • Enhanced configuration flexibility by allowing users to dynamically set the client protocol based on environment variables for improved adaptability to different runtime environments.
  • Bug Fixes

    • Added logging for unrecognized environment variable values to improve error handling and user awareness.

Copy link

coderabbitai bot commented Aug 19, 2024

Caution

Review failed

The pull request is closed.

Walkthrough

The recent changes to the configuration logic enhance client selection flexibility based on OpenTelemetry exporter protocols. The code now dynamically chooses between gRPC and HTTP clients by checking specific environment variables. This improvement allows users to customize their setup through environment variables, resulting in a more adaptable client configuration.

Changes

Files Change Summary
config.go Enhanced InitDefault to dynamically set the client based on OTEL_EXPORTER_OTLP_TRACES_PROTOCOL, with a fallback to OTEL_EXPORTER_OTLP_PROTOCOL. Added setClientFromEnv function for client configuration and logging for unsupported values.

Poem

In the realm of code where rabbits hop,
Configs now flex and never stop.
HTTP or gRPC, it’s your choice,
With environment whispers, rejoice!
A dance of clients, quick and bright,
For telemetry’s joy takes 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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • 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/schema.v2.json

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.

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.

Actionable comments posted: 1

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between b6f53d2 and a582e8e.

Files selected for processing (1)
  • config.go (2 hunks)

config.go Outdated Show resolved Hide resolved
config.go Outdated Show resolved Hide resolved
config.go Outdated Show resolved Hide resolved
config.go Outdated Show resolved Hide resolved
@rustatian
Copy link
Member

Hey @devnev 👋 Thanks you for the PR 👍 I added a few minor comments, feel free to check 😃

@devnev
Copy link
Contributor Author

devnev commented Aug 19, 2024

@rustatian do you think its worth putting effort into making this plugin fully compliant with the spec? I can give it a go, but also I think the goal should be to use https://pkg.go.dev/go.opentelemetry.io/contrib/exporters/autoexport directly, but I imagine that can't be done in a non-breaking way.

@devnev
Copy link
Contributor Author

devnev commented Aug 19, 2024

Maybe a new option auto:bool or something, which, if true, ignores the other settings and uses the autoexport package?

@rustatian
Copy link
Member

@rustatian do you think its worth putting effort into making this plugin fully compliant with the spec? I can give it a go, but also I think the goal should be to use https://pkg.go.dev/go.opentelemetry.io/contrib/exporters/autoexport directly, but I imagine that can't be done in a non-breaking way.

The case is, that PHP and Go (RR) have separate configurations.. But can be both configured via the same envs. I do think, that we should move closer to this goal (making plugin if not fully, but very close to the spec).

@devnev devnev force-pushed the standard-exporter-protocol-envs branch from 83dbe59 to a582e8e Compare August 19, 2024 23:46
@devnev
Copy link
Contributor Author

devnev commented Aug 19, 2024

@rustatian do you think its worth putting effort into making this plugin fully compliant with the spec? I can give it a go, but also I think the goal should be to use https://pkg.go.dev/go.opentelemetry.io/contrib/exporters/autoexport directly, but I imagine that can't be done in a non-breaking way.

The case is, that PHP and Go (RR) have separate configurations.. But can be both configured via the same envs. I do think, that we should move closer to this goal (making plugin if not fully, but very close to the spec).

I've got a follow up commit to bring more of the plugin inline with the spec (I tried putting it in this PR, but it changes scope too much, I'll raise it as a new PR once this is merged) EDIT: you can see the follow-up changes here: https://github.com/devnev/otel/pull/1/files

@devnev devnev force-pushed the standard-exporter-protocol-envs branch from a582e8e to 27f0cca Compare August 20, 2024 00:00
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.

Actionable comments posted: 1

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between a582e8e and 27f0cca.

Files selected for processing (1)
  • config.go (3 hunks)
Additional comments not posted (1)
config.go (1)

86-86: Enhancement: Dynamic client configuration.

The addition of setClientFromEnv enhances flexibility by allowing the client to be set based on environment variables. Ensure that proper logging is in place for unknown protocols to aid in diagnosing configuration issues.

@devnev devnev force-pushed the standard-exporter-protocol-envs branch from 27f0cca to 9163291 Compare August 20, 2024 00:16
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.

Actionable comments posted: 2

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 27f0cca and 9163291.

Files selected for processing (1)
  • config.go (3 hunks)
Additional comments not posted (2)
config.go (2)

136-139: Good practice: Logging unsupported or unknown protocols.

Logging warnings for unsupported or unknown protocols is a good practice as it helps diagnose configuration issues. Ensure that the logs are clear and informative.


84-88: Verify the behavior of setClientFromEnv.

The function now uses setClientFromEnv to set the client based on environment variables. Ensure that this function behaves as expected in all scenarios.

config.go Show resolved Hide resolved
config.go Outdated Show resolved Hide resolved
@devnev devnev requested a review from rustatian August 20, 2024 23:25
@devnev
Copy link
Contributor Author

devnev commented Aug 29, 2024

ping @rustatian

Copy link
Member

@rustatian rustatian left a comment

Choose a reason for hiding this comment

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

Hey @devnev, sorry for the long review 🥲

config.go Outdated Show resolved Hide resolved
config.go Show resolved Hide resolved
@rustatian rustatian added the enhancement New feature or request label Aug 30, 2024
@rustatian rustatian changed the title Supported standard OTEL exporter protocol environment variables feature: support standard OTEL exporter protocol environment variables Aug 30, 2024
@devnev
Copy link
Contributor Author

devnev commented Aug 30, 2024

Hey @devnev, sorry for the long review 🥲

No worries, thanks for the review

@devnev devnev requested a review from rustatian August 30, 2024 09:07
Copy link
Member

@rustatian rustatian left a comment

Choose a reason for hiding this comment

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

Looks good to me, thank you, @devnev 👍
Will be released next week 😃

@rustatian rustatian merged commit dc7a816 into roadrunner-server:master Aug 30, 2024
4 checks passed
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
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

2 participants