Fix typo in view documentation and remove unnecessary type conversions (#1162)
* Remove unnecessary type conversions
* Fix typo in view documentation
diff --git a/metric/cumulative.go b/metric/cumulative.go
index 549d091..b25ba94 100644
--- a/metric/cumulative.go
+++ b/metric/cumulative.go
@@ -116,7 +116,7 @@
if val <= 0 {
return
}
- atomic.AddInt64(&e.val, int64(val))
+ atomic.AddInt64(&e.val, val)
}
// Int64DerivedCumulative represents int64 cumulative value that is derived from an object.
diff --git a/metric/metricexport/reader_test.go b/metric/metricexport/reader_test.go
index 7567924..33313dc 100644
--- a/metric/metricexport/reader_test.go
+++ b/metric/metricexport/reader_test.go
@@ -33,8 +33,8 @@
exporter1 = &metricExporter{}
exporter2 = &metricExporter{}
gaugeEntry *metric.Int64GaugeEntry
- duration1 = time.Duration(1000 * time.Millisecond)
- duration2 = time.Duration(2000 * time.Millisecond)
+ duration1 = 1000 * time.Millisecond
+ duration2 = 2000 * time.Millisecond
)
type metricExporter struct {
@@ -194,7 +194,7 @@
func TestNewIntervalReaderStartWithInvalidInterval(t *testing.T) {
ir, err := NewIntervalReader(reader1, exporter1)
- ir.ReportingInterval = time.Duration(500 * time.Millisecond)
+ ir.ReportingInterval = 500 * time.Millisecond
err = ir.Start()
if err == nil {
t.Fatalf("expected error but got nil\n")
diff --git a/plugin/ochttp/server.go b/plugin/ochttp/server.go
index 4f6404f..dc6563a 100644
--- a/plugin/ochttp/server.go
+++ b/plugin/ochttp/server.go
@@ -128,7 +128,7 @@
// TODO: Handle cases where ContentLength is not set.
} else if r.ContentLength > 0 {
span.AddMessageReceiveEvent(0, /* TODO: messageID */
- int64(r.ContentLength), -1)
+ r.ContentLength, -1)
}
return r.WithContext(ctx), span.End
}
@@ -174,8 +174,6 @@
// Compile time assertion for ResponseWriter interface
var _ http.ResponseWriter = (*trackingResponseWriter)(nil)
-var logTagsErrorOnce sync.Once
-
func (t *trackingResponseWriter) end(tags *addedTags) {
t.endOnce.Do(func() {
if t.statusCode == 0 {
diff --git a/stats/view/doc.go b/stats/view/doc.go
index dced225..7bbedfe 100644
--- a/stats/view/doc.go
+++ b/stats/view/doc.go
@@ -29,7 +29,7 @@
// LastValue just keeps track of the most recently recorded measurement value.
// All aggregations are cumulative.
//
-// Views can be registerd and unregistered at any time during program execution.
+// Views can be registered and unregistered at any time during program execution.
//
// Libraries can define views but it is recommended that in most cases registering
// views be left up to applications.
diff --git a/tag/map_codec.go b/tag/map_codec.go
index f8b5827..c242e69 100644
--- a/tag/map_codec.go
+++ b/tag/map_codec.go
@@ -168,7 +168,7 @@
eg := &encoderGRPC{
buf: make([]byte, len(m.m)),
}
- eg.writeByte(byte(tagsVersionID))
+ eg.writeByte(tagsVersionID)
for k, v := range m.m {
if v.m.ttl.ttl == valueTTLUnlimitedPropagation {
eg.writeByte(byte(keyTypeString))
diff --git a/tag/map_codec_test.go b/tag/map_codec_test.go
index 344ab0e..b607d2f 100644
--- a/tag/map_codec_test.go
+++ b/tag/map_codec_test.go
@@ -91,7 +91,7 @@
got := make([]keyValue, 0)
for k, v := range decoded.m {
- got = append(got, keyValue{k, string(v.value)})
+ got = append(got, keyValue{k, v.value})
}
want := tc.pairs