signalfx / signalfx-go

Go client library and instrumentation bindings for SignalFx
https://www.signalfx.com
Apache License 2.0
14 stars 48 forks source link

Problem with unmarshalling ChartsFiltersTime.end #36

Closed doctornkz closed 5 years ago

doctornkz commented 5 years ago

I faced with conflict of types. It's not easy to explain, but now it's about Time Sometimes we receive int64 from JSON API, but golang library waits string:

type ChartsFiltersTime struct {
    // The end of the time range to show for all charts in the dashboard. 
    //If you don't specify a value for this property, the system defaults to the value for each chart's `end` property.<br> 
    //**Note:** The specified type for `end` is `string`, 
    //but the system also accepts a 64-bit signed integer that represents a time in Unix time format 
    //(milliseconds since the Unix epoch UTC+0)

    End string `json:"end,omitempty"`
    // The start of the time range to show for all charts in the dashboard. 
    //If you don't specify a value for this property, the system defaults to the value for each chart's `start` property.<br> 
    //**Note:** The specified type for `start` is `string`, but the system also accepts a 64-bit signed integer 
    //that represents a time in Unix time format (milliseconds since the Unix epoch UTC+0)
    Start string `json:"start,omitempty"`
}

I catch exception

2019/07/12 15:33:40 Dashboard error: json: cannot unmarshal number into Go struct field ChartsFiltersTime.end of type string
2019/07/12 15:33:40 Can't fetch dashboard
exit status 1
cory-signalfx commented 5 years ago

Annoying! Gotya, sounds like we're gonna need a number of string here. I'll get this done today, @doctornkz!

cory-signalfx commented 5 years ago

Confirmed, this is a StringOrLong in the API code. 😠