-
Notifications
You must be signed in to change notification settings - Fork 3
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: detect resources from environment variables when not set in config #64
Conversation
WalkthroughThe changes involve updates to the initialization processes in Changes
Sequence Diagram(s)sequenceDiagram
participant Config
participant Resource
participant Plugin
Config->>Resource: Call InitDefault
Resource->>Config: Use fillValue for attributes
Plugin->>Resource: Call newResource
Resource-->>Plugin: Return resource and error
Plugin->>Plugin: Handle resource creation
Poem
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? TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 1
Outside diff range, codebase verification and nitpick comments (3)
config.go (1)
Line range hint
68-97
: Refactor and centralization of configuration logic approved.The use of the
fillValue
function centralizes and simplifies the setting of service attributes, enhancing maintainability and flexibility. However, consider adding error handling or logging for the retrieval of environment attributes to ensure robustness in cases where the environment setup might be incorrect.The code changes are approved.
Consider adding error handling or logging for the retrieval of environment attributes.
plugin.go (2)
115-121
: Improved error handling in resource initialization.The changes to handle errors from the
newResource
function enhance the robustness of the initialization process. Consider adding more detailed error messages to aid in debugging when resource creation fails.The code changes are approved.
Consider enhancing error messages for better debugging and traceability.
168-182
: Enhanced resource creation with comprehensive options.The refactoring of the
newResource
function to return both a resource pointer and an error significantly improves error handling capabilities. Consider passing the context from the caller toresource.New
for better traceability and control over timeouts and cancellations.The code changes are approved.
Consider using the caller's context in
resource.New
to enhance traceability and control.
Hello again @devnev 👋 |
@rustatian no rush, but I'll also be on holidays so only checking in here or there |
Hey @devnev 👋 |
Reason for This PR
OpenTelemetry has some standardised environment variables for resource attributes, which this plugin should respect.
https://opentelemetry.io/docs/specs/otel/configuration/sdk-environment-variables/#general-sdk-configuration
Description of Changes
For the four resource attributes that can be defined in the config (service.name, service.version, service.instance.id, service.namespace), if the value is not set in the config, the plugin will try to take the value from the standardised otel environment variables, and only inject a default if no value is found that way.
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]
git commit -s
).CHANGELOG.md
.Summary by CodeRabbit
New Features
Bug Fixes
Documentation