Open wapkch opened 1 year ago
The templatedUrl from context.getCarrier().requestTemplate().methodMetadata().template().url() will be /post, which isn't a valid url that skywalking agent can accept.
So what is the valid URL? Isn't /post
a valid templated URL ?
cc @jonatan-ivanov @shakuzen for example of using Skywalking with Micrometer Observation
The templatedUrl from context.getCarrier().requestTemplate().methodMetadata().template().url() will be /post, which isn't a valid url that skywalking agent can accept.
So what is the valid URL? Isn't
/post
a valid templated URL ?cc @jonatan-ivanov @shakuzen for example of using Skywalking with Micrometer Observation
/post
is a valid templated URL, but it lacks of a host, so SpanHelper#tryToGetPeer
in skywalking agent will return null:
class SpanHelper {
static String tryToGetPeer(String remoteAddress, KeyValues allKeyValues) {
if (remoteAddress != null) {
return remoteAddress;
}
String result = allKeyValues
.stream()
.filter(keyValue -> "http.url".equalsIgnoreCase(
keyValue.getKey()) || "uri".equalsIgnoreCase(keyValue.getKey())
|| keyValue.getKey().contains("uri") || keyValue.getKey().contains("url")
)
.findFirst()
.map(KeyValue::getValue)
.orElse("unknown");
try {
URI uri = URI.create(result);
if (uri.getHost() == null) {
return null;
}
return uri.getHost() + ":" + uri.getPort();
} catch (Exception ex) {
return null;
}
}
}
which result in ContextManager#createExitSpan
's last param(remotePeer) being null, and then TracingContext#inject will check the peer is not empty and throw IllegalStateException:
package org.apache.skywalking.apm.agent.core.context;
public class TracingContext implements AbstractTracerContext {
public void inject(AbstractSpan exitSpan, ContextCarrier carrier) {
if (!exitSpan.isExit()) {
throw new IllegalStateException("Inject can be done only in Exit Span");
}
ExitTypeSpan spanWithPeer = (ExitTypeSpan) exitSpan;
String peer = spanWithPeer.getPeer();
if (StringUtil.isEmpty(peer)) {
throw new IllegalStateException("Exit span doesn't include meaningful peer information.");
}
...
}
}
File a PR in skywalking that fixes this, I don't think this is a problem with Feign. Apparently we should try to modify the way we tag this in skywalking
File a PR in skywalking that fixes this, I don't think this is a problem with Feign. Apparently we should try to modify the way we tag this in skywalking
Thanks, i will try to do this.
Since URI is inappropriate for peer(https://github.com/apache/skywalking-java/pull/531#discussion_r1197274921). I think remoteServiceName or remoteServiceAddress should be set to FeignContext, so we can use it instead of using templatedUrl as the peer in skywalking.
I don't think I follow. Can you create a draft PR of how you think this should be fixed?
Description
I tried to use Micrometer to report OpenFeign traces to Skywalking OAP server. maven dependencies are following:
Feign Client definition:
ObservationRegistryCustomizer:
When i start the application and invoke
JsonPlaceholderService
loadPosts method, the skywalking-api.log has errors:This is caused by getLowCardinalityKeyValues in DefaultFeignObservationConvention:
The templatedUrl from
context.getCarrier().requestTemplate().methodMetadata().template().url()
will be/post
, which isn't a valid url that skywalking agent can accept.For now, i can define a
CustomFeignObservationConvention
and get the templatedUrl usingcontext.getCarrier().requestTemplate().path()
.But should we change the way for retrieving templatedUrl in
DefaultFeignObservationConvention
? @marcingrzejszczak