Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid format using metrics #26

Closed
marcioemiranda opened this issue Apr 30, 2020 · 3 comments
Closed

Invalid format using metrics #26

marcioemiranda opened this issue Apr 30, 2020 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@marcioemiranda
Copy link

Hello Heitor,

I am switching all my EMF logs from ordinary prints to the metric module.

All went fine except for this one. Below is the snippet that threw the error, the error raised and the equivalent print:

Error
Invalid format. Error: data._aws.CloudWatchMetrics[0].Metrics[0].Unit must match pattern ^(Seconds|Microseconds|Milliseconds|Bytes|Kilobytes|Megabytes|Gigabytes|Terabytes|Bits|Kilobits|Megabits|Gigabits|Terabits|Percent|Count|Bytes\/Second|Kilobytes\/Second|Megabytes\/Second|Gigabytes\/Second|Terabytes\/Second|Bits\/Second|Kilobits\/Second|Megabits\/Second|Gigabits\/Second|Terabits\/Second|Count\/Second|None)$, Invalid item: data._aws.CloudWatchMetrics[0].Metrics[0].Unit"

using single_metric
with single_metric(name="invoke-rate", unit=MetricUnit.CountPerSecond, value=int(rate)) as metric:
metric.add_namespace(name='Campaign/Orchestrator/WorkerInvokeRate')
metric.add_dimension(name='media', value='SMS')

ordinary print
print(json_dumps({
"_aws": {
"CloudWatchMetrics": [
{
"Namespace": "Campaign/Orchestrator/WorkerInvokeRate",
"Dimensions": [["media"]],
"Metrics": [
{
"Name": "rate",
"Unit": "Count/Second"
}
],
}
],
"Timestamp": int(datetime.now().timestamp()*1000)
},
"media": "SMS",
"rate": int(rate)
}))

@heitorlessa
Copy link
Contributor

heitorlessa commented May 1, 2020 via email

@heitorlessa heitorlessa added the bug Something isn't working label May 1, 2020
@heitorlessa heitorlessa self-assigned this May 1, 2020
@heitorlessa
Copy link
Contributor

heitorlessa commented May 1, 2020

Fixing this now, found another edge case (plain string won't work due to a branch enum logic)

@heitorlessa
Copy link
Contributor

Just released 0.8.1 with the fix, including additional tests that were missing.

Thank you (again) for helping out @marcioemiranda

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants