open-telemetry / opentelemetry.io

The OpenTelemetry website and documentation
https://opentelemetry.io
Creative Commons Attribution 4.0 International
520 stars 1.11k forks source link

json output #1569

Closed iomari closed 2 years ago

iomari commented 2 years ago

Greetings, I'm running the following command:

opentelemetry-instrument --traces_exporter console,otlp_proto_http --metrics_exporter console flask run

How can I get my console metric output to like:

{
  "resource_metrics": [
    {
      "resource": {
        "attributes": {
          "telemetry.sdk.language": "python",
          "telemetry.sdk.name": "opentelemetry",
          "telemetry.sdk.version": "1.12.0rc1",
          "telemetry.auto.version": "0.31b0",
          "service.name": "unknown_service"
        },
        "schema_url": ""
      },
      "scope_metrics": [
        {
          "scope": {
            "name": "app",
            "version": "",
            "schema_url": null
          },
          "metrics": [
            {
              "name": "roll_counter",
              "description": "The number of rolls by roll value",
              "unit": "",
              "data": {
                "data_points": [
                  {
                    "attributes": {
                      "roll.value": 4
                    },
                    "start_time_unix_nano": 1654790325350232600,
                    "time_unix_nano": 1654790332211598800,
                    "value": 3
                  },
                  {
                    "attributes": {
                      "roll.value": 6
                    },
                    "start_time_unix_nano": 1654790325350232600,
                    "time_unix_nano": 1654790332211598800,
                    "value": 4
                  },
                  {
                    "attributes": {
                      "roll.value": 5
                    },
                    "start_time_unix_nano": 1654790325350232600,
                    "time_unix_nano": 1654790332211598800,
                    "value": 1
                  },
                  {
                    "attributes": {
                      "roll.value": 1
                    },
                    "start_time_unix_nano": 1654790325350232600,
                    "time_unix_nano": 1654790332211598800,
                    "value": 2
                  },
                  {
                    "attributes": {
                      "roll.value": 3
                    },
                    "start_time_unix_nano": 1654790325350232600,
                    "time_unix_nano": 1654790332211598800,
                    "value": 1
                  }
                ],
                "aggregation_temporality": 2,
                "is_monotonic": true
              }
            }
          ],
          "schema_url": null
        }
      ],
      "schema_url": ""
    }
  ]
}

instead of like this:

{"resource_metrics": [{"resource": {"attributes": {"telemetry.sdk.language": "python", "telemetry.sdk.name": "opentelemetry", "telemetry.sdk.version": "1.12.0rc2", "service.name": "inspired", "telemetry.auto.version": "0.32b0"}, "schema_url": ""}, "scope_metrics": [{"scope": {"name": "app", "version": "", "schema_url": ""}, "metrics": [{"name": "roll_counter", "description": "The number of rolls by roll value", "unit": "", "data": {"data_points": [{"attributes": {"roll.value": 93351}, "start_time_unix_nano": 1658947583189784828, "time_unix_nano": 1658947637183833820, "value": 1}, {"attributes": {"roll.value": 420808}, "start_time_unix_nano": 1658947583189784828, "time_unix_nano": 1658947637183833820, "value": 58}, {"attributes": {"roll.value": 205885}, "start_time_unix_nano": 1658947583189784828, "time_unix_nano": 1658947637183833820, "value": 85}, {"attributes": {"roll.value": 871679}, "start_time_unix_nano": 1658947583189784828, "time_unix_nano": 1658947637183833820, "value": 8}], "aggregation_temporality": 2, "is_monotonic": true}}], "schema_url": ""}], "schema_url": ""}]}

cartermp commented 2 years ago

@iomari could you specify your steps to reproduce this behavior? Specifically, steps run to create the app in the first place (packages installed, etc.) and sharable code if possible.

svrnm commented 2 years ago

@iomari any updates before we close this issue?

svrnm commented 2 years ago

@iomari, I am closing this issue now, please re-open it with the requested info. Thanks