Aras Innovator Platform

Appendix C

“Convert” method of IConverter interface has parameter ConversionContext.

This context contains:

  • ConversionTask(IConversionTask) - Conversion Task object with contains all task data.
  • ConversionTempFolder(string) - Path to conversion temp folder.
  • Connection(IServerConnection) - Innovator Server connection to communicate with innovator server/
  • Logger(ILogger) - Can be used to writing logs into Conversion Server log file.

To give diagnostic information the next tools can be used:

Logger

Can be used with logger extension(Microsoft.Extensions.Logging): LogInformation, LogWarning, LogError, LogCritical and etc.

Examples:

- Log information:

context.Diagnostics.Logger.LogInformation(“<log_message>”);

-Log exception

context.Diagnostics.Logger.LogError(“<log_message>”, exception);

///or

context.Diagnostics.Logger.LogWarning(“<log_message>”, exception);

ActivitySource

If telemetry is turned on for the Conversion Service a converter can create a new span and link it to the Conversion Service context or create its own ActivitySource.

Examples:

- Create a new span for a converter:

using Activity activity = Activity.Current?.Source.StartActivity(<converter_span_name>, <activity_kind>, string.Empty, <converter_span_tags>);

- Link a converter activity span to ConversionService context:

var activityLink = new ActivityLink(Activity.Current!.Context);

using Activity activity = Activity.Current?.Source.StartActivity(<conversion_span_name>, <activity_kind>, string.Empty, <converter_span_tags>, [activityLink]);

- Create a new nested span for a conversion stage:

using Activity activity = Activity.Current?.Source.StartActivity(<converter_nested_span_name>, <activity_kind>, string.Empty, <converter_nested_span_tags>);

- To point an additional conversion stage event:

activity?.AddEvent(new ActivityEvent(eventName, tags: new ActivityTagsCollection(<tags_collection>)));

- If conversion process failed:

activity?.SetStatus(ActivityStatusCode.Error, <ErrorMessage>);

- If conversion process succeeded:

activity?.SetStatus(ActivityStatusCode.Ok);