Request

Response

    Troubleshooting

    If you encounter issues while using the SDK, it is important to troubleshoot with the goal of identifying, analyzing, and resolving any unexpected issues or behaviors. You may encounter problems within the code, and the following two approaches can assist in debugging the problem:

    1. Debugging using the Logger
    2. Debugging using metrics

    Debugging using the Logger

    The SDK supports a file-based logging system, which can be further divided into multiple log levels, such as Informative, Error, and Debug.

    • Informative: This is the default log level, which provides limited logs related to execution. Logging at this level records exception logs, but may not provide a complete stack trace.
    • Error: The Error logs are more concise and are only created when there is an error.
    • Debug: The Debug logs are currently the most verbose and provide enhanced diagnostic information to assist in troubleshooting when errors occur.

    You can create an instance of logger by using “Autodesk.DataExchange.Extensions.Logging.File” and the steps for the same are as follows:

    • Download and install the package Autodesk.DataExchange.Extensions.Logging.File.
    • Create an instance of a Ilogger by providing the log directory path as a constructor parameter of string type, this will create the instance of the Ilogger.
          ILogger Logger = new Log(LogDirectoryPath);
    
    • Set the Debug log level by calling the SetDebugLogLevel() method of the Autodesk.DataExchange.Extensions.Logging.File.
          Logger.SetDebugLogLevel();
    
          (SDK as Autodesk.DataExchange.Client).EnableHttpDebugLogging();
    

    The default logger of the SDK provides inbuilt Informative and Error logs, therefore there is no need to set informative or error log levels explicitly.

    Debugging using metrics

    The SDK provides access to the Insights.Metrics class, which enables you to measure various performance metrics of the code.

    • You can enable the metrics by using the following method:
          Insights.Metrics.EnableMetrics(true);
    
    • To track the time taken for a particular activity you can make use of StartTracking and StopTracking methods.

      • In the following methods, the input parameter is the name of the activity against which the performance metrics can be calculated.
          Insights.Metrics.StartTracking("CreateExchangeAsync").  
          Insights.Metrics.StopTracking("CreateExchangeAsync").  
    
    * Both methods also have one optional parameter `string uniqueid` which can be used to distinguish between two activities with the same name.   
    
          Insights.Metrics.StartTracking("CreateExchangeAsync", "q125g49t").   
          Insights.Metrics.StopTracking("CreateExchangeAsync", "q125g49t"). 
    
    • To keep the numeric count of an activity, use the following method.
          Insights.Metrics.CreateCounter(Id)
    
    • To increment the numeric count of an activity, use the following method.
          Insights.Metrics.IncrementCounter(Id) 
    
    • To get the data that has been tracked for different operations, use the following method.
          Insights.Metrics.GetString();
    
    • To clear all the data inside the metrics class, use the following method.
          Insights.Metrics.ClearMetrics()
    

    Resolving thread pool starvation

    When you sync large models, the CPU-intensive geometry conversions that the SDK performs can starve the .NET thread pool of the threads it needs for I/O completion callbacks. This can surface as an error such as There were not enough free threads in the ThreadPool to complete the operation.

    By default, the SDK guards against this. The GeometryConfiguration.TuneThreadPool property is true by default, which raises the process-wide thread pool minimums during client initialization so the pool creates threads eagerly rather than ramping up slowly. If you see this error, confirm that you have not set TuneThreadPool to false. Disabling it removes this safeguard. For details on the setting and when to opt out, see Tuning the thread pool.