Table of Contents

Interface SzDiagnostic

Namespace
Senzing.Sdk
Assembly
Senzing.Sdk.dll

Defines the interface to the Senzing diagnostic functions.

public interface SzDiagnostic

Examples

An SzDiagnostic instance is typically obtained from an SzEnvironment instance via the GetDiagnostic() method as follows.

For example:

// How to obtain an SzDiagnostic instance
try
{
    // obtain the SzEnvironment (varies by application)
    SzEnvironment env = GetEnvironment();

    SzDiagnostic diagnostic = env.GetDiagnostic();

    . . .

}
catch (SzException e)
{
    // handle or rethrow the exception
    LogError("Failed to get SzDiagnostic.", e);
}

Remarks

The Senzing diagnostic functions provide diagnostics and statistics pertaining to the host system and the Senzing repository.

Methods

CheckDatastorePerformance(int)

Runs non-destruction DB performance tests and returns detail of the result as a JSON string.

string CheckDatastorePerformance(int secondsToRun)

Parameters

secondsToRun int

How long to run the database performance test.

Returns

string

The JSON string describing the results of the performance test.

Examples

Usage:

// How to get datastore info via SzDiagnostic
try
{
    // obtain the SzEnvironment (varies by application)
    SzEnvironment env = GetEnvironment();

    // get the diagnostic instance
    SzDiagnostic diagnostic = env.GetDiagnostic();

    // check the datastore performance
    string performanceJson = diagnostic.CheckDatastorePerformance(10);

    // do something with the returned JSON (varies by application)
    Log(performanceJson);

}
catch (SzException e)
{
    // handle or rethrow the exception
    LogError("Failed to check the datastore performance.", e);
}

Exceptions

SzException

Thrown if a failure occurs.

GetDatastoreInfo()

Gathers detailed information on the data store and returns it as a JSON string.

string GetDatastoreInfo()

Returns

string

A JSON string describing the datastore.

Examples

Usage:

// How to get datastore info via SzDiagnostic
try
{
    // obtain the SzEnvironment (varies by application)
    SzEnvironment env = GetEnvironment();

    // get the diagnostic instance
    SzDiagnostic diagnostic = env.GetDiagnostic();

    // get the datastore info
    string datastoreJson = diagnostic.GetDatastoreInfo();

    // do something with the returned JSON (varies by application)
    Log(datastoreJson);

}
catch (SzException e)
{
    // handle or rethrow the exception
    LogError("Failed to get the datastore info.", e);
}

Exceptions

SzException

Thrown if a failure occurs.

GetFeature(long)

Experimental/internal method for obtaining diagnostic feature definition for the specified feature identifier.

string GetFeature(long featureID)

Parameters

featureID long

The identifier for the feature.

Returns

string

The feature definition describing the feature for the specified feature ID.

Examples

Usage:

// How to get a feature by its feature ID
try
{
    // obtain the SzEnvironment (varies by application)
    SzEnvironment env = GetEnvironment();

    // get the diagnostic instance
    SzDiagnostic diagnostic = env.GetDiagnostic();

    // get a valid feature (varies by application)
    long featureID = GetFeatureID();

    // get the feature for the feature ID
    string featureJson = diagnostic.GetFeature(featureID);

    // do something with the returned JSON
    Log(featureJson);

}
catch (SzException e)
{
    // handle or rethrow the exception
    LogError("Failed to purge the repository.", e);
}

Exceptions

SzException

Thrown if a failure occurs.

PurgeRepository()

Purges all data in the configured repository.

void PurgeRepository()

Examples

Usage:

// How to purge the Senzing repository
try
{
    // obtain the SzEnvironment (varies by application)
    SzEnvironment env = GetEnvironment();

    // get the diagnostic instance
    SzDiagnostic diagnostic = env.GetDiagnostic();

    // purge the repository (MAKE SURE YOU WANT TO DO THIS)
    if (ConfirmPurge())
    {
        diagnostic.PurgeRepository();
    }

}
catch (SzException e)
{
    // handle or rethrow the exception
    LogError("Failed to purge the repository.", e);
}

Remarks

WARNING: There is no undoing from this. Make sure your repository is regularly backed up.

Exceptions

SzException

Thrown if a failure occurs.

See Also