Skip to content
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.javaagent.instrumentation.vaadin;

import io.opentelemetry.instrumentation.api.incubator.semconv.code.CodeAttributesGetter;

public class RpcCodeAttributesGetter implements CodeAttributesGetter<VaadinRpcRequest> {

@Override
public Class<?> getCodeClass(VaadinRpcRequest request) {
return request.getRpcInvocationHandler().getClass();
}

@Override
public String getMethodName(VaadinRpcRequest request) {
return request.getMethodName();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,12 @@ public class VaadinSingletons {
context.with(REQUEST_HANDLER_CONTEXT_KEY, true))
.buildInstrumenter();

RpcCodeAttributesGetter rpcCodeAttributesGetter = new RpcCodeAttributesGetter();
RPC_INSTRUMENTER =
Instrumenter.<VaadinRpcRequest, Void>builder(
GlobalOpenTelemetry.get(), INSTRUMENTATION_NAME, VaadinSingletons::rpcSpanName)
.setEnabled(ExperimentalConfig.get().controllerTelemetryEnabled())
.addAttributesExtractor(CodeAttributesExtractor.create(rpcCodeAttributesGetter))
.buildInstrumenter();

SERVICE_INSTRUMENTER =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

package io.opentelemetry.javaagent.instrumentation.vaadin;

import static io.opentelemetry.instrumentation.testing.junit.code.SemconvCodeStabilityUtil.codeFunctionAssertions;
import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.assertThat;
import static org.awaitility.Awaitility.await;

Expand Down Expand Up @@ -170,7 +171,11 @@ private void assertButtonClick() {
assertThat(spans.get(spans.size() - 1))
.hasName("EventRpcHandler.handle/click")
.hasParent(spans.get(spans.size() - 2))
.hasKind(SpanKind.INTERNAL);
.hasKind(SpanKind.INTERNAL)
.hasAttributesSatisfyingExactly(
codeFunctionAssertions(
"com.vaadin.flow.server.communication.rpc.EventRpcHandler",
"handle"));
Comment on lines +177 to +178
Copy link
Member Author

Choose a reason for hiding this comment

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

this isn't very useful

i'm 50-50 whether it's good for consistency to emit these, or if it's pointless and we should just say no

Copy link
Contributor

Choose a reason for hiding this comment

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

My initial impression was that this would be pointless, but considering that the span name is EventRpcHandler.handle providing the full class name might make it more clear what this span is about. I think I'm currently leaning more towards lets add it.

Copy link
Member Author

Choose a reason for hiding this comment

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

I like consistency

});
});
}
Expand Down