# Migrate a custom 1.0 Python extension to the new 2.0 framework.

**URL:** <https://community.dynatrace.com/t/migrate-a-custom-1-0-python-extension-to-the-new-2-0-framework/48955>\
**Category:** Extensions\
**Tags:** python, extensions\
**Created:** [November 19, 2024, 3:22pm UTC](https://community.dynatrace.com/t/migrate-a-custom-1-0-python-extension-to-the-new-2-0-framework/48955 "2024-11-19T15:22:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jannickdeturck](https://avatars.discourse-cdn.com/v4/letter/j/3da27b/32.png) [@jannickdeturck](https://community.dynatrace.com/u/jannickdeturck)\
**Post date:** [November 19, 2024, 3:22pm UTC](https://community.dynatrace.com/t/migrate-a-custom-1-0-python-extension-to-the-new-2-0-framework/48955/1 "2024-11-19T15:22:51Z")

</div>

We have a custom extension V2 in python that performs some healthcheck. It should report back the metrics to Dynatrace with the status and the url used to perform the healthcheck. Our call looks this:

self.report\_metric(  
key=“healthcheck\_state”,  
value=“success”,  
dimensions={“url”: “google.be”}  
)

When checking the logs on the Active Gate we get the following error back:

Error HTTP 400 from [http://127.0.0.1:14599/mint/8460131254161511808:](http://127.0.0.1:14599/mint/8460131254161511808:) b’{\n “error”: {\n “invalidLines”: [\n {\n “line”: 1,\n “error”: “invalid metric field in message \‘healthcheck\_state,url=\\“[google.com](http://google.com)\\” gauge,success 1732025455011\’; error at \’ \’ (index 48)”\n },\n {\n “line”: 2,\n “error”: “invalid metric field in message \‘healthcheck\_state,url=\\“[google.com](http://google.com)\\” gauge,success 1732025455011\’; error at \’ \’ (index 48)”\n }\n ],\n “code”: 400,\n “message”: “2 invalid lines”\n },\n “linesOk”: 0,\n “linesInvalid”: 2\n}’

I guess this means that the validation of the metric fails. After reading about the MINT protocol I still wonder why it fails? I don’t see a&nbsp;\&nbsp;somewhere. Seems to me like the&nbsp;dict&nbsp;is not correctly serialized and the quotes are escaped? Can this be avoided?

Could it be related to this&nbsp;[line](https://github.com/dynatrace-extensions/dt-extensions-python-sdk/blob/88e01af748b7e8a0357b000fd2a6320e6040f105/dynatrace_extension/sdk/metric.py#L87)

def \_key\_and\_dimensions(self):  
if not self.dimensions:  
return f"{self.key}"

# Double quotes are added around {v} but later escaped.  
dimensions\_string = “,”.join([f’{k}=“{v}”’ for k, v in self.dimensions.items()])  
return f"{self.key},{dimensions\_string}"

---

<div class="post-metadata">

**Author:** ![jannickdeturck](https://avatars.discourse-cdn.com/v4/letter/j/3da27b/32.png) [@jannickdeturck](https://community.dynatrace.com/u/jannickdeturck)\
**Post date:** [November 19, 2024, 3:24pm UTC](https://community.dynatrace.com/t/migrate-a-custom-1-0-python-extension-to-the-new-2-0-framework/48955/2 "2024-11-19T15:24:22Z")

</div>

![jannickdeturck_0-1732029856138.png](https://global.discourse-cdn.com/dynatrace/original/3X/2/f/2f13bce8180da311b7fd0e6b8d3957a46104857e.png)

---

<div class="post-metadata">

**Author:** ![AntonioSousa](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/antoniosousa/32/50_2.png) [@AntonioSousa](https://community.dynatrace.com/u/AntonioSousa)\
**Post date:** [November 19, 2024, 3:28pm UTC](https://community.dynatrace.com/t/migrate-a-custom-1-0-python-extension-to-the-new-2-0-framework/48955/3 "2024-11-19T15:28:37Z")

</div>

You’re not doing the metric ingestion correctly. For correct gauge usage, please chek out the documentation and examples here:

> **[Metric ingestion protocol](https://docs.dynatrace.com/docs/ingest-from/extend-dynatrace/extend-metrics/reference/metric-ingestion-protocol)**
>
> Learn how the data ingestion protocol for Dynatrace Metrics API works.
