这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@hgiasac
Copy link
Collaborator

@hgiasac hgiasac commented Nov 16, 2025

This pull request refactors OpenTelemetry-related utility functions by moving them from the main gotel package into a new dedicated package, otelutils. This improves code organization and separation of concerns. All usages of these utilities in the tracing middleware have been updated to reference the new package.

Refactoring and code organization:

  • Created new otelutils package containing reusable OpenTelemetry utility functions, including SetSpanHeaderAttributes, NewTelemetryHeaders, IsSensitiveHeader, MaskString, and SplitHostPort. This moves them out of the main gotel package for better modularity.
  • Removed the above utility functions and related variables from utils.go in the gotel package, as they are now provided by otelutils.
  • Updated imports in middleware.go to use otelutils for OpenTelemetry utilities.

Middleware usage updates:

  • Replaced all calls to the moved utility functions in middleware.go to use the new otelutils package, ensuring correct references throughout the tracing middleware. [1] [2] [3] [4] [5]

Testing updates:

  • Renamed the test file for these utilities to otelutils/utils_test.go and updated its package declaration to match the new package.

@hgiasac hgiasac requested a review from Copilot November 16, 2025 14:58
Copilot finished reviewing on behalf of hgiasac November 16, 2025 15:00
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors OpenTelemetry utility functions by moving them from the main gotel package into a new dedicated otelutils subpackage, improving code organization and modularity.

  • Introduces the otelutils package with reusable OpenTelemetry utility functions
  • Updates all references in existing code to use the new package location
  • Maintains backward compatibility by properly exporting all moved functions

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
utils.go Removes OpenTelemetry-specific utility functions that were moved to otelutils package, retaining only general-purpose utilities
tracer.go Updates import to reference otelutils.UserVisibilityAttribute from the new package
provider.go Removes UserVisibilityAttribute declaration (now in otelutils) and unused attribute import
otelutils/utils_test.go Updates package declaration to otelutils to match the new package location
otelutils/utils.go Creates new package containing all OpenTelemetry utility functions moved from main package
middleware.go Updates all function calls to use otelutils package prefix for SplitHostPort, NewTelemetryHeaders, and SetSpanHeaderAttributes

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@@ -0,0 +1,158 @@
// Package otelutils contain reusable utilities for OpenTelemetry attributes.
Copy link

Copilot AI Nov 16, 2025

Choose a reason for hiding this comment

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

The package comment has a grammatical error. It should be "contains" instead of "contain" since "Package otelutils" is singular.

Suggested fix:

// Package otelutils contains reusable utilities for OpenTelemetry attributes.
Suggested change
// Package otelutils contain reusable utilities for OpenTelemetry attributes.
// Package otelutils contains reusable utilities for OpenTelemetry attributes.

Copilot uses AI. Check for mistakes.
@hgiasac hgiasac merged commit 3edb868 into main Nov 16, 2025
7 checks passed
@hgiasac hgiasac deleted the move-utils-subpackage branch November 16, 2025 15:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant