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

bugfix: indent not used in MetricsData to_json #3197

Merged
merged 4 commits into from
Feb 24, 2023

Conversation

codeboten
Copy link
Contributor

@codeboten codeboten commented Feb 23, 2023

Description

The indent parameter was passed down to the resource metric's to_json method, but not used in MetricsData. This change fixes that.

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

Tested this by running the getting started example code. The output used to be:

{"resource_metrics": [{"resource": {"attributes": {"telemetry.sdk.language": "python", "telemetry.sdk.name": "opentelemetry", "telemetry.sdk.version": "1.17.0.dev0", "service.name": "unknown_service"}, "schema_url": ""}, "scope_metrics": [{"scope": {"name": "getting-started", "version": "0.1.2", "schema_url": ""}, "metrics": [{"name": "counter", "description": "", "unit": "", "data": {"data_points": [{"attributes": {}, "start_time_unix_nano": 1677187635593555000, "time_unix_nano": 1677187635593924000, "value": 1}], "aggregation_temporality": 2, "is_monotonic": true}}, {"name": "updown_counter", "description": "", "unit": "", "data": {"data_points": [{"attributes": {}, "start_time_unix_nano": 1677187635593610000, "time_unix_nano": 1677187635593924000, "value": -4}], "aggregation_temporality": 2, "is_monotonic": false}}, {"name": "histogram", "description": "", "unit": "", "data": {"data_points": [{"attributes": {}, "start_time_unix_nano": 1677187635593649000, "time_unix_nano": 1677187635593924000, "count": 1, "sum": 99.9, "bucket_counts": [0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0], "explicit_bounds": [0.0, 5.0, 10.0, 25.0, 50.0, 75.0, 100.0, 250.0, 500.0, 750.0, 1000.0, 2500.0, 5000.0, 7500.0, 10000.0], "min": 99.9, "max": 99.9}], "aggregation_temporality": 2}}, {"name": "observable_counter", "description": "", "unit": "", "data": {"data_points": [{"attributes": {}, "start_time_unix_nano": 1677187635593837000, "time_unix_nano": 1677187635593924000, "value": 1}], "aggregation_temporality": 2, "is_monotonic": true}}, {"name": "observable_updown_counter", "description": "", "unit": "", "data": {"data_points": [{"attributes": {}, "start_time_unix_nano": 1677187635593869000, "time_unix_nano": 1677187635593924000, "value": -10}], "aggregation_temporality": 2, "is_monotonic": false}}, {"name": "gauge", "description": "", "unit": "", "data": {"data_points": [{"attributes": {}, "start_time_unix_nano": 0, "time_unix_nano": 1677187635593924000, "value": 9}]}}], "schema_url": ""}], "schema_url": ""}]}

It's now:

{
    "resource_metrics": [
        {
            "resource": {
                "attributes": {
                    "telemetry.sdk.language": "python",
                    "telemetry.sdk.name": "opentelemetry",
                    "telemetry.sdk.version": "1.17.0.dev0",
                    "service.name": "unknown_service"
                },
                "schema_url": ""
            },
            "scope_metrics": [
                {
                    "scope": {
                        "name": "getting-started",
                        "version": "0.1.2",
                        "schema_url": ""
                    },
                    "metrics": [
                        {
                            "name": "counter",
                            "description": "",
                            "unit": "",
                            "data": {
                                "data_points": [
                                    {
                                        "attributes": {},
                                        "start_time_unix_nano": 1677187655866373000,
                                        "time_unix_nano": 1677187655866615000,
                                        "value": 1
                                    }
                                ],
                                "aggregation_temporality": 2,
                                "is_monotonic": true
                            }
                        },
                        {
                            "name": "updown_counter",
                            "description": "",
                            "unit": "",
                            "data": {
                                "data_points": [
                                    {
                                        "attributes": {},
                                        "start_time_unix_nano": 1677187655866404000,
                                        "time_unix_nano": 1677187655866615000,
                                        "value": -4
                                    }
                                ],
                                "aggregation_temporality": 2,
                                "is_monotonic": false
                            }
                        },
                        {
                            "name": "histogram",
                            "description": "",
                            "unit": "",
                            "data": {
                                "data_points": [
                                    {
                                        "attributes": {},
                                        "start_time_unix_nano": 1677187655866431000,
                                        "time_unix_nano": 1677187655866615000,
                                        "count": 1,
                                        "sum": 99.9,
                                        "bucket_counts": [
                                            0,
                                            0,
                                            0,
                                            0,
                                            0,
                                            0,
                                            1,
                                            0,
                                            0,
                                            0,
                                            0,
                                            0,
                                            0,
                                            0,
                                            0,
                                            0
                                        ],
                                        "explicit_bounds": [
                                            0.0,
                                            5.0,
                                            10.0,
                                            25.0,
                                            50.0,
                                            75.0,
                                            100.0,
                                            250.0,
                                            500.0,
                                            750.0,
                                            1000.0,
                                            2500.0,
                                            5000.0,
                                            7500.0,
                                            10000.0
                                        ],
                                        "min": 99.9,
                                        "max": 99.9
                                    }
                                ],
                                "aggregation_temporality": 2
                            }
                        },
                        {
                            "name": "observable_counter",
                            "description": "",
                            "unit": "",
                            "data": {
                                "data_points": [
                                    {
                                        "attributes": {},
                                        "start_time_unix_nano": 1677187655866561000,
                                        "time_unix_nano": 1677187655866615000,
                                        "value": 1
                                    }
                                ],
                                "aggregation_temporality": 2,
                                "is_monotonic": true
                            }
                        },
                        {
                            "name": "observable_updown_counter",
                            "description": "",
                            "unit": "",
                            "data": {
                                "data_points": [
                                    {
                                        "attributes": {},
                                        "start_time_unix_nano": 1677187655866578000,
                                        "time_unix_nano": 1677187655866615000,
                                        "value": -10
                                    }
                                ],
                                "aggregation_temporality": 2,
                                "is_monotonic": false
                            }
                        },
                        {
                            "name": "gauge",
                            "description": "",
                            "unit": "",
                            "data": {
                                "data_points": [
                                    {
                                        "attributes": {},
                                        "start_time_unix_nano": 0,
                                        "time_unix_nano": 1677187655866615000,
                                        "value": 9
                                    }
                                ]
                            }
                        }
                    ],
                    "schema_url": ""
                }
            ],
            "schema_url": ""
        }
    ]
}

Does This PR Require a Contrib Repo Change?

  • No.

Checklist:

  • Followed the style guidelines of this project
  • Changelogs have been updated
  • Unit tests have been update
  • Documentation has been updated

The indent parameter was passed down to the resource metric's to_json method, but not used in MetricsData. This change fixes that.

Signed-off-by: Alex Boten <aboten@lightstep.com>
@codeboten codeboten requested a review from a team as a code owner February 23, 2023 21:33
Alex Boten added 3 commits February 24, 2023 09:03
Signed-off-by: Alex Boten <aboten@lightstep.com>
@lzchen lzchen merged commit a9a96aa into open-telemetry:main Feb 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants