cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Custom python extension - migration from v1 to v2

jannick_deturck
Organizer

In my v1 python extension I have a definition "initialize" that only will be executed during a first run, also referencing to a HealthcheckHost.json file

def initialize(self, **kwargs):

        #will only be executed during the first run.
        #capture parameters and save them in memmory
        script_dir = os.path.dirname(__file__)
        file_path = os.path.join(script_dir, "HealthcheckHosts.json")

        #read in parameters
        self.url = self.config["url"]
        self.hostpattern = self.config["hosts"]
        self.disableAlertBool = self.config["disableAllerting"]
        self.httpmethod = self.config["httpmethod"]
        self.rqmethod = self.config["requestmethod"]
        self.port = 9000        
        self.applicationcheckname = self.config["app"]
        splits = self.url.split('/')
        self.appextentionname = splits[1]
        self.warningSend = False
.......
 
Can somebody explain me where I need to put this definition in the new extension v2 structure????

jannick_deturck_0-1726212028274.png

 


cfr: Extension Structure — dt-sdk 1.0.0 documentation (dynatrace-extensions.github.io)
1 REPLY 1

Mike_L
Dynatrace Guru
Dynatrace Guru

That goes into the def initialize(self) function. If you use our vscode addon or the sdk to generate your project, it should automatically have that function as part of the template. 

Mike

Featured Posts