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

Extension 2.0 : report_metric doesn't work.

Sullivan
Participant

Hello,

I am having an issue with my 2.0 extension, and I am uncertain as to why.

 

This is part of my python script : 

                    for item in csv_reader:
                        affiliate = item.get("context.organization.#Affiliate", "empty")
                        employees_with_usage = item.get("employees_with_usage", 0)
                       
                        # Validate employees_with_usage is an integer
                        try:
                            employees_with_usage = int(employees_with_usage)
                        except ValueError:
                            self.logger.error(f"Invalid value for employees_with_usage: {employees_with_usage}")
                            continue
                       
                        # Ensure metric key format
                        metric_key = 'custom.metric.test'

                        # Prepare dimensions with proper escaping
                        dimensions = {'affiliate': affiliate}
                        try:
                            self.report_metric(metric_key, employees_with_usage, dimensions)
                        except Exception as e:
                            self.logger.error(f"Failed to send metric {metric_key} for affiliate {dimensions['affiliate']}: {str(e)}")
            except Exception as e:
                self.logger.error(f"An error occurred: {e}")

I don't have errors, can you explain me please ?

 

3 REPLIES 3

AntonPineiro
DynaMight Guru
DynaMight Guru

Hi,

Have you check logs?

Best regards

❤️ Emacs ❤️ Vim ❤️ Bash ❤️ Perl

Julius_Loman
DynaMight Legend
DynaMight Legend

Do you see values when you run the extension in the simulator?
Are you 100% sure the the self.report_metric is called? 

Certified Dynatrace Master | Alanata a.s., Slovakia, Dynatrace Master Partner

Sullivan
Participant

 

Hello,

I deleted my extension, rebuiled it, and it worked. Thank you for your help.

Featured Posts