How do I change the default cloud function open telemetry exporter? - google-cloud-functions

By default, cloud functions emit a span that's visible in Cloud Trace. If the function cis called with opentelemetry headers, that remote trace is propagated as expected.
If I add additional open telemetry instrumentation to my function and use the cloud trace exporter, everything works as expected. If I change the exporter, my manually instrumented spans are sent to the new exporter but the default spans still go to cloud trace leaving gaps in my traces.
It appears that cloud functions have their own exporter that isn't configurable using the open telemetry environment variables.
Has anyone had luck rerouting the default spans or bypassing them in some way?

Related

Invalid value at 'function' (oneof), oneof field 'source_code' is already set. Cannot set 'sourceUploadUrl'

Cloud Code v1.22.0-insiders.0
I installed the Cloud Code extension for VSCode to work with my cloud functions locally.
After authorizing, when I click cloud functions section on the cloud code nav tab, I see the cloud function I want to work one with a green 'Active' checkmark.
When I hover over the cloud function and click "Download to new workspace" I do so, which installs the folder to a local dir.
I then tried making a one line amendment and deploying this test change by clicking "Deploy Function" under workspace Local.
This results in 2 error messages:
Invalid value at 'function' (oneof), oneof field 'source_code' is already set. Cannot set 'sourceUploadUrl'
And
Error running command cloudcode.functions.deployFunction: Invalid value at 'function' (oneof), oneof field 'source_code' is already set. Cannot set 'sourceUploadUrl'. This is likely caused by the extension that contributes cloudcode.functions.deployFunction.
How can I upload/sync my changes using this extension?
It looks like this happens when a Gen 1 function is created via a Zip file in the Cloud Console. This is a bug in Cloud Code, we're working on a fix to push out in the next update. In the meantime, Gen 2 functions, or Gen 1 functions created using the inline editor should work, but Gen 1 functions created using a Zip will run into this issue with no workaround at this time; sorry for the inconvenience while this issue persists.

In SSIS how can I check if the package or task is being run within BIDS by using the play button or right-clicking and choosing Execute Task?

This is not the same as debug mode. I want to display a warning if the developer is actually in BIDS and not display the warning if the package is being run from a scheduled job.
You could use a script task that opens a MsgBox. The MsgBox would only open when the task is running in BIDS, if I am not mistaken.
I'm afraid what you are trying to achieve is not possible. BIDS uses the same runtime as your SSIS agent.
You could, however, set an environment variable in your package and remove it during deployment. All of this is hacky and defeats the purpose though.
There really should be no custom logic when running a package locally versus being deployed (other than configurations that might affect the execution graph).
If you are trying to prevent user-error it would be best to educate your peers and/or restrict access.
I have found but not checked that there is a system variable "System::InteractiveMode" that may be used for this. Something to check.
According to Microsoft's documentation on System Variables the InteractiveMode variable should be able to fulfil your need to determine if the package is running from BIDS or from a SQL Job.
InteractiveMode (Boolean)
Indicates whether the package is run in
interactive mode. If a package is running in SSIS Designer, this
property is set to True. If a package is running using the DTExec
command prompt utility, the property is set to False.
I created a Script task at the beginning of my Flow (in the control flow tab) with a precedence constraint on the following task. I defined System::InteractiveMode in the ReadOnlyVariables field and used the code below to display the question and process the answer.
public void Main()
{
if ((bool)Dts.Variables["InteractiveMode"].Value)
{
DialogResult button = MessageBox.Show("Are you sure you want to run the package?", "Validate", MessageBoxButtons.YesNo);
if (button == DialogResult.No)
{
Dts.TaskResult = (int)ScriptResults.Failure;
return;
}
}
Dts.TaskResult = (int)ScriptResults.Success;
}
It doesn't stop the execution like the stop button in BIDS but prevents the execution of the rest of the package. I tried to use the RunningPackage.Stop() method but in order to get the list of RunningPackages it requires to be running from SQL Server Integration Service.
I tested it from BIDS and from SQL Server integration service and it worked as expected.

Application_Launching timing

What exactly is the timing/thread of the Application_Launching method on WP8? Specifically, in relation to the UI loading/rendering sequence?
I have an app where some global init is being done within Application_Launching. I'm getting a crash report from a method that's called during data binding on the start page's XAML; the crash is consistent with said global init not taking place.
EDIT: I'm calling a native (C++) method which is reading a file into a mallocated memory block in a global variable that's initialized to null. Said variable is dumped as a part of crash reporting; I've got a report where it's null.
Pasting the code would be rather pointless IMHO.
When starting the app, the Launching event is raised. However, the app can later be put in a dormant state, in a process that is called "tombstoning". When a tombstoned app is resumed, it won't raise the Launching event but the Activated event instead. It's very likely that you forgot to handle that case.
To test it easily, go in the properties of your Windows Phone project, in the Debug tab, and check the "Tombstone upon deactivation while debugging" option. From there, every time the app is deactivated while the debugger is attached (typically, when pressing the home button on the emulator), the app will be tombstoned, and you can make sure that it resumes properly when switching back to it.
I've got another theory. It's not about the library being loaded at the wrong time, it's about the library being unloaded. Since almost all of my native functions are static and the state is global, there are no active native objects, and the COM subsystem has a zero ref count on the module. As per COM rules, modules like that are fair game for unloading anytime. On a subsequent native function call, the library is reloaded, but the global state is gone.
From the next version, I'll keep one live native object for the app's lifetime. We'll see if the crash comes back.

SSIS package script logging

I am new to SSIS packages and I am trying to get logging to work from within a custom script. We have it logging the native messages from the package already but I want to add my own custom log messages to it. I see on the Microsoft.SqlServer.Dts.Pipeline.ScriptComponent class there is a Log method but I am unsure what to use for the dataCode and dataBytes arguments so I used 0 and an empty array but this did not log anything.
So how do I get the logging to work from within my script?
Are there any configurations that I need to know about to enable it?
Thanks
Note: I am working with SqlServer 2008 SP2 (not R2)
You need to make sure that the task is enabled for logging. Select SSIS > Logging... from the BIDS menu. Select your data flow task. On the Providers and Logs tab, ensure that a log provider is selected. Select the Details tab and Check the ScriptComponentLogEntry event. Note that this event is not inherited from the Package settings; so you have to select the data flow task. Now your logging should be captured.
You may also be interested in the ComponentMetaData.FireInformation method to log an information event. Here's more information on FireInformation and related methods. You may find these easier to configure, since the associated events (OnInformation for FireInformation) are inherited from the package settings. In other words, if you set logging for the OnInformation event at the package level, all tasks will log the OnInformation event.

What can cause Outlook to change a COM-addin's LoadBehavior to 2 - other than unhandled exceptions?

For some weeks now we have been fighting with an issue where at a small number of customers our Outlook addin gets unloaded and disabled for yet undetermined reasons. By "disabled" I mean that Outlook changes the following registry value from 3 to 2 which in effect means that the addin will not be loaded on next startup:
HKEY_LOCAL_MACHINE\Software\Microsoft\Office\Outlook\Addins\[OurAddin.sProgID]\LoadBehavior
There is no error message and neither do any exceptions show up in the log files that our addin produces itself.
I have already found the following page which specifically deals with the LoadBehavior change issue: http://blogs.msdn.com/vsod/archive/2008/04/22/Troubleshooting-com-add-in-load-failures.aspx
However, none of the possible reasons proposed there appear to be applicable:
The addin is not merely listed in the Disabled Items list.
There are no unhandled exceptions neither in the IDTExtensibility2 methods nor anywhere else in the code. All code is wrapped in try/catch equivalents and all exception output is emitted only via OutputDebugString or into a log file.
The error appears to be independent of anti-virus software, i.e. it also occurs with it disabled.
Disabling all other addins also has no effect on the error.
So, what else can cause Outlook to disable an addin?
Some more details / observations:
We haven't been able to reproduce the issue in our test environments so far so we haven't yet been able to attach a debugger while the issue occurs.
The issue never occurs while we try to watch what happens via remote support (TeamViewer). I suspect this is because TeamViewer uses a hook DLL that injects itself into all running processes (including Outlook) and thus affects the memory layout, timing, thread order, whatever.
Whenever we compile a new version of the addin to try out something new the addin will typically work fine for a couple of hours or even days only to eventually get disabled again. Once this has happened all subsequent attempts to get the addin to load on that machine (by manually changing back the LoadBehavior value) will fail (i.e. LoadBehaviour will simply change back to 2) until we compile and deploy another build (or try to watch using TeamViewer - see above).
Typically the addin will get unloaded right on Outlook startup though occasionally it also does happen after Outlook has already been running for some time. The log file in those cases looks completely inconspicious - the addin simply goes through the regular shutdown steps just as if Outlook had been closed normally.
As far as I can tell from our log files and by observing the issue via SysInternals ProcessMonitor, when the addin get disabled on Outlook startup (rather than during the session) the DLL gets unloaded even before the COM object (i.e. the addin) gets instantiated (log messages in the constructor never show up).
We have put OutputDebugString messages in initialization sections (this a Delphi DLL). None of them show up when the addin fails to load.
Only a very small fraction of our customers is affected by this issue. We have several tens of thousands of installations from whom we haven't received any reports about this.
UPDATE: It seems that often (but not always) one of the last things that gets logged before the addin gets unloaded is an exception with text "OLE error 800A01A8". That exception gets caught by a global exception handler built into the framework I'm using (Add-in-Express) and does not appear originate from anywhere it my own code every single method of which is by now entirely wrapped in try..catch. This typically occurs right after I set the visibility of my CommandBarButtons from an Inspector's Activate event handler.
Common properties of all affected machines:
Windows XP Professional, up-to-date patch level
Outlook 2003 Professional, up-to-date patch level
varying versions of McAfee Virus Scan (though disabling it has no effect - see above)
Users are members of the local Administrators group
One more thing to note which very probably is significant as well (though maybe not as much as I first thought):
We are using a licensing / copy protection module from a third-party vendor which wraps the compiled DLL in a "shell" and only unpacks it on-the-fly. Ever since I found out that the addin gets unloaded even before any of our own code gets executed this has been my prime suspect. However, while the vendor confirmed that there may be unhandled exceptions in their code a log file produced by a special debug version of the protection shell showed that the unpacking process completed successfully and control was already handed back to the protected DLL before Outlook unloaded the addin. So it appears that whatever causes Outlook to unload our addin happens between the completion of the protection shell's initialization and our own code.
Any more ideas?
My company has been putting up with what sounds like the same issue you are seeing for years. The plug-in we have is a VB6 COM add-in for Outlook 2003 and it’s deployed on several hundred machines that get cycled hundreds (if not thousands) of times a day. We go through the load and unload cycles a lot.
We get a fair bit of the general errors where the plug-in is loaded but not connected and we handle that in code. (Obviously not production quality)
Dim outlook As outlook.Application
Set outlook = CreateObject("Outlook.Application")
outlook.COMAddIns("MyFancyDancyPlugin").Connect = True
Rarely, but not so rare that it isn’t an annoyance, we see the plug-in reach a state where it is loaded and we can see it in “Tools>Options>Others>Advanced Options> Com Add-Ins”, but we just can’t connect to the thing. If you try to connect you don’t get an error it just switches back to disconnected. [The equivalent of switching back to a 2 in the registry key] The COM object as far as I can tell is never created. The item is not listed in the Disabled items.
We don’t actually have to redeploy to correct this error. Removing the object through the Com Add-Ins dialogue and then re-adding it there seems to correct the issue. This is still not an acceptable solution but it does get things back and running without a reinstall.
Windows XP Professional, up-to-date
patch level
Outlook 2003
Professional, up-to-date patch level
varying versions of McAfee Virus Scan
(though disabling it has no effect -
see above)
Users are members of the
local Administrators group
This seems to fit, we don't use McAfee but the virus scanner also doesn't interact with outlook or the com add-ins. We also don't use a copy protection app.
I'm sorry I can't be of more help, but I would love to root cause this.
I am also working on Outlook Add-In and I know one reason when the Add-In gets disabled. some time when Outlook shuts down abruptly or user forcefully shut down the Outlook, add-In gets disabled. I am not sure if this is the reason in your case but it could also give you some direction to think of.
I some time use this method (closing the outlook using task manager while it is still loading) to simulate this behavior and actually I have developed a tool which scans all the machines provided to it and checks if the add-In is disabled on a machine and if yes it changes the registry value to enable it.
maybe you are a lockback policy victim. add a bypass key to registry, then it works.
modern office versions or vsto creates the key while installation. the effect is: install
a modern office too and the adddin now are also loaded in older office. please take a look
code snippet taken from NetOffice http://netoffice.codeplex.com
public static void RegisterFunction(Type type)
{
try
{
// add codebase value
Assembly thisAssembly = Assembly.GetAssembly(typeof(ExampleClassicAddin));
RegistryKey key = Registry.ClassesRoot.CreateSubKey("CLSID\\{" + type.GUID.ToString().ToUpper() + "}\\InprocServer32\\1.0.0.0");
key.SetValue("CodeBase", thisAssembly.CodeBase);
key.Close();
key = Registry.ClassesRoot.CreateSubKey("CLSID\\{" + type.GUID.ToString().ToUpper() + "}\\InprocServer32");
key.SetValue("CodeBase", thisAssembly.CodeBase);
key.Close();
// add bypass key
// http://support.microsoft.com/kb/948461
key = Registry.ClassesRoot.CreateSubKey("Interface\\{000C0601-0000-0000-C000-000000000046}");
string defaultValue = key.GetValue("") as string;
if (null == defaultValue)
key.SetValue("", "Office .NET Framework Lockback Bypass Key");
key.Close();
// add addin key
Registry.ClassesRoot.CreateSubKey(#"CLSID\{" + type.GUID.ToString().ToUpper() + #"}\Programmable");
Registry.CurrentUser.CreateSubKey(_addinRegistryKey + _prodId);
RegistryKey rk = Registry.CurrentUser.OpenSubKey(_addinRegistryKey + _prodId, true);
rk.SetValue("LoadBehavior", Convert.ToInt32(3));
rk.SetValue("FriendlyName", _addinName);
rk.SetValue("Description", "NetOffice COMAddinExample with classic UI");
rk.Close();
}
catch (Exception ex)
{
string details = string.Format("{1}{1}Details:{1}{1}{0}", ex.Message, Environment.NewLine);
MessageBox.Show("An error occured." + details, "Register " + _addinName, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
If you have the ability for your users to run a debug program to get more information about the problem when it happens, try using Add-in Spy from Microsoft.
http://msdn.microsoft.com/en-us/library/cc984533(v=office.12).aspx
I was having an add-in fail to load and discovered that it was happening because a dependency wasn't getting preloaded. This tool should be able to tell you what specific error is happening when the Outlook add-in fails to load.
Just to close this up: The problem did eventually turn out to be caused by a bug in the third-party licensing wrapper we were using. It has been confirmed by the vendor and was fixed in more recent releases.