Ejemplo n.º 1
0
 // This method gets called once for each cmdlet in the pipeline when the pipeline starts executing
 protected override void BeginProcessing()
 {
     _telemetryClient = MyTelemetryClient.getInstance();
     _stringBuilder   = new StringBuilder();
     _properties      = new Dictionary <string, string>();
     _functionName    = FunctionName;
 }
Ejemplo n.º 2
0
        // This method gets called once for each cmdlet in the pipeline when the pipeline starts executing
        protected override void BeginProcessing()
        {
            _telemetryClient = MyTelemetryClient.getInstance();
            _stringBuilder   = new StringBuilder();
            _properties      = new Dictionary <string, string>();

            // if we have $MyInvocation we can get the function name - it is not in the ErrorRecord somewhere?
            // user can also provide a function name as input, which takes precedence
            _functionName = String.IsNullOrEmpty(FunctionName) ? (MyInvocation != null ? MyInvocation.MyCommand.ToString() : null) : FunctionName;

            // if function name is greater than 256 characters or contains a space then it may come from
            // a runspace (ex. Azure Function App)
            if (_functionName.Length > 256 || _functionName.Contains(" "))
            {
                WriteVerbose("_functionName invalid (too long or contains spaces), are you calling from a runspace?");
                _functionName = String.IsNullOrEmpty(FunctionName) ? null : FunctionName;
            }

            // we put these into the properties dictionary
            _scriptLineNumber = ErrorRecord.InvocationInfo.ScriptLineNumber;
            _scriptName       = ErrorRecord.InvocationInfo.ScriptName;
            _line             = ErrorRecord.InvocationInfo.Line;
            _stackTrace       = ErrorRecord.Exception.StackTrace;
            _exception        = ErrorRecord.Exception;

            _customMessage = String.IsNullOrEmpty(Message) ? ErrorRecord.Exception.Message : Message;
        } // end BeginProcessing
Ejemplo n.º 3
0
 // This method gets called once for each cmdlet in the pipeline when the pipeline starts executing
 protected override void BeginProcessing()
 {
     //WriteVerbose("Begin!");
     //StaticStuff.InstrumentationKey = InstrumentationKey;
     // create new telemetry client and add the instrumentation key
     _telemetryClient = MyTelemetryClient.getInstance();
     _telemetryClient.InstrumentationKey = InstrumentationKey;
 }