Before

…lines 1–230 unchanged (230 lines)
231 now = time.Now()
232 exs = make([]*dto.Exemplar, len(exemplars))
233 err error
234 )
235 for i, e := range exemplars {
236 ts := e.Timestamp
237 if ts == (time.Time{}) {
238 ts = now
239 }
240 exs[i], err = newExemplar(e.Value, ts, e.Labels)
241 if err != nil {
242 return nil, err
243 }
…lines 244–258 unchanged (15 lines)

After

…lines 1–230 unchanged (230 lines)
231 now = time.Now()
232 exs = make([]*dto.Exemplar, len(exemplars))
233 err error
234 )
235 for i, e := range exemplars {
236 ts := e.Timestamp
237 if ts.IsZero() {
238 ts = now
239 }
240 exs[i], err = newExemplar(e.Value, ts, e.Labels)
241 if err != nil {
242 return nil, err
243 }
…lines 244–258 unchanged (15 lines)

Before

source_file
comment "// Copyright 2014 The Prometheus Authors"
comment "// Licensed under the Apache License, Version 2.0 (the \"Lice"...
comment "// you may not use this file except in compliance with the L"...
comment "// You may obtain a copy of the License at"
comment "//"
comment "// http://www.apache.org/licenses/LICENSE-2.0"
comment "//"
comment "// Unless required by applicable law or agreed to in writing"...
comment "// distributed under the License is distributed on an \"AS IS"...
comment "// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either expr"...
comment "// See the License for the specific language governing permi"...
comment "// limitations under the License."
package_clause
package "package"
package_identifier "prometheus"
import_declaration (+46 nodes collapsed)
var_declaration
var "var"
var_spec
identifier "separatorByteSlice"
= "="
expression_list
composite_literal
slice_type
[ "["
] "]"
type_identifier "byte"
literal_value
{ "{"
literal_element
selector_expression
identifier "model"
. "."
field_identifier "SeparatorByte"
} "}"
comment "// For convenient use with xxhash."
comment "// A Metric models a single sample value with its meta data "...
comment "// Prometheus. Implementations of Metric in this package are"...
comment "// Histogram, Summary, and Untyped."
type_declaration (+52 nodes collapsed)
comment "// Opts bundles the options for creating most Metric types. "...
comment "// implementation XXX has its own XXXOpts type, but in most "...
comment "// an alias of this type (which might change when the requir"...
comment "//"
comment "// It is mandatory to set Name to a non-empty string. All ot"...
comment "// optional and can safely be left at their zero value, alth"...
comment "// encouraged to set a Help string."
type_declaration (+55 nodes collapsed)
comment "// BuildFQName joins the given three name components by \"_\"."...
comment "// components are ignored. If the name parameter itself is e"...
comment "// string is returned, no matter what. Metric implementation"...
comment "// library use this function internally to generate the full"...
comment "// name from the name component in their Opts. Users of the "...
comment "// need this function if they implement their own Metric or "...
comment "// (with NewDesc) directly."
function_declaration (+175 nodes collapsed)
type_declaration
type "type"
type_spec
type_identifier "invalidMetric"
struct_type
struct "struct"
field_declaration_list
{ "{"
field_declaration
field_identifier "desc"
pointer_type
* "*"
type_identifier "Desc"
field_declaration
field_identifier "err"
type_identifier "error"
} "}"
comment "// NewInvalidMetric returns a metric whose Write method alwa"...
comment "// provided error. It is useful if a Collector finds itself "...
comment "// a metric and wishes to report an error to the registry."
function_declaration (+35 nodes collapsed)
method_declaration (+28 nodes collapsed)
method_declaration (+33 nodes collapsed)
type_declaration
type "type"
type_spec
type_identifier "timestampedMetric"
struct_type
struct "struct"
field_declaration_list
{ "{"
field_declaration
type_identifier "Metric"
field_declaration
field_identifier "t"
qualified_type
package_identifier "time"
. "."
type_identifier "Time"
} "}"
method_declaration (+97 nodes collapsed)
comment "// NewMetricWithTimestamp returns a new Metric wrapping the "...
comment "// way that it has an explicit timestamp set to the provided"...
comment "// useful in rare cases as the timestamp of a Prometheus met"...
comment "// be set by the Prometheus server during scraping. Exceptio"...
comment "// metrics with given timestamps from other metric"
comment "// sources."
comment "//"
comment "// NewMetricWithTimestamp works best with MustNewConstMetric"...
comment "// MustNewConstHistogram, and MustNewConstSummary, see examp"...
comment "//"
comment "// Currently, the exposition formats used by Prometheus are "...
comment "// millisecond resolution. Thus, the provided time will be r"...
comment "// next full millisecond value."
function_declaration (+42 nodes collapsed)
type_declaration (+22 nodes collapsed)
method_declaration (+370 nodes collapsed)
comment "// Exemplar is easier to use, user-facing representation of "...
type_declaration (+24 nodes collapsed)
comment "// NewMetricWithExemplars returns a new Metric wrapping the "...
comment "// exemplars. Exemplars are validated."
comment "//"
comment "// Only last applicable exemplar is injected from the list."
comment "// For example for Counter it means last exemplar is injecte"...
comment "// For Histogram, it means last applicable exemplar for each"...
comment "//"
comment "// NewMetricWithExemplars works best with MustNewConstMetric"...
comment "// MustNewConstHistogram, see example."
function_declaration
func "func"
identifier "NewMetricWithExemplars"
parameter_list
( "("
parameter_declaration
identifier "m"
type_identifier "Metric"
, ","
variadic_parameter_declaration
identifier "exemplars"
... "..."
type_identifier "Exemplar"
) ")"
parameter_list
( "("
parameter_declaration
type_identifier "Metric"
, ","
parameter_declaration
type_identifier "error"
) ")"
block
{ "{"
statement_list
if_statement (+32 nodes collapsed)
var_declaration (+45 nodes collapsed)
for_statement
for "for"
range_clause
expression_list
identifier "i"
, ","
identifier "e"
:= ":="
range "range"
identifier "exemplars"
block
{ "{"
statement_list
short_var_declaration
expression_list
identifier "ts"
:= ":="
expression_list
selector_expression
identifier "e"
. "."
field_identifier "Timestamp"
if_statement
if "if"
binary_expression
identifier "ts"
== "=="
parenthesized_expression
( "("
composite_literal
qualified_type
package_identifier "time"
. "."
type_identifier "Time"
literal_value
{ "{"
} "}"
) ")"
block
{ "{"
statement_list
assignment_statement
expression_list
identifier "ts"
= "="
expression_list
identifier "now"
} "}"
assignment_statement (+27 nodes collapsed)
if_statement
if "if"
binary_expression
identifier "err"
!= "!="
nil "nil"
block
{ "{"
statement_list
return_statement
return "return"
expression_list
nil "nil"
, ","
identifier "err"
} "}"
} "}"
return_statement (+25 nodes collapsed)
} "}"
comment "// MustNewMetricWithExemplars is a version of NewMetricWithE"...
comment "// NewMetricWithExemplars would have returned an error."
function_declaration (+57 nodes collapsed)

After

source_file
comment "// Copyright 2014 The Prometheus Authors"
comment "// Licensed under the Apache License, Version 2.0 (the \"Lice"...
comment "// you may not use this file except in compliance with the L"...
comment "// You may obtain a copy of the License at"
comment "//"
comment "// http://www.apache.org/licenses/LICENSE-2.0"
comment "//"
comment "// Unless required by applicable law or agreed to in writing"...
comment "// distributed under the License is distributed on an \"AS IS"...
comment "// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either expr"...
comment "// See the License for the specific language governing permi"...
comment "// limitations under the License."
package_clause
package "package"
package_identifier "prometheus"
import_declaration (+46 nodes collapsed)
var_declaration
var "var"
var_spec
identifier "separatorByteSlice"
= "="
expression_list
composite_literal
slice_type
[ "["
] "]"
type_identifier "byte"
literal_value
{ "{"
literal_element
selector_expression
identifier "model"
. "."
field_identifier "SeparatorByte"
} "}"
comment "// For convenient use with xxhash."
comment "// A Metric models a single sample value with its meta data "...
comment "// Prometheus. Implementations of Metric in this package are"...
comment "// Histogram, Summary, and Untyped."
type_declaration (+52 nodes collapsed)
comment "// Opts bundles the options for creating most Metric types. "...
comment "// implementation XXX has its own XXXOpts type, but in most "...
comment "// an alias of this type (which might change when the requir"...
comment "//"
comment "// It is mandatory to set Name to a non-empty string. All ot"...
comment "// optional and can safely be left at their zero value, alth"...
comment "// encouraged to set a Help string."
type_declaration (+55 nodes collapsed)
comment "// BuildFQName joins the given three name components by \"_\"."...
comment "// components are ignored. If the name parameter itself is e"...
comment "// string is returned, no matter what. Metric implementation"...
comment "// library use this function internally to generate the full"...
comment "// name from the name component in their Opts. Users of the "...
comment "// need this function if they implement their own Metric or "...
comment "// (with NewDesc) directly."
function_declaration (+175 nodes collapsed)
type_declaration
type "type"
type_spec
type_identifier "invalidMetric"
struct_type
struct "struct"
field_declaration_list
{ "{"
field_declaration
field_identifier "desc"
pointer_type
* "*"
type_identifier "Desc"
field_declaration
field_identifier "err"
type_identifier "error"
} "}"
comment "// NewInvalidMetric returns a metric whose Write method alwa"...
comment "// provided error. It is useful if a Collector finds itself "...
comment "// a metric and wishes to report an error to the registry."
function_declaration (+35 nodes collapsed)
method_declaration (+28 nodes collapsed)
method_declaration (+33 nodes collapsed)
type_declaration
type "type"
type_spec
type_identifier "timestampedMetric"
struct_type
struct "struct"
field_declaration_list
{ "{"
field_declaration
type_identifier "Metric"
field_declaration
field_identifier "t"
qualified_type
package_identifier "time"
. "."
type_identifier "Time"
} "}"
method_declaration (+97 nodes collapsed)
comment "// NewMetricWithTimestamp returns a new Metric wrapping the "...
comment "// way that it has an explicit timestamp set to the provided"...
comment "// useful in rare cases as the timestamp of a Prometheus met"...
comment "// be set by the Prometheus server during scraping. Exceptio"...
comment "// metrics with given timestamps from other metric"
comment "// sources."
comment "//"
comment "// NewMetricWithTimestamp works best with MustNewConstMetric"...
comment "// MustNewConstHistogram, and MustNewConstSummary, see examp"...
comment "//"
comment "// Currently, the exposition formats used by Prometheus are "...
comment "// millisecond resolution. Thus, the provided time will be r"...
comment "// next full millisecond value."
function_declaration (+42 nodes collapsed)
type_declaration (+22 nodes collapsed)
method_declaration (+370 nodes collapsed)
comment "// Exemplar is easier to use, user-facing representation of "...
type_declaration (+24 nodes collapsed)
comment "// NewMetricWithExemplars returns a new Metric wrapping the "...
comment "// exemplars. Exemplars are validated."
comment "//"
comment "// Only last applicable exemplar is injected from the list."
comment "// For example for Counter it means last exemplar is injecte"...
comment "// For Histogram, it means last applicable exemplar for each"...
comment "//"
comment "// NewMetricWithExemplars works best with MustNewConstMetric"...
comment "// MustNewConstHistogram, see example."
function_declaration
func "func"
identifier "NewMetricWithExemplars"
parameter_list
( "("
parameter_declaration
identifier "m"
type_identifier "Metric"
, ","
variadic_parameter_declaration
identifier "exemplars"
... "..."
type_identifier "Exemplar"
) ")"
parameter_list
( "("
parameter_declaration
type_identifier "Metric"
, ","
parameter_declaration
type_identifier "error"
) ")"
block
{ "{"
statement_list
if_statement (+32 nodes collapsed)
var_declaration (+45 nodes collapsed)
for_statement
for "for"
range_clause
expression_list
identifier "i"
, ","
identifier "e"
:= ":="
range "range"
identifier "exemplars"
block
{ "{"
statement_list
short_var_declaration
expression_list
identifier "ts"
:= ":="
expression_list
selector_expression
identifier "e"
. "."
field_identifier "Timestamp"
if_statement
if "if"
call_expression
selector_expression
identifier "ts"
. "."
field_identifier "IsZero"
argument_list
( "("
) ")"
block
{ "{"
statement_list
assignment_statement
expression_list
identifier "ts"
= "="
expression_list
identifier "now"
} "}"
assignment_statement (+27 nodes collapsed)
if_statement
if "if"
binary_expression
identifier "err"
!= "!="
nil "nil"
block
{ "{"
statement_list
return_statement
return "return"
expression_list
nil "nil"
, ","
identifier "err"
} "}"
} "}"
return_statement (+25 nodes collapsed)
} "}"
comment "// MustNewMetricWithExemplars is a version of NewMetricWithE"...
comment "// NewMetricWithExemplars would have returned an error."
function_declaration (+57 nodes collapsed)