Skip to content

Commit

Permalink
add xDS flow uri version log
Browse files Browse the repository at this point in the history
  • Loading branch information
bohhyang committed Dec 20, 2023
1 parent 904c825 commit 19738a4
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions d2/src/main/java/com/linkedin/d2/xds/XdsToD2PropertiesAdaptor.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@

public class XdsToD2PropertiesAdaptor
{
private static final Logger _log = LoggerFactory.getLogger(XdsToD2PropertiesAdaptor.class);
private static final Logger LOG = LoggerFactory.getLogger(XdsToD2PropertiesAdaptor.class);
private static final String D2_CLUSTER_NODE_PREFIX = "/d2/clusters/";
private static final String D2_SERVICE_NODE_PREFIX = "/d2/services/";
private static final String D2_URI_NODE_PREFIX = "/d2/uris/";
Expand Down Expand Up @@ -220,7 +220,7 @@ public void onChanged(XdsClient.NodeUpdate update)
}
catch (PropertySerializationException e)
{
_log.error("Failed to parse D2 service properties from xDS update. Service name: " + serviceName, e);
LOG.error("Failed to parse D2 service properties from xDS update. Service name: " + serviceName, e);
}
}
}
Expand Down Expand Up @@ -269,7 +269,7 @@ public void onChanged(XdsClient.NodeUpdate update)
}
catch (PropertySerializationException e)
{
_log.error("Failed to parse D2 cluster properties from xDS update. Cluster name: " + clusterName, e);
LOG.error("Failed to parse D2 cluster properties from xDS update. Cluster name: " + clusterName, e);
}
}
}
Expand Down Expand Up @@ -388,6 +388,10 @@ private Map<String, UriProperties> toUriProperties(Map<String, XdsD2.D2URI> uriD
{
XdsD2.D2URI d2URI = entry.getValue();
UriProperties uriProperties = _uriPropertiesJsonSerializer.fromProto(d2URI);
if (uriProperties.getVersion() < 0)
{
LOG.warn("xDS data for {} has invalid version: {}", entry.getKey(), uriProperties.getVersion());
}
parsedMap.put(entry.getKey(), uriProperties);
}

Expand Down Expand Up @@ -449,7 +453,7 @@ public void onChanged(XdsClient.D2URIMapUpdate update)
}
catch (PropertySerializationException e)
{
_log.error("Failed to parse D2 uri properties from xDS update. Cluster name: " + _clusterName, e);
LOG.error("Failed to parse D2 uri properties from xDS update. Cluster name: " + _clusterName, e);
}
}
}
Expand All @@ -474,15 +478,15 @@ private void emitSDStatusInitialRequestEvent(String cluster, boolean succeeded)
{
if (_eventEmitter == null)
{
_log.info("Service discovery event emitter in XdsToD2PropertiesAdaptor is null. Skipping emitting events.");
LOG.info("Service discovery event emitter in XdsToD2PropertiesAdaptor is null. Skipping emitting events.");
return;
}

// measure request duration and convert to milli-seconds
long initialFetchDurationMillis = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - _initFetchStart);
if (initialFetchDurationMillis < 0)
{
_log.warn("Failed to log ServiceDiscoveryStatusInitialRequest event, initialFetchStartAt time is greater than current time.");
LOG.warn("Failed to log ServiceDiscoveryStatusInitialRequest event, initialFetchStartAt time is greater than current time.");
return;
}
// emit service discovery status initial request event for success
Expand All @@ -494,7 +498,7 @@ private void emitSDStatusUpdateReceiptEvents(Map<String, UriProperties> updates)
{
if (_eventEmitter == null)
{
_log.info("Service discovery event emitter in XdsToD2PropertiesAdaptor is null. Skipping emitting events.");
LOG.info("Service discovery event emitter in XdsToD2PropertiesAdaptor is null. Skipping emitting events.");
return;
}

Expand Down

0 comments on commit 19738a4

Please sign in to comment.