Skip to main content
Published: August 19 2014, 9:31:00 AMUpdated: November 28 2020, 3:09:22 PM

Enabling call metrics logging with .NET SDK version 485

Enabling call metrics logging with .NET SDK version 485

Summary

.NET SDK version 485 has a new 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.ApiAccount.Developer = 'devID';
  context.ApiCredential.ApiAccount.Application = 'appID';
  context.ApiCredential.ApiAccount.Certificate = 'certID';
  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/2007 1:23:16 PM, Informational]
Number of calls recorded: 1

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

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

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

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

 


Version Info

The code example above was based on the versions specified below:

API Schema Version 485
.NET SDK Version .NET SDK v485.0 full release



Additional Resources

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