-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Add supports for printing pretty histogram to stdout #1028
Add supports for printing pretty histogram to stdout #1028
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please revert the unrelated go.mod
and go.sum
changes.
47bbbbb
to
18e3f14
Compare
This is happening |
The build is failing on Are you sure you ran Regardless of the validity of the module hashes, what @jmacd is pointing out is a lot of the changes to the Please revert the changes to all |
Took a deeper look into the That said, I'm still at a loss why your local system is making the changes it is. These are no automatically made by the local build system for me when I do not prune anything manually. It seems like my advice above about reverting changes to all |
I fell that I've seen this sort of problem arise as follows:
I would basically revert the change and ignore it, since it seemed accidental. |
18e3f14
to
5091a30
Compare
exporters/stdout/metric.go
Outdated
@@ -44,10 +45,22 @@ type line struct { | |||
|
|||
Quantiles []quantile `json:"Quantiles,omitempty"` | |||
|
|||
Histogram []bucket `json:"histogram,omitempty"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see below a switch on e.config.PrettyPrint
which directly calls Fprintf, and I wonder if the structure would be more readable if the pretty-form of histogram printed in-line with the JSON, formatted within quotes, like:
...
Histogram: "
_pretty representation_
...
"
This could be implemented using a new type with a MarshalJSON()
method that switched on e.config.PrettyPrint
itself. How does this sound?
@@ -44,13 +45,37 @@ type line struct { | |||
|
|||
Quantiles []quantile `json:"Quantiles,omitempty"` | |||
|
|||
Histogram histogram `json:"histogram,omitempty"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we follow the other naming structure here and make this capital.
Histogram histogram `json:"histogram,omitempty"` | |
Histogram histogram `json:"Histogram,omitempty"` |
boundary struct { | ||
Min float64 `json:"min"` | ||
Max float64 `json:"max"` | ||
} | ||
|
||
bucket struct { | ||
boundary `json:"bounds"` | ||
Count float64 `json:"count"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar here:
boundary struct { | |
Min float64 `json:"min"` | |
Max float64 `json:"max"` | |
} | |
bucket struct { | |
boundary `json:"bounds"` | |
Count float64 `json:"count"` | |
boundary struct { | |
Min float64 `json:"Min"` | |
Max float64 `json:"Max"` | |
} | |
bucket struct { | |
boundary `json:"Bounds"` | |
Count float64 `json:"Count"` |
bytes, err := json.Marshal(hist) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return append(bytes, []byte("\n"+printHistogram(hist))...), nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not following why we are Marshaling with json and printing the histogram. This is redundantly showing the same information.
return err | ||
} | ||
buckets := make([]bucket, 0, len(val.Boundaries)) | ||
lowerBound := float64(-math.MaxFloat64) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be negative infinity? Or is there a limitation here?
lowerBound := float64(-math.MaxFloat64) | |
lowerBound := math.Inf(-1) |
}) | ||
lowerBound = val.Boundaries[i] | ||
if i == len(val.Boundaries)-1 { | ||
upperBound = float64(math.MaxFloat64) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
upperBound = float64(math.MaxFloat64) | |
upperBound = math.Inf(1) |
) | ||
|
||
func (hist histogram) MarshalJSON() ([]byte, error) { | ||
bytes, err := json.Marshal(hist) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we have the pretty print just return the similarly formatted JSON structure like the other formats and have the default return the tabular form? That would provide the expected consistency.
@evantorrie is going to take this over. |
Closing due to staleness. |
No description provided.