Skip to content

Allow customizing the default environment repository observation convention - #3407

Open
yashdotdev13 wants to merge 3 commits into
spring-cloud:mainfrom
yashdotdev13:fix/2383-custom-observation-convention
Open

yashdotdev13 wants to merge 3 commits into
spring-cloud:mainfrom
yashdotdev13:fix/2383-custom-observation-convention

Conversation

@yashdotdev13

Copy link
Copy Markdown
Contributor

Summary

This PR enables applications to provide a custom ObservationConvention<ObservationEnvironmentRepositoryContext> bean to customize observations generated by environment repositories.

Previously, the ObservationEnvironmentRepositoryWrapper always used the default observation convention, preventing applications from customizing observation tags and metadata.

Changes

  • Allow injecting a custom observation convention into ObservationEnvironmentRepositoryWrapper.
  • Preserve the existing default convention as a fallback when no custom convention is provided.
  • Propagate the custom convention through composite, native, Git/JGit, and SVN environment repository configurations.
  • Support custom conventions in the environment encryption wrapper.
  • Preserve existing constructors for backward compatibility.
  • Add unit and configuration tests covering custom convention injection and observation behavior.

Testing

  • Added tests for custom observation convention behavior.
  • Added configuration tests for Native, Git, and Composite repositories.
  • Verified existing composite and encryption wrapper tests.
  • Ran the Spring Java Format validation.
  • Verified git diff --check.

Fixes #2383

Signed-off-by: 98001yash <yashchauhan.gaya@gmail.com>

@ryanjbaxter ryanjbaxter left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could you add a test that calls findOne with a TestObservationRegistry and a custom convention bean? It should assert that the custom convention's name or key values appear on the observation.

Please add docs to the observability section on how to supply a custom convention bean

Signed-off-by: 98001yash <yashchauhan.gaya@gmail.com>
@yashdotdev13

Copy link
Copy Markdown
Contributor Author

Addressed the review feedback and pushed the updates.

The changes include:

  • Added an integration test verifying that a custom ObservationConvention is used when finding an environment.
  • Updated all ObservationConvention lookups to use getIfUnique().
  • Removed duplicate ObservationRegistry and ObservationConvention fields from the SCM/JGit repository hierarchy by introducing protected accessors in AbstractScmEnvironmentRepository.
  • Added documentation explaining how to configure a custom environment repository observation convention and its default fallback behavior.
  • Restored unrelated formatting changes and preserved existing constructor compatibility.

Validated the changes with the relevant configuration tests and Spring Java Format validation.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ability to customize the default ObservationEnvironmentRepositoryObservationConvention

3 participants