Skip to content

Commit

Permalink
stats/opentelemetry: Add e2e testing for CSM Observability (#7279)
Browse files Browse the repository at this point in the history
  • Loading branch information
zasweq authored Jun 10, 2024
1 parent c4753c3 commit 3267089
Show file tree
Hide file tree
Showing 6 changed files with 1,475 additions and 384 deletions.
15 changes: 2 additions & 13 deletions stats/opentelemetry/client_metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func (h *clientStatsHandler) initializeMetrics() {

func (h *clientStatsHandler) unaryInterceptor(ctx context.Context, method string, req, reply any, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error {
ci := &callInfo{
target: h.determineTarget(cc),
target: cc.CanonicalTarget(),
method: h.determineMethod(method, opts...),
}
ctx = setCallInfo(ctx, ci)
Expand All @@ -83,17 +83,6 @@ func (h *clientStatsHandler) unaryInterceptor(ctx context.Context, method string
return err
}

// determineTarget determines the target to record attributes with. This will be
// "other" if target filter is set and specifies, the target name as is
// otherwise.
func (h *clientStatsHandler) determineTarget(cc *grpc.ClientConn) string {
target := cc.CanonicalTarget()
if f := h.options.MetricsOptions.TargetAttributeFilter; f != nil && !f(target) {
target = "other"
}
return target
}

// determineMethod determines the method to record attributes with. This will be
// "other" if StaticMethod isn't specified or if method filter is set and
// specifies, the method name as is otherwise.
Expand All @@ -108,7 +97,7 @@ func (h *clientStatsHandler) determineMethod(method string, opts ...grpc.CallOpt

func (h *clientStatsHandler) streamInterceptor(ctx context.Context, desc *grpc.StreamDesc, cc *grpc.ClientConn, method string, streamer grpc.Streamer, opts ...grpc.CallOption) (grpc.ClientStream, error) {
ci := &callInfo{
target: h.determineTarget(cc),
target: cc.CanonicalTarget(),
method: h.determineMethod(method, opts...),
}
ctx = setCallInfo(ctx, ci)
Expand Down
Loading

0 comments on commit 3267089

Please sign in to comment.