Home > OS >  aws_embedded_metrics package not working in Python
aws_embedded_metrics package not working in Python

Time:10-25

I have installed the aws_embedded package and I am trying to import the module in Pycharm. Unfortunately, it is not working.

Code

import json
from aws_embedded_metrics import metric_scope

@metric_scope
def my_handler(metrics):
    metrics.put_dimensions({"Foo": "Bar"})
    metrics.put_metric("ProcessingLatency", 100, "Milliseconds")
    metrics.set_property("AccountId", "123456789012")
    metrics.set_property("RequestId", "422b1569-16f6-4a03")
    metrics.set_property("DeviceId", "61270781-c6ac-46f1")

    return {"message": "Hello!"}

Terminal with the Package Installed Python Console Output

CodePudding user response:

Installation of aws-embedded-metrics using pip

You are making mistake in installation, this is the correct way to install.

pip3 install aws-embedded-metrics

Import of aws-embedded-metrics

import json
from aws_embedded_metrics import metric_scope


@metric_scope
def my_handler(metrics):
    metrics.put_dimensions({"Foo": "Bar"})
    metrics.put_metric("ProcessingLatency", 100, "Milliseconds")
    metrics.set_property("AccountId", "123456789012")
    metrics.set_property("RequestId", "422b1569-16f6-4a03")
    metrics.set_property("DeviceId", "61270781-c6ac-46f1")

    return {"message": "Hello!"}
  • Related