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

stats/opentelemetry: separate out interceptors for tracing and metrics #8063

Open
wants to merge 56 commits into
base: master
Choose a base branch
from

Conversation

janardhanvissa
Copy link
Contributor

@janardhanvissa janardhanvissa commented Feb 3, 2025

RELEASE NOTES: None

Copy link

codecov bot commented Feb 3, 2025

Codecov Report

Attention: Patch coverage is 69.88636% with 53 lines in your changes missing coverage. Please review.

Project coverage is 81.93%. Comparing base (775150f) to head (5bb48b3).
Report is 11 commits behind head on master.

Files with missing lines Patch % Lines
stats/opentelemetry/client_tracing.go 58.57% 23 Missing and 6 partials ⚠️
stats/opentelemetry/server_tracing.go 66.66% 7 Missing and 4 partials ⚠️
stats/opentelemetry/client_metrics.go 79.54% 6 Missing and 3 partials ⚠️
stats/opentelemetry/server_metrics.go 73.33% 3 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #8063      +/-   ##
==========================================
- Coverage   82.25%   81.93%   -0.33%     
==========================================
  Files         393      410      +17     
  Lines       39143    40300    +1157     
==========================================
+ Hits        32197    33019     +822     
- Misses       5616     5901     +285     
- Partials     1330     1380      +50     
Files with missing lines Coverage Δ
stats/opentelemetry/opentelemetry.go 76.54% <100.00%> (+1.54%) ⬆️
stats/opentelemetry/server_metrics.go 87.73% <73.33%> (-2.10%) ⬇️
stats/opentelemetry/client_metrics.go 83.33% <79.54%> (-6.07%) ⬇️
stats/opentelemetry/server_tracing.go 74.41% <66.66%> (-25.59%) ⬇️
stats/opentelemetry/client_tracing.go 64.19% <58.57%> (-12.28%) ⬇️

... and 55 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@janardhanvissa janardhanvissa force-pushed the refactor-tracing-metrics branch from 69df069 to 71804b4 Compare February 3, 2025 11:48
@purnesh42H
Copy link
Contributor

@janardhanvissa its not clear what is the intention of this refactor. The follow up from opentelemetry tracing API PR was to create separate interceptors for metrics and traces. Right now, single interceptor is handling both trace and metrics options. Once we have separate unary and stream interceptor each for tracing and metrics, we don't have to check for options disabled/enabled everytime.

Copy link
Contributor

@purnesh42H purnesh42H left a comment

Choose a reason for hiding this comment

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

Please see this discussion https://github.com/grpc/grpc-go/pull/7852/files#r1909469701 and modify accordingly.

@purnesh42H purnesh42H added Type: Internal Cleanup Refactors, etc Area: Observability Includes Stats, Tracing, Channelz, Healthz, Binlog, Reflection, Admin, GCP Observability labels Mar 13, 2025
@purnesh42H purnesh42H added this to the 1.72 Release milestone Mar 13, 2025
Copy link
Contributor

@purnesh42H purnesh42H left a comment

Choose a reason for hiding this comment

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

Please consider the same comments for server metrics and tracing as well.

@janardhanvissa janardhanvissa removed their assignment Mar 20, 2025
method := info.FullMethodName
if h.options.MetricsOptions.MethodAttributeFilter != nil {
if !h.options.MetricsOptions.MethodAttributeFilter(method) {
method = "other"
Copy link
Contributor

Choose a reason for hiding this comment

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

why are you changing this? This is suppose to be other if the method is part of the filtered list. Please revert and don't make unnecessary changes

}
}
server := internal.ServerFromContext.(func(context.Context) *grpc.Server)(ctx)
if server == nil { // Shouldn't happen, defensive programming.
logger.Error("ctx passed into server side stats handler has no grpc server ref")
method = "other"
method = methodName
Copy link
Contributor

Choose a reason for hiding this comment

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

same. Please revert

} else {
isRegisteredMethod := internal.IsRegisteredMethod.(func(*grpc.Server, string) bool)
if !isRegisteredMethod(server, method) {
method = "other"
method = methodName
Copy link
Contributor

Choose a reason for hiding this comment

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

Revert

func (h *serverStatsHandler) TagRPC(ctx context.Context, info *stats.RPCTagInfo) context.Context {
ri := getRPCInfo(ctx)
Copy link
Contributor

Choose a reason for hiding this comment

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

line 185-191 should be down where you are removing attemptInfo stuff. Don't move it at the start. As i mentioned in the office hours, we follow convention of declaring the identifier right before its needed.

}

// HandleRPC implements per RPC tracing and stats implementation.
// HandleRPC handles per RPC attempt stats for server-side metrics collection.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// HandleRPC handles per RPC attempt stats for server-side metrics collection.
// HandleRPC handles per RPC stats implementation.

func (h *clientStatsHandler) TagRPC(ctx context.Context, info *stats.RPCTagInfo) context.Context {
ri := getRPCInfo(ctx)
var ai *attemptInfo
Copy link
Contributor

Choose a reason for hiding this comment

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

same. Please move this entire thing down where you are removing attemptInfo stuff.


// HandleRPC handles per-RPC attempt stats events for tracing.
func (h *clientTracingHandler) HandleRPC(ctx context.Context, rs stats.RPCStats) {
// Fetch the rpcInfo set by a previously registered stats handler.
Copy link
Contributor

Choose a reason for hiding this comment

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

no need of this comment

)

const methodName = "other"
Copy link
Contributor

Choose a reason for hiding this comment

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

Again. Why this unnecessary change? Please revert

@@ -44,3 +80,22 @@ func (h *serverStatsHandler) traceTagRPC(ctx context.Context, ai *attemptInfo) (
ai.traceSpan = span
return ctx, ai
}

// HandleRPC handles per-RPC attempt stats events for tracing.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// HandleRPC handles per-RPC attempt stats events for tracing.
// HandleRPC handles per RPC tracing implementation.


// HandleRPC handles per-RPC attempt stats events for tracing.
func (h *serverTracingHandler) HandleRPC(ctx context.Context, rs stats.RPCStats) {
// Fetch the rpcInfo set by a previously registered stats handler.
Copy link
Contributor

Choose a reason for hiding this comment

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

no need of this comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Observability Includes Stats, Tracing, Channelz, Healthz, Binlog, Reflection, Admin, GCP Observability Type: Internal Cleanup Refactors, etc
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants