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

Improve the error messages of the metricdatatest package #3035

Open
MrAlias opened this issue Jul 21, 2022 · 2 comments
Open

Improve the error messages of the metricdatatest package #3035

MrAlias opened this issue Jul 21, 2022 · 2 comments
Labels
area:metrics Part of OpenTelemetry Metrics enhancement New feature or request pkg:SDK Related to an SDK package pkg:testing Related to testing or a testing package

Comments

@MrAlias
Copy link
Contributor

MrAlias commented Jul 21, 2022

After looking at the output, a few things stick out. Some of these are easy to tell what's wrong, but some less so: In the ResourceMetrics test: resources are easy to tell, but the scopemetrics less so:

For the ScopeMetrics, what would be a clearer way to you to see they are not the same for the ResourceMetric? I am trying to concisely state that the elements of the ScopeMetric slice differ, and showing what one contains but not the other, but I agree there is a lot of information there.

I think there are two solutions that would help:

  1. Add formatting to the objects, like either a String() string function or some other formating, so we have just a bit less extra information.
  2. Use a formatting function that is aware of the different types we have and can provide a more concise format.

My goal would be if presented with something like:

            ResourceMetrics ScopeMetrics not equal:
            missing expected values:
            metricdata.ScopeMetrics{Scope:instrumentation.Scope{Name:"A", Version:"", SchemaURL:""}, Metrics:[]metricdata.Metrics{metricdata.Metrics{Name:"A", Description:"A desc", Unit:"1", Data:metricdata.Sum{DataPoints:[]metricdata.DataPoint{metricdata.DataPoint{Attributes:attribute.Set{equivalent:attribute.Distinct{iface:[1]attribute.KeyValue{attribute.KeyValue{Key:"A", Value:attribute.Value{vtype:1, numeric:0x1, stringly:"", slice:interface {}(nil)}}}}}, StartTime:time.Date(2022, time.July, 20, 13, 18, 7, 260802950, time.Local), Time:time.Date(2022, time.July, 20, 13, 18, 8, 260802950, time.Local), Value:-1}}, Temporality:0x1, IsMonotonic:true}}}}
            unexpected additional values:
            metricdata.ScopeMetrics{Scope:instrumentation.Scope{Name:"B", Version:"", SchemaURL:""}, Metrics:[]metricdata.Metrics{metricdata.Metrics{Name:"B", Description:"B desc", Unit:"By", Data:metricdata.Gauge{DataPoints:[]metricdata.DataPoint{metricdata.DataPoint{Attributes:attribute.Set{equivalent:attribute.Distinct{iface:[1]attribute.KeyValue{attribute.KeyValue{Key:"B", Value:attribute.Value{vtype:1, numeric:0x1, stringly:"", slice:interface {}(nil)}}}}}, StartTime:time.Date(2022, time.July, 20, 13, 18, 7, 261802950, time.Local), Time:time.Date(2022, time.July, 20, 13, 18, 8, 261802950, time.Local), Value:2}}}}}}

and it only differed by one character I would be easy to tell apart.

Originally posted by @MadVikingGod in #3025 (comment)

@MrAlias MrAlias added enhancement New feature or request pkg:testing Related to testing or a testing package pkg:SDK Related to an SDK package area:metrics Part of OpenTelemetry Metrics labels Jul 21, 2022
@MrAlias MrAlias added this to the Metric SDK: Beta milestone Jul 21, 2022
@checkaayush
Copy link

@MrAlias I'd like to give this a shot. Apart from proposed suggestions, could something like https://github.com/davecgh/go-spew be used?

@MrAlias
Copy link
Contributor Author

MrAlias commented Aug 29, 2022

could something like https://github.com/davecgh/go-spew be used?

I'd rather not add an unneeded dependency to the package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:metrics Part of OpenTelemetry Metrics enhancement New feature or request pkg:SDK Related to an SDK package pkg:testing Related to testing or a testing package
Projects
None yet
Development

No branches or pull requests

3 participants