# Extension 2.0 : report\_metric doesn't work.

**URL:** <https://community.dynatrace.com/t/extension-2-0-report-metric-doesnt-work/52746>\
**Category:** Extensions\
**Tags:** python, extensions\
**Created:** [July 31, 2025, 1:02pm UTC](https://community.dynatrace.com/t/extension-2-0-report-metric-doesnt-work/52746 "2025-07-31T13:02:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sullivan](https://avatars.discourse-cdn.com/v4/letter/s/9dc877/32.png) [@Sullivan](https://community.dynatrace.com/u/Sullivan)\
**Post date:** [July 31, 2025, 1:02pm UTC](https://community.dynatrace.com/t/extension-2-0-report-metric-doesnt-work/52746/1 "2025-07-31T13:02:25Z")

</div>

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 :&nbsp;

_for item in csv\_reader:_&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _affiliate = item.get(“context.organization.#Affiliate”, “empty”)_&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _employees\_with\_usage = item.get(“employees\_with\_usage”, 0)_&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _# Validate employees\_with\_usage is an integer_&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _try:_&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _employees\_with\_usage = int(employees\_with\_usage)_&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _except ValueError:_&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _self.logger.error(f"Invalid value for employees\_with\_usage: {employees\_with\_usage}")_&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _continue_&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _# Ensure metric key format_&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _metric\_key = ‘custom.metric.test’_  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _# Prepare dimensions with proper escaping_&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _dimensions = {‘affiliate’: affiliate}_&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _try:_&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _self.report\_metric(metric\_key, employees\_with\_usage, dimensions)_&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _except Exception as e:_&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _self.logger.error(f"Failed to send metric {metric\_key} for affiliate {dimensions[‘affiliate’]}: {str(e)}")_&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _except Exception as e:_&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _self.logger.error(f"An error occurred: {e}")_

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

---

<div class="post-metadata">

**Author:** ![AntonPineiro](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/antonpineiro/32/49_2.png) [@AntonPineiro](https://community.dynatrace.com/u/AntonPineiro)\
**Post date:** [August 1, 2025, 7:17am UTC](https://community.dynatrace.com/t/extension-2-0-report-metric-doesnt-work/52746/2 "2025-08-01T07:17:31Z")

</div>

Hi,

Have you check logs?

Best regards

---

<div class="post-metadata">

**Author:** ![Julius\_Loman](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/julius_loman/32/51_2.png) [@Julius\_Loman](https://community.dynatrace.com/u/Julius_Loman)\
**Post date:** [August 1, 2025, 9:56pm UTC](https://community.dynatrace.com/t/extension-2-0-report-metric-doesnt-work/52746/3 "2025-08-01T21:56:10Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Sullivan](https://avatars.discourse-cdn.com/v4/letter/s/9dc877/32.png) [@Sullivan](https://community.dynatrace.com/u/Sullivan)\
**Post date:** [August 4, 2025, 11:48am UTC](https://community.dynatrace.com/t/extension-2-0-report-metric-doesnt-work/52746/4 "2025-08-04T11:48:01Z")

</div>

Hello,

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