Skip to main content
Published: August 19 2014, 9:31:00 AMUpdated: July 29 2022, 1:14:32 PM

Enabling call metrics logging with .NET SDK 

Summary

.NET SDK has a feature that lets you monitor the amount of time spent by a call at each phase.  This is a great utility to help you identify performance bottlenecks. 
 


Detailed Description 


Here is a sample C# code using .NET SDK to enable logging call metrics:
 
/*
© 2007-2014 eBay Inc., All Rights Reserved
Licensed under CDDL 1.0 - http://opensource.org/licenses/cddl1.php
*/

using System;
using eBay.Service.Call;
using eBay.Service.Core.Sdk;
using eBay.Service.Util;
using eBay.Service.Core.Soap;

namespace SDK3Examples
{

public class AddItem
{

    public ApiLogger logger;
    public CallMetricsTable metrics;
 
public void GeteBayOfficialTime()
{
  GeteBayOfficialTimeCall apicall = new GeteBayOfficialTimeCall(GetContext);
  apicall.GeteBayOfficialTime();
  //log the metrics for the call
  metrics.GenerateReport(logger);

}

    public ApiContext GetContext()
    {
       ApiContext context = new ApiContext();

  // Credentials for the call
  context.ApiCredential.eBayToken = 'token';

  // Set the URL
  context.SoapApiServerUrl = 'https://api.sandbox.ebay.com/wsapi'; 

  // Set logging
  context.ApiLogManager = newApiLogManager();
  context.ApiLogManager.ApiLoggerList.Add(new eBay.Service.Util.FileLogger('Messages.log', true, true, true));
  context.ApiLogManager.EnableLogging = true;
  logger = context.ApiLogManager.ApiLoggerList[0];

  // Set the version
  context.Version = '485';

 // Enable Call Metrics logging
 metrics = new CallMetricsTable();
 context.CallMetricsTable = metrics;
 context.EnableMetrics = true;


 return context;

    }

}

}


This logs the call metrics in the log file as follows:

[1/4/2021 1:23:16 PM, Informational]
Number of calls recorded: 1

[1/4/2021 1:23:16 PM, Informational]
Total     Setup     Network   Server    Finish    Start Time          

[1/4/2021 1:23:16 PM, Informational]
======================================================================

[1/4/2021 1:23:16 PM, Informational]
8512      7721      392       8         390       2021-01-04 13:23:07.864  

[1/4/2021 1:23:16 PM, Informational]
======================================================================

 

 

How well did this answer your question?
Answers others found helpful

Got thoughts? Click the feedback button – your insights help us improve!