Skip to content

Commit 4e24798

Browse files
committed
fix: formatting
1 parent 28633d6 commit 4e24798

2 files changed

Lines changed: 20 additions & 22 deletions

File tree

opentelemetry/src/main/java/io/grpc/opentelemetry/OpenTelemetryMetricsModule.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -573,13 +573,12 @@ public void serverCallStarted(ServerCallInfo<?, ?> callInfo) {
573573
boolean isSampledToLocalTracing = callInfo.getMethodDescriptor().isSampledToLocalTracing();
574574
isGeneratedMethod = isSampledToLocalTracing;
575575

576-
AttributesBuilder builder = io.opentelemetry.api.common.Attributes.builder()
577-
.put(METHOD_KEY, recordMethodName(fullMethodName, isSampledToLocalTracing));
578-
579-
io.opentelemetry.api.common.Attributes attributes = builder.build();
576+
io.opentelemetry.api.common.Attributes attribute =
577+
io.opentelemetry.api.common.Attributes.of(
578+
METHOD_KEY, recordMethodName(fullMethodName, isSampledToLocalTracing));
580579

581580
if (module.resource.serverCallCountCounter() != null) {
582-
module.resource.serverCallCountCounter().add(1, attributes, otelContext);
581+
module.resource.serverCallCountCounter().add(1, attribute, otelContext);
583582
}
584583
}
585584

@@ -626,7 +625,6 @@ public void streamClosed(Status status) {
626625
AttributesBuilder builder = io.opentelemetry.api.common.Attributes.builder()
627626
.put(METHOD_KEY, recordMethodName(fullMethodName, isGeneratedMethod))
628627
.put(STATUS_KEY, status.getCode().toString());
629-
630628
for (OpenTelemetryPlugin.ServerStreamPlugin plugin : streamPlugins) {
631629
plugin.addLabels(builder);
632630
}

opentelemetry/src/test/java/io/grpc/opentelemetry/OpenTelemetryMetricsModuleTest.java

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,8 @@ public void clientBasicMetrics() {
262262
enabledMetricsMap, disableDefaultMetrics);
263263
OpenTelemetryMetricsModule module = newOpenTelemetryMetricsModule(resource);
264264
OpenTelemetryMetricsModule.CallAttemptsTracerFactory callAttemptsTracerFactory =
265-
new CallAttemptsTracerFactory(module, target, method.getFullMethodName(), emptyList(),
266-
Context.root());
265+
new CallAttemptsTracerFactory(module, target, method.getFullMethodName(), emptyList(),
266+
Context.root());
267267
Metadata headers = new Metadata();
268268
ClientStreamTracer tracer =
269269
callAttemptsTracerFactory.newClientStreamTracer(STREAM_INFO, headers);
@@ -430,8 +430,8 @@ public void clientBasicMetrics_withRetryMetricsEnabled_shouldRecordZeroOrBeAbsen
430430
enabledMetrics, disableDefaultMetrics);
431431
OpenTelemetryMetricsModule module = newOpenTelemetryMetricsModule(resource);
432432
OpenTelemetryMetricsModule.CallAttemptsTracerFactory callAttemptsTracerFactory =
433-
new CallAttemptsTracerFactory(module, target, method.getFullMethodName(), emptyList(),
434-
Context.root());
433+
new CallAttemptsTracerFactory(module, target, method.getFullMethodName(), emptyList(),
434+
Context.root());
435435
ClientStreamTracer tracer =
436436
callAttemptsTracerFactory.newClientStreamTracer(STREAM_INFO, new Metadata());
437437

@@ -499,7 +499,7 @@ public void recordAttemptMetrics() {
499499
OpenTelemetryMetricsModule module = newOpenTelemetryMetricsModule(resource);
500500
OpenTelemetryMetricsModule.CallAttemptsTracerFactory callAttemptsTracerFactory =
501501
new OpenTelemetryMetricsModule.CallAttemptsTracerFactory(module, target,
502-
method.getFullMethodName(), emptyList(), Context.root());
502+
method.getFullMethodName(), emptyList(), Context.root());
503503
ClientStreamTracer tracer =
504504
callAttemptsTracerFactory.newClientStreamTracer(STREAM_INFO, new Metadata());
505505

@@ -956,7 +956,7 @@ public void recordAttemptMetrics_withRetryMetricsEnabled() {
956956
OpenTelemetryMetricsModule module = newOpenTelemetryMetricsModule(resource);
957957
OpenTelemetryMetricsModule.CallAttemptsTracerFactory callAttemptsTracerFactory =
958958
new OpenTelemetryMetricsModule.CallAttemptsTracerFactory(module, target,
959-
method.getFullMethodName(), emptyList(), Context.root());
959+
method.getFullMethodName(), emptyList(), Context.root());
960960

961961
ClientStreamTracer tracer =
962962
callAttemptsTracerFactory.newClientStreamTracer(STREAM_INFO, new Metadata());
@@ -1044,7 +1044,7 @@ public void recordAttemptMetrics_withHedgedCalls() {
10441044
OpenTelemetryMetricsModule module = newOpenTelemetryMetricsModule(resource);
10451045
OpenTelemetryMetricsModule.CallAttemptsTracerFactory callAttemptsTracerFactory =
10461046
new OpenTelemetryMetricsModule.CallAttemptsTracerFactory(module, target,
1047-
method.getFullMethodName(), emptyList(), Context.root());
1047+
method.getFullMethodName(), emptyList(), Context.root());
10481048

10491049
// Create a StreamInfo specifically for hedged attempts
10501050
final ClientStreamTracer.StreamInfo hedgedStreamInfo =
@@ -1125,7 +1125,7 @@ public void clientStreamNeverCreatedStillRecordMetrics() {
11251125
OpenTelemetryMetricsModule module = newOpenTelemetryMetricsModule(resource);
11261126
OpenTelemetryMetricsModule.CallAttemptsTracerFactory callAttemptsTracerFactory =
11271127
new OpenTelemetryMetricsModule.CallAttemptsTracerFactory(module, target,
1128-
method.getFullMethodName(), emptyList(), Context.root());
1128+
method.getFullMethodName(), emptyList(), Context.root());
11291129
fakeClock.forwardTime(3000, MILLISECONDS);
11301130
Status status = Status.DEADLINE_EXCEEDED.withDescription("5 seconds");
11311131
callAttemptsTracerFactory.callEnded(status);
@@ -1234,8 +1234,8 @@ public void clientLocalityMetrics_present() {
12341234
fakeClock.getStopwatchSupplier(), resource, Arrays.asList("grpc.lb.locality"),
12351235
emptyList());
12361236
OpenTelemetryMetricsModule.CallAttemptsTracerFactory callAttemptsTracerFactory =
1237-
new CallAttemptsTracerFactory(module, target, method.getFullMethodName(), emptyList(),
1238-
Context.root());
1237+
new CallAttemptsTracerFactory(module, target, method.getFullMethodName(), emptyList(),
1238+
Context.root());
12391239

12401240
ClientStreamTracer tracer =
12411241
callAttemptsTracerFactory.newClientStreamTracer(STREAM_INFO, new Metadata());
@@ -1304,8 +1304,8 @@ public void clientLocalityMetrics_missing() {
13041304
fakeClock.getStopwatchSupplier(), resource, Arrays.asList("grpc.lb.locality"),
13051305
emptyList());
13061306
OpenTelemetryMetricsModule.CallAttemptsTracerFactory callAttemptsTracerFactory =
1307-
new CallAttemptsTracerFactory(module, target, method.getFullMethodName(), emptyList(),
1308-
Context.root());
1307+
new CallAttemptsTracerFactory(module, target, method.getFullMethodName(), emptyList(),
1308+
Context.root());
13091309

13101310
ClientStreamTracer tracer =
13111311
callAttemptsTracerFactory.newClientStreamTracer(STREAM_INFO, new Metadata());
@@ -1370,8 +1370,8 @@ public void clientBackendServiceMetrics_present() {
13701370
fakeClock.getStopwatchSupplier(), resource, Arrays.asList("grpc.lb.backend_service"),
13711371
emptyList());
13721372
OpenTelemetryMetricsModule.CallAttemptsTracerFactory callAttemptsTracerFactory =
1373-
new CallAttemptsTracerFactory(module, target, method.getFullMethodName(), emptyList(),
1374-
Context.root());
1373+
new CallAttemptsTracerFactory(module, target, method.getFullMethodName(), emptyList(),
1374+
Context.root());
13751375

13761376
ClientStreamTracer tracer =
13771377
callAttemptsTracerFactory.newClientStreamTracer(STREAM_INFO, new Metadata());
@@ -1440,8 +1440,8 @@ public void clientBackendServiceMetrics_missing() {
14401440
fakeClock.getStopwatchSupplier(), resource, Arrays.asList("grpc.lb.backend_service"),
14411441
emptyList());
14421442
OpenTelemetryMetricsModule.CallAttemptsTracerFactory callAttemptsTracerFactory =
1443-
new CallAttemptsTracerFactory(module, target, method.getFullMethodName(), emptyList(),
1444-
Context.root());
1443+
new CallAttemptsTracerFactory(module, target, method.getFullMethodName(), emptyList(),
1444+
Context.root());
14451445

14461446
ClientStreamTracer tracer =
14471447
callAttemptsTracerFactory.newClientStreamTracer(STREAM_INFO, new Metadata());

0 commit comments

Comments
 (0)