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: Adjust default naming logic for otel resources #66

Merged
merged 2 commits into from
Oct 30, 2024

Conversation

nickdnk
Copy link
Member

@nickdnk nickdnk commented Oct 25, 2024

Reason for This PR

The default naming logic is inconsistent here, as it depends on deprecated fields. If you don't use those deprecate fields, your service name will be empty.

This also changes the default name of the service namespace to include the service name, instead of defaulting to roadrunner (which is still the default service name key).

service_name and service_version are both deprecated at the plugin level.

Description of Changes

[Author TODO: add description of changes.]

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

    • Updated the construction of the service_namespace to incorporate the service name, enhancing clarity and organization.
  • Bug Fixes

    • Deprecated service_name and service_version properties, directing users to utilize resource.service_name and resource.service_version for improved schema structure.
  • Documentation

    • Updated schema documentation to reflect changes in property usage and deprecation notices, promoting a more hierarchical approach to service metadata.
  • Chores

    • Updated the go.temporal.io/sdk dependency version from v1.29.1 to v1.30.0.

@nickdnk nickdnk added documentation Improvements or additions to documentation enhancement New feature or request labels Oct 25, 2024
@nickdnk nickdnk requested a review from rustatian October 25, 2024 22:07
@nickdnk nickdnk self-assigned this Oct 25, 2024
Copy link

coderabbitai bot commented Oct 25, 2024

Walkthrough

The changes involve modifications to the Config struct in config.go and updates to the JSON schema in schema.json. In config.go, the fillValue function call in the InitDefault method has been altered to construct the ServiceNamespaceKey based on the ServiceName field instead of a static string. In schema.json, the default value for the service_namespace property has been updated to reflect this change, and the service_name and service_version properties have been marked as deprecated, with guidance to use new properties under the resource object.

Changes

File Change Summary
config.go Modified fillValue function in InitDefault to set ServiceNamespaceKey using ServiceNameKey and a UUID.
schema.json Updated default value for service_namespace from "RoadRunner-<uuid>" to "<service_name>-<uuid>"; marked service_name and service_version as deprecated.
go.mod Updated dependency version for go.temporal.io/sdk from v1.29.1 to v1.30.0.

Poem

In the meadow where bunnies play,
A change has come to brighten the day.
With names anew, the services gleam,
A hop and a skip, we build our dream!
🐇✨ Let's celebrate this joyful flight,
With UUIDs dancing in the moonlight! 🌙


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between ed7bc6c and f1b617d.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (1)
  • go.mod (1 hunks)
🔇 Additional comments (1)
go.mod (1)

21-21: Verify Temporal SDK version upgrade implications.

The upgrade from v1.29.1 to v1.30.0 looks good and aligns with the PR objectives. However, as this is a minor version bump that could affect service naming behavior, we should verify the changes.

Let's verify the version compatibility and changelog:

✅ Verification successful

Temporal SDK upgrade is safe to proceed

The codebase uses Temporal SDK in a limited way, primarily for OpenTelemetry integration through the opentelemetry.NewTracingInterceptor. This is a stable API that hasn't changed between v1.29.1 and v1.30.0. The implementation only uses core interceptor interfaces and the OpenTelemetry contrib package, which are well-established parts of the SDK.

  • The temporal integration is isolated to temporal_interceptor.go and uses stable APIs
  • No version-specific features are being used
  • The integration focuses on OpenTelemetry tracing which aligns with the PR objectives
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if the new version is stable and if there are any breaking changes

# Test 1: Verify if v1.30.0 is the latest stable version
gh release view v1.30.0 --repo go.temporal.io/sdk

# Test 2: Check the changelog for breaking changes
curl -s https://raw.githubusercontent.com/temporalio/sdk-go/v1.30.0/CHANGELOG.md | grep -A 10 "v1.30.0"

Length of output: 247


Script:

#!/bin/bash
# Let's try a different approach to verify the temporal SDK version
# Check for any direct usage of temporal SDK features that might be affected

# Search for temporal imports and usage
rg -l "temporal.io/sdk" --type go

# Look for any temporal client configurations or workflow-related code
rg "temporal\." --type go -A 3

# Check if there are any tests that might verify the integration
fd -e go -exec grep -l "temporal" {} \;

Length of output: 694


Script:

#!/bin/bash
# Let's examine the temporal interceptor implementation to understand the SDK usage

# Check the temporal interceptor implementation
cat temporal_interceptor.go

# Check the plugin implementation
cat plugin.go

# Look specifically for any version-specific features or configurations
rg "temporal" -A 5 -B 5 temporal_interceptor.go

Length of output: 7994


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.

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.

@rustatian
Copy link
Member

Hey @nickdnk 👋
I've merged another PR with the warnings about deprecation of that API.

@nickdnk
Copy link
Member Author

nickdnk commented Oct 26, 2024

Hey @nickdnk 👋 I've merged another PR with the warnings about deprecation of that API.

Cool. I rebased on it so it's just the ServiceNamespaceKey property that behaves in a more predictable way according to defaults. I'll let you decide if you want this.

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: 0

🧹 Outside diff range and nitpick comments (1)
schema.json (1)

Line range hint 1-124: Consider enhancing schema documentation for migration

The schema structure correctly handles the deprecation of root-level properties in favor of the resource object. To further improve the migration experience, consider:

  1. Adding examples in the schema showing both old and new configurations
  2. Documenting the minimum version where resource properties became available
  3. Adding a note about the relationship between root-level and resource-level properties during transition

This would help users understand the migration path better and prevent confusion about property precedence.

Would you like me to help draft the enhanced documentation and examples?

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between da55bec and ed7bc6c.

📒 Files selected for processing (2)
  • config.go (1 hunks)
  • schema.json (1 hunks)
🔇 Additional comments (4)
schema.json (2)

Line range hint 1-124: Schema structure and validation rules look good

The schema maintains proper JSON Schema standards with:

  • Clear property definitions and constraints
  • Proper type validation
  • Consistent structure between deprecated and new fields

31-31: Clarify the service_name reference in default value template

While the change to use <service_name>-<uuid> makes the namespace more meaningful, please clarify:

  1. Which service_name is used (root level or resource.service_name)?
  2. How is this template processed?

Consider adding documentation about the templating syntax and variable resolution.

Let's check if there's any existing documentation about this templating:

✅ Verification successful

Let me search for more context about this templating mechanism in the codebase.


Based on the findings from config.go, I can now generate a final response as we have clear evidence of how the templating works.

The default value template is correctly implemented but needs documentation

The implementation in config.go shows that <service_name>-<uuid> is properly handled:

  • It uses Resource.ServiceNameKey for the service name
  • Generates a new UUID using uuid.NewString()
  • Combines them using fmt.Sprintf("%s-%s", c.Resource.ServiceNameKey, uuid.NewString())

Please add documentation in the schema or README about this templating mechanism to improve clarity for users.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for documentation about templating syntax
rg -i "template|placeholder|<service_name>|<uuid>" README.md || echo "No documentation found about templating syntax"

Length of output: 165


Script:

#!/bin/bash
# Search for service name and UUID related code
rg -i "service.*name.*uuid" -A 5 -B 5

# Search for any code that might be handling these placeholders
rg -i "replace.*service.*name|replace.*uuid" -A 5 -B 5

# Look for any configuration processing code
fd -e php -e go -e js "config|plugin" --exec rg -l "service.*name"

Length of output: 1518

config.go (2)

Line range hint 39-43: LGTM: Proper deprecation handling

The code appropriately handles the deprecation of service_name and service_version fields by:

  1. Maintaining backward compatibility
  2. Providing clear warning messages
  3. Directing users to the new resource structure

97-97: Verify impact on existing deployments

The change to use ServiceNameKey instead of the static "RoadRunner" prefix for namespace construction is a good improvement that makes the namespace more meaningful. However, this change might affect existing monitoring/tracing setups.

Let's verify the potential impact:

Consider adding a note to the changelog about this behavioral change, as it affects the default namespace construction pattern.

✅ Verification successful

Let me gather more context about the service namespace usage and configuration to better understand the impact.


Based on the gathered information, I can now provide the final response:

ServiceNamespaceKey change is safe to proceed

The change from static "RoadRunner" prefix to dynamic service name is safe as:

  • No hardcoded dependencies on the RoadRunner-prefixed namespace format were found
  • The namespace is only used internally for telemetry identification
  • The UUID suffix maintains uniqueness regardless of the prefix
  • The schema.json only defines the field structure without any prefix assumptions

The change improves observability by making services more identifiable in monitoring systems while maintaining backward compatibility through the same configuration key (service_namespace).

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any hardcoded references to RoadRunner-prefixed namespaces
rg -l 'RoadRunner-[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}'

# Search for any configuration files that might be affected
fd -e yaml -e json -e toml | xargs rg 'service_namespace'

Length of output: 182


Script:

#!/bin/bash
# Check the schema definition for service_namespace
cat schema.json | jq '.[] | select(.service_namespace != null)'

# Look for any tests or code that might be relying on the namespace format
rg -A 3 -B 3 'ServiceNamespaceKey'

# Check for any existing configuration examples
fd -e yaml -e json -e toml -e md | xargs rg -l 'service.*namespace'

Length of output: 1755

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.

LGTM, thanks @nickdnk 👍

@rustatian
Copy link
Member

That can be merged even on failing CI. Waiting for the fix from Temporal.

@rustatian rustatian merged commit 81d06a8 into master Oct 30, 2024
7 checks passed
@rustatian rustatian deleted the fix_defaults branch October 30, 2024 13:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants