Skip to content
This repository has been archived by the owner on Jul 31, 2023. It is now read-only.

Commit

Permalink
Simplify use of time package (#1167)
Browse files Browse the repository at this point in the history
  • Loading branch information
bvwells authored and rghetia committed Sep 10, 2019
1 parent ce85b6d commit 3da91ae
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion examples/derived_gauges/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ func doWork() {
func main() {
// Using logexporter but you can choose any supported exporter.
exporter, err := exporter.NewLogExporter(exporter.Options{
ReportingInterval: time.Duration(10 * time.Second),
ReportingInterval: 10 * time.Second,
MetricsLogFile: metricsLogFile,
})
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion examples/derived_gauges/derived_gauge.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ func doWork() {
func main() {
// Using logexporter but you can choose any supported exporter.
exporter, err := exporter.NewLogExporter(exporter.Options{
ReportingInterval: time.Duration(10 * time.Second),
ReportingInterval: 10 * time.Second,
MetricsLogFile: metricsLogFile,
})
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion examples/gauges/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ func work() {
func main() {
// Using log exporter to export metrics but you can choose any supported exporter.
exporter, err := exporter.NewLogExporter(exporter.Options{
ReportingInterval: time.Duration(10 * time.Second),
ReportingInterval: 10 * time.Second,
MetricsLogFile: metricsLogFile,
})
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion examples/gauges/gauge.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ func work() {
func main() {
// Using log exporter to export metrics but you can choose any supported exporter.
exporter, err := exporter.NewLogExporter(exporter.Options{
ReportingInterval: time.Duration(10 * time.Second),
ReportingInterval: 10 * time.Second,
MetricsLogFile: metricsLogFile,
})
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion examples/helloworld/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func main() {

// Register an exporter to be able to retrieve
// the data from the subscribed views.
e, err := exporter.NewLogExporter(exporter.Options{ReportingInterval: time.Duration(time.Second)})
e, err := exporter.NewLogExporter(exporter.Options{ReportingInterval: time.Second})
if err != nil {
log.Fatal(err)
}
Expand Down
2 changes: 1 addition & 1 deletion examples/http/helloworld_server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func main() {

// Using log exporter to export metrics but you can choose any supported exporter.
exporter, err := exporter.NewLogExporter(exporter.Options{
ReportingInterval: time.Duration(10 * time.Second),
ReportingInterval: 10 * time.Second,
MetricsLogFile: metricsLogFile,
TracesLogFile: tracesLogFile,
})
Expand Down
2 changes: 1 addition & 1 deletion examples/quickstart/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func main() {

// Using log exporter here to export metrics but you can choose any supported exporter.
exporter, err := exporter.NewLogExporter(exporter.Options{
ReportingInterval: time.Duration(10 * time.Second),
ReportingInterval: 10 * time.Second,
MetricsLogFile: metricsLogFile,
})
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion plugin/ochttp/trace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ func serveHTTP(handler *Handler, done chan struct{}, wait chan time.Time, status
// Simulate a slow-responding server.
sleepUntil := <-wait
for time.Now().Before(sleepUntil) {
time.Sleep(sleepUntil.Sub(time.Now()))
time.Sleep(time.Until(sleepUntil))
}

io.WriteString(w, "expected-response")
Expand Down
4 changes: 2 additions & 2 deletions stats/view/view_to_metric_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ func initMetricDescriptors() {
}

func Test_ViewToMetric(t *testing.T) {
startTime := time.Now().Add(-time.Duration(60 * time.Second))
startTime := time.Now().Add(-60 * time.Second)
now := time.Now()
tests := []*testToMetrics{
{
Expand Down Expand Up @@ -460,7 +460,7 @@ func Test_ViewToMetric(t *testing.T) {
// Test to verify that a metric converted from a view with Aggregation Count should always
// have Dimensionless unit.
func TestUnitConversionForAggCount(t *testing.T) {
startTime := time.Now().Add(-time.Duration(60 * time.Second))
startTime := time.Now().Add(-60 * time.Second)
now := time.Now()
tests := []*struct {
name string
Expand Down

0 comments on commit 3da91ae

Please sign in to comment.