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

fix: Update default Otel Attribute from method_name to method #2833

Merged
merged 5 commits into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions gax-java/gax/clirr-ignored-differences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,10 @@
<className>com/google/api/gax/rpc/StubSettings</className>
<method>* getServiceName()</method>
</difference>
<!-- Ignore all field name changes as MetricsTracer is InternalApi -->
<difference>
<differenceType>6011</differenceType>
<className>com/google/api/gax/tracing/MetricsTracer</className>
<field>*</field>
</difference>
</differences>
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
@BetaApi
@InternalApi
public class MetricsTracer implements ApiTracer {
public static final String METHOD_NAME_ATTRIBUTE = "method_name";
public static final String METHOD_ATTRIBUTE = "method";
public static final String LANGUAGE_ATTRIBUTE = "language";
public static final String STATUS_ATTRIBUTE = "status";
public static final String DEFAULT_LANGUAGE = "Java";
Expand All @@ -67,7 +67,7 @@ public class MetricsTracer implements ApiTracer {
private final AtomicBoolean operationFinished;

public MetricsTracer(MethodName methodName, MetricsRecorder metricsRecorder) {
this.attributes.put(METHOD_NAME_ATTRIBUTE, methodName.toString());
this.attributes.put(METHOD_ATTRIBUTE, methodName.toString());
this.attributes.put(LANGUAGE_ATTRIBUTE, DEFAULT_LANGUAGE);
this.metricsRecorder = metricsRecorder;
this.operationFinished = new AtomicBoolean();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ void testNewTracer_hasCorrectNumberAttributes_hasDefaultAttributes() {
(MetricsTracer) metricsTracerFactory.newTracer(parent, spanName, OperationType.Unary);
Map<String, String> attributes = metricsTracer.getAttributes();
Truth.assertThat(attributes.size()).isEqualTo(DEFAULT_ATTRIBUTES_COUNT);
Truth.assertThat(attributes.get(MetricsTracer.METHOD_NAME_ATTRIBUTE))
Truth.assertThat(attributes.get(MetricsTracer.METHOD_ATTRIBUTE))
.isEqualTo("testService.testMethod");
Truth.assertThat(attributes.get(MetricsTracer.LANGUAGE_ATTRIBUTE))
.isEqualTo(MetricsTracer.DEFAULT_LANGUAGE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ void setUp() {

private ImmutableMap<String, String> getAttributes(Code statusCode) {
return ImmutableMap.of(
"status",
MetricsTracer.STATUS_ATTRIBUTE,
statusCode.toString(),
"method_name",
MetricsTracer.METHOD_ATTRIBUTE,
DEFAULT_METHOD_NAME,
"language",
MetricsTracer.LANGUAGE_ATTRIBUTE,
MetricsTracer.DEFAULT_LANGUAGE);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ void testGrpc_operationSucceeded_recordsMetrics() throws InterruptedException {

Map<String, String> expectedAttributes =
ImmutableMap.of(
MetricsTracer.METHOD_NAME_ATTRIBUTE,
MetricsTracer.METHOD_ATTRIBUTE,
"Echo.Echo",
MetricsTracer.LANGUAGE_ATTRIBUTE,
MetricsTracer.DEFAULT_LANGUAGE);
Expand All @@ -333,7 +333,7 @@ void testHttpJson_operationSucceeded_recordsMetrics() throws InterruptedExceptio

Map<String, String> expectedAttributes =
ImmutableMap.of(
MetricsTracer.METHOD_NAME_ATTRIBUTE,
MetricsTracer.METHOD_ATTRIBUTE,
"google.showcase.v1beta1.Echo/Echo",
MetricsTracer.LANGUAGE_ATTRIBUTE,
MetricsTracer.DEFAULT_LANGUAGE);
Expand Down Expand Up @@ -363,7 +363,7 @@ void testGrpc_operationCancelled_recordsMetrics() throws Exception {

Map<String, String> expectedAttributes =
ImmutableMap.of(
MetricsTracer.METHOD_NAME_ATTRIBUTE,
MetricsTracer.METHOD_ATTRIBUTE,
"Echo.Block",
MetricsTracer.LANGUAGE_ATTRIBUTE,
MetricsTracer.DEFAULT_LANGUAGE);
Expand Down Expand Up @@ -391,7 +391,7 @@ void testHttpJson_operationCancelled_recordsMetrics() throws Exception {

Map<String, String> expectedAttributes =
ImmutableMap.of(
MetricsTracer.METHOD_NAME_ATTRIBUTE,
MetricsTracer.METHOD_ATTRIBUTE,
"google.showcase.v1beta1.Echo/Block",
MetricsTracer.LANGUAGE_ATTRIBUTE,
MetricsTracer.DEFAULT_LANGUAGE);
Expand Down Expand Up @@ -420,7 +420,7 @@ void testGrpc_operationFailed_recordsMetrics() throws InterruptedException {

Map<String, String> expectedAttributes =
ImmutableMap.of(
MetricsTracer.METHOD_NAME_ATTRIBUTE,
MetricsTracer.METHOD_ATTRIBUTE,
"Echo.Block",
MetricsTracer.LANGUAGE_ATTRIBUTE,
MetricsTracer.DEFAULT_LANGUAGE);
Expand Down Expand Up @@ -450,7 +450,7 @@ void testHttpJson_operationFailed_recordsMetrics() throws InterruptedException {

Map<String, String> expectedAttributes =
ImmutableMap.of(
MetricsTracer.METHOD_NAME_ATTRIBUTE,
MetricsTracer.METHOD_ATTRIBUTE,
"google.showcase.v1beta1.Echo/Block",
MetricsTracer.LANGUAGE_ATTRIBUTE,
MetricsTracer.DEFAULT_LANGUAGE);
Expand Down Expand Up @@ -513,7 +513,7 @@ void testGrpc_attemptFailedRetriesExhausted_recordsMetrics() throws Exception {

Map<String, String> expectedAttributes =
ImmutableMap.of(
MetricsTracer.METHOD_NAME_ATTRIBUTE,
MetricsTracer.METHOD_ATTRIBUTE,
"Echo.Echo",
MetricsTracer.LANGUAGE_ATTRIBUTE,
MetricsTracer.DEFAULT_LANGUAGE);
Expand Down Expand Up @@ -581,7 +581,7 @@ void testHttpJson_attemptFailedRetriesExhausted_recordsMetrics() throws Exceptio

Map<String, String> expectedAttributes =
ImmutableMap.of(
MetricsTracer.METHOD_NAME_ATTRIBUTE,
MetricsTracer.METHOD_ATTRIBUTE,
"google.showcase.v1beta1.Echo/Echo",
MetricsTracer.LANGUAGE_ATTRIBUTE,
MetricsTracer.DEFAULT_LANGUAGE);
Expand Down Expand Up @@ -611,7 +611,7 @@ void testGrpc_attemptPermanentFailure_recordsMetrics() throws InterruptedExcepti

Map<String, String> expectedAttributes =
ImmutableMap.of(
MetricsTracer.METHOD_NAME_ATTRIBUTE,
MetricsTracer.METHOD_ATTRIBUTE,
"Echo.Block",
MetricsTracer.LANGUAGE_ATTRIBUTE,
MetricsTracer.DEFAULT_LANGUAGE);
Expand Down Expand Up @@ -639,7 +639,7 @@ void testHttpJson_attemptPermanentFailure_recordsMetrics() throws InterruptedExc

Map<String, String> expectedAttributes =
ImmutableMap.of(
MetricsTracer.METHOD_NAME_ATTRIBUTE,
MetricsTracer.METHOD_ATTRIBUTE,
"google.showcase.v1beta1.Echo/Block",
MetricsTracer.LANGUAGE_ATTRIBUTE,
MetricsTracer.DEFAULT_LANGUAGE);
Expand Down Expand Up @@ -708,7 +708,7 @@ void testGrpc_multipleFailedAttempts_successfulOperation() throws Exception {

Map<String, String> expectedAttributes =
ImmutableMap.of(
MetricsTracer.METHOD_NAME_ATTRIBUTE,
MetricsTracer.METHOD_ATTRIBUTE,
"Echo.Block",
MetricsTracer.LANGUAGE_ATTRIBUTE,
MetricsTracer.DEFAULT_LANGUAGE);
Expand Down Expand Up @@ -778,7 +778,7 @@ void testHttpJson_multipleFailedAttempts_successfulOperation() throws Exception

Map<String, String> expectedAttributes =
ImmutableMap.of(
MetricsTracer.METHOD_NAME_ATTRIBUTE,
MetricsTracer.METHOD_ATTRIBUTE,
"google.showcase.v1beta1.Echo/Block",
MetricsTracer.LANGUAGE_ATTRIBUTE,
MetricsTracer.DEFAULT_LANGUAGE);
Expand Down Expand Up @@ -839,7 +839,7 @@ void recordsCustomAttributes() throws InterruptedException, IOException {
List<MetricData> actualMetricDataList = getMetricDataList(inMemoryMetricReader);
Map<String, String> expectedAttributes =
ImmutableMap.of(
MetricsTracer.METHOD_NAME_ATTRIBUTE,
MetricsTracer.METHOD_ATTRIBUTE,
"Echo.Echo",
MetricsTracer.LANGUAGE_ATTRIBUTE,
MetricsTracer.DEFAULT_LANGUAGE,
Expand Down
Loading