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

Commit

Permalink
go fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
dashpole committed Nov 1, 2022
1 parent edfb10a commit 9f8e122
Show file tree
Hide file tree
Showing 13 changed files with 34 additions and 29 deletions.
2 changes: 1 addition & 1 deletion examples/derived_gauges/derived_gauge.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
// items. Consumer randomly consumes 1-5 items in each attempt. It then sleeps randomly
// between 1-10 seconds before the next attempt. Two metrics collected to monitor the queue.
//
// Metrics
// # Metrics
//
// * queue_size: It is an instantaneous queue size represented using derived gauge int64.
//
Expand Down
2 changes: 1 addition & 1 deletion examples/gauges/gauge.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
// This example shows how to use gauge metrics. The program records two gauges, one to demonstrate
// a gauge with int64 value and the other to demonstrate a gauge with float64 value.
//
// Metrics
// # Metrics
//
// 1. process_heap_alloc (int64): Total bytes used by objects allocated in the heap.
// It includes objects currently used and objects that are freed but not garbage collected.
Expand Down
4 changes: 3 additions & 1 deletion examples/grpc/proto/helloworld.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion examples/quickstart/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
// limitations under the License.

// Command stats implements the stats Quick Start example from:
// https://opencensus.io/quickstart/go/metrics/
//
// https://opencensus.io/quickstart/go/metrics/
package main

import (
Expand Down
4 changes: 3 additions & 1 deletion internal/testpb/test.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion metric/test/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func (e *Exporter) ReadAndExport() {
e.metricReader.ReadAndExport(e)
}

// String defines the ``native'' format for the exporter.
// String defines the native format for the exporter.
func (e *Exporter) String() string {
return fmt.Sprintf("points{%v}", e.points)
}
Expand Down
8 changes: 5 additions & 3 deletions plugin/ochttp/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ import (
// Handler is an http.Handler wrapper to instrument your HTTP server with
// OpenCensus. It supports both stats and tracing.
//
// Tracing
// # Tracing
//
// This handler is aware of the incoming request's span, reading it from request
// headers as configured using the Propagation field.
// The extracted span can be accessed from the incoming request's
// context.
//
// span := trace.FromContext(r.Context())
// span := trace.FromContext(r.Context())
//
// The server span will be automatically ended at the end of ServeHTTP.
type Handler struct {
Expand Down Expand Up @@ -224,7 +224,9 @@ func (t *trackingResponseWriter) WriteHeader(statusCode int) {
}

// wrappedResponseWriter returns a wrapped version of the original
// ResponseWriter and only implements the same combination of additional
//
// ResponseWriter and only implements the same combination of additional
//
// interfaces as the original.
// This implementation is based on https://github.com/felixge/httpsnoop.
func (t *trackingResponseWriter) wrappedResponseWriter() http.ResponseWriter {
Expand Down
8 changes: 4 additions & 4 deletions plugin/runmetrics/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
//
// To enable collecting runtime metrics, just call Enable():
//
// _ := runmetrics.Enable(runmetrics.RunMetricOptions{
// EnableCPU: true,
// EnableMemory: true,
// })
// _ := runmetrics.Enable(runmetrics.RunMetricOptions{
// EnableCPU: true,
// EnableMemory: true,
// })
package runmetrics // import "go.opencensus.io/plugin/runmetrics"
7 changes: 3 additions & 4 deletions stats/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Package stats contains support for OpenCensus stats recording.
OpenCensus allows users to create typed measures, record measurements,
aggregate the collected data, and export the aggregated data.
Measures
# Measures
A measure represents a type of data point to be tracked and recorded.
For example, latency, request Mb/s, and response Mb/s are measures
Expand All @@ -33,7 +33,7 @@ Libraries can define and export measures. Application authors can then
create views and collect and break down measures by the tags they are
interested in.
Recording measurements
# Recording measurements
Measurement is a data point to be collected for a measure. For example,
for a latency (ms) measure, 100 is a measurement that represents a 100ms
Expand All @@ -49,7 +49,7 @@ Libraries can always record measurements, and applications can later decide
on which measurements they want to collect by registering views. This allows
libraries to turn on the instrumentation by default.
Exemplars
# Exemplars
For a given recorded measurement, the associated exemplar is a diagnostic map
that gives more information about the measurement.
Expand All @@ -64,6 +64,5 @@ then the trace span will be added to the exemplar associated with the measuremen
When exported to a supporting back end, you should be able to easily navigate
to example traces that fell into each bucket in the Distribution.
*/
package stats // import "go.opencensus.io/stats"
6 changes: 3 additions & 3 deletions stats/view/aggregation.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ func Sum() *Aggregation {
//
// If len(bounds) >= 2 then the boundaries for bucket index i are:
//
// [-infinity, bounds[i]) for i = 0
// [bounds[i-1], bounds[i]) for 0 < i < length
// [bounds[i-1], +infinity) for i = length
// [-infinity, bounds[i]) for i = 0
// [bounds[i-1], bounds[i]) for 0 < i < length
// [bounds[i-1], +infinity) for i = length
//
// If len(bounds) is 0 then there is no histogram associated with the
// distribution. There will be a single bucket with boundaries
Expand Down
2 changes: 1 addition & 1 deletion stats/view/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
// Libraries can define views but it is recommended that in most cases registering
// views be left up to applications.
//
// Exporting
// # Exporting
//
// Collected and aggregated data can be exported to a metric collection
// backend by registering its exporter.
Expand Down
13 changes: 6 additions & 7 deletions trace/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,23 @@ Package trace contains support for OpenCensus distributed tracing.
The following assumes a basic familiarity with OpenCensus concepts.
See http://opencensus.io
Exporting Traces
# Exporting Traces
To export collected tracing data, register at least one exporter. You can use
one of the provided exporters or write your own.
trace.RegisterExporter(exporter)
trace.RegisterExporter(exporter)
By default, traces will be sampled relatively rarely. To change the sampling
frequency for your entire program, call ApplyConfig. Use a ProbabilitySampler
to sample a subset of traces, or use AlwaysSample to collect a trace on every run:
trace.ApplyConfig(trace.Config{DefaultSampler: trace.AlwaysSample()})
trace.ApplyConfig(trace.Config{DefaultSampler: trace.AlwaysSample()})
Be careful about using trace.AlwaysSample in a production application with
significant traffic: a new trace will be started and exported for every request.
Adding Spans to a Trace
# Adding Spans to a Trace
A trace consists of a tree of spans. In Go, the current span is carried in a
context.Context.
Expand All @@ -44,8 +43,8 @@ It is common to want to capture all the activity of a function call in a span. F
this to work, the function must take a context.Context as a parameter. Add these two
lines to the top of the function:
ctx, span := trace.StartSpan(ctx, "example.com/Run")
defer span.End()
ctx, span := trace.StartSpan(ctx, "example.com/Run")
defer span.End()
StartSpan will create a new top-level span if the context
doesn't contain another span, otherwise it will create a child span.
Expand Down
2 changes: 1 addition & 1 deletion zpages/zpages.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
// zpages are currrently work-in-process and cannot display minutely and
// hourly stats correctly.
//
// Performance
// # Performance
//
// Installing the zpages has a performance overhead because additional traces
// and stats will be collected in-process. In most cases, we expect this
Expand Down

0 comments on commit 9f8e122

Please sign in to comment.