Skip to content

Commit

Permalink
fix: Conform metric field type to Singer spec
Browse files Browse the repository at this point in the history
According to the [Singer
Spec](https://github.com/singer-io/getting-started/blob/master/docs/SYNC_MODE.md#metric-messages),
the correct field name is `type` and not `metric_type`.
  • Loading branch information
edgarrmondragon committed Apr 2, 2023
1 parent 304d123 commit bd442b6
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions singer_sdk/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import logging
import logging.config
import os
from dataclasses import asdict, dataclass, field
from dataclasses import dataclass, field
from pathlib import Path
from time import time
from typing import TYPE_CHECKING, Any, Generic, Mapping, TypeVar
Expand Down Expand Up @@ -79,7 +79,15 @@ def to_json(self) -> str:
Returns:
A JSON object.
"""
return json.dumps(asdict(self), default=str)
return json.dumps(
{
"type": self.metric_type,
"metric": self.metric.value,
"value": self.value,
"tags": self.tags,
},
default=str,
)


def log(logger: logging.Logger, point: Point) -> None:
Expand Down

0 comments on commit bd442b6

Please sign in to comment.