manika137 commented on code in PR #8137:
URL: https://github.com/apache/hadoop/pull/8137#discussion_r2652389644


##########
hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/services/AbfsClient.java:
##########
@@ -1643,38 +1718,63 @@ private void resumeTimer() {
    * Initiates a metric call to the Azure Blob FileSystem (ABFS) for 
retrieving file system properties.
    * This method performs a HEAD request to the specified metric URL, using 
default headers and query parameters.
    *
-   * @param tracingContext The tracing context to be used for capturing 
tracing information.
+   * @param metricsData The tracing context to be used for capturing tracing 
information.
    * @throws IOException throws IOException.
    */
-  public void getMetricCall(TracingContext tracingContext) throws IOException {
-    this.isSendMetricCall = true;
+  public void getMetricCall(String metricsData) throws IOException {
+    if (StringUtils.isEmpty(metricsData)) {
+      return;
+    }
     final List<AbfsHttpHeader> requestHeaders = createDefaultHeaders();
-    final AbfsUriQueryBuilder abfsUriQueryBuilder = 
createDefaultUriQueryBuilder();
+    final AbfsUriQueryBuilder abfsUriQueryBuilder
+        = createDefaultUriQueryBuilder();
     abfsUriQueryBuilder.addQuery(QUERY_PARAM_RESOURCE, FILESYSTEM);
 
     // Construct the URL for the metric call
     // In case of blob storage, the URL is changed to DFS URL
-    final URL url = UriUtils.changeUrlFromBlobToDfs(
-        createRequestUrl(new URL(abfsMetricUrl),
-            EMPTY_STRING, abfsUriQueryBuilder.toString()));
+    final URL url = createRequestUrl(getMetricsUrl(),
+        EMPTY_STRING, abfsUriQueryBuilder.toString());
     final AbfsRestOperation op = getAbfsRestOperation(
-            AbfsRestOperationType.GetFileSystemProperties,
-            HTTP_METHOD_HEAD,
-            url,
-            requestHeaders);
+        AbfsRestOperationType.GetFileSystemProperties,
+        HTTP_METHOD_HEAD,
+        url,
+        requestHeaders);
+    TracingContext tracingContext = new TracingContext(
+        TracingContext.validateClientCorrelationID(
+            abfsConfiguration.getClientCorrelationId()),
+        fileSystemId, FSOperationType.GET_ATTR, true,
+        TracingHeaderFormat.AGGREGATED_METRICS_FORMAT,
+        null, metricsData);
     try {
       op.execute(tracingContext);
-    } finally {
-      this.isSendMetricCall = false;
+    } catch (AzureBlobFileSystemException e) {
+      // Ignore the exception and continue.
     }
   }
 
-  public boolean isSendMetricCall() {
-    return isSendMetricCall;
+  public boolean isMetricCollectionEnabled() {
+    return isMetricCollectionEnabled.get();
   }
 
-  public boolean isMetricCollectionEnabled() {
-    return isMetricCollectionEnabled;
+  /**
+   * Getter for metric URL.
+   *
+   * @return metricUrl
+   */
+  @VisibleForTesting
+  public URL getMetricsUrl() {
+    return metricUrl;
+  }
+
+  /**
+   * Setter for metric URL.
+   * Converts blob URL to dfs URL in case of blob storage account.
+   *
+   * @param urlString to be set as metricUrl.
+   * @throws IOException if URL is malformed.
+   */
+  private void setMetricsUrl(String urlString) throws IOException {
+    metricUrl = UriUtils.changeUrlFromBlobToDfs(new URL(urlString));

Review Comment:
   why cant we send it for blob endpoints?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to