How to create many instances of the TracerProvider class within a python application instrumented with open-telementry? - instrumentation

Currently, I'm instrumenting a python application using open-telemetry and jaeger. I was wondering if there is a way or a workaround to instantiate many instances of the the TraceProvider class, within the same multi-threaded application. I know I shouldn't do this, but I have my own reason :) The problem I'm facing is that the function set_tracer_provider() is implemented to be called only once. Is there any opentelemetry expert who can advise me on how to achieve this?
Many thanks.

Related

What is the equivalent of karate.get() in Java?

I have created a Java object in karate scripts using Java interop and have used it as required.
Now, I want to retrieve that same instance in another Java class. Is there a way to do that?
In karate, we have an equivalent method like karate.get('objectName'). Is there any equivalent API available in Karate lib?
Please assume that the answer is no. I'd like to mention that the whole point of creating Karate was to avoid using Java for API test automation. I say this because I suspect based on your questions that you have made the same mistake I've seen a few other teams make - which is attempting to make Karate work like the Seleniums and Rest Assureds of the world. That always ends badly. And what's worse is that these teams blame Karate for that and go around telling everyone. I'd rather have that not happen - so if this is a "blocker" please consider using some other tool.
If you are already calling Java, you have plenty of ways to pass objects around right? Just use that and don't over-complicate your tests. Or you can use the "singleton" pattern, nothing to do with Karate, you can look it up.

How to find production methods only used by tests in Intellij

Does anyone know if it's possible to identify production methods that are only referenced by unit test class methods?
I can see if a method has production or test uses by using the Find Usages option but I want to scan my whole codebase.
Thanks.
Unfortunately this feature is not yet implemented, but there is an issue for it, please follow:
https://youtrack.jetbrains.com/issue/IDEA-212420

Call .net methods into java without using C/C

Can anybody explain how can i call .net methods(from .dll) in my java code but i dont want to write/use C/C++ Code please expalin it Step by Step
You haven't given us any information to work off (How large are the two projects? Are you forced to use a specific CLR/JRE? Can they be two separate processes or do you just need to access a bunch of methods? Stuff like that), but I can point you in a general direction...
IKVM.NET is an implementation of Java that runs on the CLR. If you run your Java program in there, you can interop with any other .NET language easily.
If you can't use this for some reason, then you're probably going to have to embed Mono in your application and write some JNI bindings to start an instance of the CLR, then load and invoke your code.
If you've got a small amount of methods, consider just porting the code to Java instead of creating this huge system in order to get a small amount of functionality.
I can't explain it step by step because you haven't provided very much information as to what restrictions you have or how it needs to be done. Also, this isn't something trivial. You're trying to get two language runtimes to interact with each other without using native code, when native code is the only thing either runtime can interoperate with.

How do I access/read the Phonegap API?

I know there is this: http://docs.phonegap.com/en/2.1.0/index.html but it doesn't really help.
I am trying to learn about the appView variable (I think it's a variable). I would've said it was a class but it starts with a lower case letter :/
The reason I am trying to learn that is because I am trying to understand the appView.addJavascriptInterface(Object, String) method.
My main goal is to send a variable from a java file to a javascript file. Tutorials online seem to be using the method stated above. Because the method takes in an object, the tutorials seem to be creating another class. I want to simplify my code as much as possible so I was seeing if there are any other options.
You will want to write a Plugin. We've already gone through the pain of the JS to Java and back to JS communication. If you purely use addJavaScriptInterface you will run into some edge cases where it doesn't work and we already guard against.
In appView.addJavascriptInterface(Object, String) method Object refers to Java object from which you want to transfer data from Java to java script.
You can't achieve functionality without creating new class.
Apart from Plugin usage above mentioned way only we can achieve communication between java and javascript in phonegap apps.

Multi-instancing a project with extensive use of globals

We have a fairly robust program developed in Visual Basic .NET, and we've created an API which essentially represents the entire program as a single object. This works quite well and we've been using it for years--but now a project's come up where we really could use multiple instances of this.
The problem is that the codebase has extensive references to a global variable (gSvcMgr) in a Startup module. How can I make multiple instances of this object reference a different variable? Can I use namespaces? Or the Shadows keyword?
I can describe the structure further if I've been unclear, or if the specifics might help.
While refactoring the globals isn't out of the question if it's the only option, we have a very large code base, and only a few developers.
Thank you!
You could create each instance of your application object in a separate Application Domain using AppDomain.CreateInstanceAndUnWrap. That will create each instance of the option it a different domain where which will have its own copy of the shared global data and will not touch each other.
Using app domains will however come with a performance cost - all method calls will be marshaled (read copied) between the app domains. You will also have to derive your application object from MashalByRefObject.
See this blog post for an example of using app domains to solve a similar issue to yours.