# \[Extension 2.0\] Python : Issue with text metrics

**URL:** <https://community.dynatrace.com/t/extension-2-0-python-issue-with-text-metrics/48501>\
**Category:** Extensions\
**Tags:** python, extensions\
**Created:** [October 23, 2024, 1:40pm UTC](https://community.dynatrace.com/t/extension-2-0-python-issue-with-text-metrics/48501 "2024-10-23T13:40:41Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![MathieuB](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/mathieub/32/16706_2.png) [@MathieuB](https://community.dynatrace.com/u/MathieuB)\
**Post date:** [October 23, 2024, 1:40pm UTC](https://community.dynatrace.com/t/extension-2-0-python-issue-with-text-metrics/48501/1 "2024-10-23T13:40:41Z")

</div>

Hello,

Text metrics seem not working.

Context: I develop python extensions on my machine, build and upload to Dynatrace. Then the extensions are running on a cloud cluster.

I send 2 metrics :

```python
# __main__.py file

self.report_metric("my_metric_text", "OK")
self.report_metric("my_metric_num", 1)

```

I run the simulation with the SDK, all is ok :

```javascript
$ dt-sdk run my_extension
...
send_metric: my_metric_text gauge,OK
send_metric: my_metric_num gauge,1
Sent 2 metric lines to EEC: [MintResponse(lines_ok=2, lines_invalid=0, error=None, warnings=None)]
...

```

I run the build and the upload, also no error.

Then, when the extension run on the target environnement, I get this error from the log :

```javascript
_send_metrics: 1 invalid metric lines found

```

When I check the metrics data, I only saw the numerical metric. So this is the text metric that is considered as ‘ **invalid** ’.

I checked the documentation, the ‘value’ parameter can be a text :  
_value:&nbsp;float&nbsp;|&nbsp;str&nbsp;|&nbsp;int&nbsp;|&nbsp;SummaryStat_

> **[— dt-sdk 1.0.0 documentation](https://dynatrace-extensions.github.io/dt-extensions-python-sdk/api/extension.html#dynatrace_extension.Extension.report_metric)**
>
> Report a metric.

**I am missing something ?**

I am very concerned about the difference between the local run (_with the dt-sdk run command_) and the ‘true’ run in production.

We are at the end of our migration from extension 1.0 to 2.0 and we run all the new extension on local, to not impact production metrics.

---

<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:** [October 23, 2024, 3:02pm UTC](https://community.dynatrace.com/t/extension-2-0-python-issue-with-text-metrics/48501/2 "2024-10-23T15:02:31Z")

</div>

[@MathieuB](https://community.dynatrace.com/user/57910)&nbsp;there is no such thing as string metrics in Dynatrace. It accepts the&nbsp;_SummaryStat_ which is a structure to allow sending min/max/sum/count in a single call. It’s not a string.

The _dt-sdk run_ does not include EEC which does the metric value validation, that’s why you see different outcomes between the simulator and real deployment.

---

<div class="post-metadata">

**Author:** ![MathieuB](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/mathieub/32/16706_2.png) [@MathieuB](https://community.dynatrace.com/u/MathieuB)\
**Post date:** [October 23, 2024, 3:27pm UTC](https://community.dynatrace.com/t/extension-2-0-python-issue-with-text-metrics/48501/3 "2024-10-23T15:27:45Z")

</div>

[@Julius\_Loman](https://community.dynatrace.com/user/3364)&nbsp;thanks for the explanation.

On Extension 1.0, we had “ **state metric** ”, which allow to have “OK/KO” metric (_with the state\_metric method_).  
So you are saying that with EF2 we lost the state metric ?

If so, I have a huge rework on all my extension…

It’s a shame that the simulator is useless regarding the metric.

---

<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:** [October 23, 2024, 3:36pm UTC](https://community.dynatrace.com/t/extension-2-0-python-issue-with-text-metrics/48501/4 "2024-10-23T15:36:44Z")

</div>

No… Actually the state metric was a little bit “fake”. It used a dimension for reporting the status and a constant value of 1.  
So the metric was reported with either status=OK or status=KO dimension in your example.&nbsp; So you just need to send a dummy metric with the value of 1 with the dimension value of your choice.

The simulator is not useless. Just this would require an EEC running along with the simulator.&nbsp;[@michal\_nalezin](https://community.dynatrace.com/user/26013)&nbsp; maybe a product idea for you? Simulator is mostly about being able to collect and process the data. It does not valide the results you are sending.

---

<div class="post-metadata">

**Author:** ![MostafaHussein](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/mostafahussein/32/2785_2.png) [@MostafaHussein](https://community.dynatrace.com/u/MostafaHussein)\
**Post date:** [October 23, 2024, 3:47pm UTC](https://community.dynatrace.com/t/extension-2-0-python-issue-with-text-metrics/48501/5 "2024-10-23T15:47:16Z")

</div>

in Extensions v2 as the following figure

1st argument for the metrics name  
2nd argument for the metric value it should be numeric and cannot be string  
3rd argument is array of dimensions for the current reported data point

 ![MostafaHussein_0-1729698220694.png](https://global.discourse-cdn.com/dynatrace/original/3X/6/f/6f520c43a08e76843c9348fc58f1c78ec180e604.png)

try to imagine that the data points for getting percentage of cpu usage is

7:45:00pm = 98  
7:46:00pm = 95  
7:47:00pm = ‘fully\_utilized’

how dynatrace going to give you average value over last 5 minutes ?!!

---

<div class="post-metadata">

**Author:** ![MathieuB](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/mathieub/32/16706_2.png) [@MathieuB](https://community.dynatrace.com/u/MathieuB)\
**Post date:** [October 23, 2024, 3:47pm UTC](https://community.dynatrace.com/t/extension-2-0-python-issue-with-text-metrics/48501/6 "2024-10-23T15:47:26Z")

</div>

So all my work was a fake with EF1&nbsp;😂 (_please don’t tell my compagny_)

Thanks a lot for your time, I will try to play with the dimensions to retrieve the behaviour I use with EF1.

Regards,

Mathieu

---

<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:** [October 23, 2024, 4:46pm UTC](https://community.dynatrace.com/t/extension-2-0-python-issue-with-text-metrics/48501/7 "2024-10-23T16:46:47Z")

</div>

Your work was not fake, the way how DT did that in extension V1 was sort of a hack 😜

You should be able to get the exactly same behaviour with Extension V2, just use the same dimensions and values.
