Comments (8)
As well as some testing helpers such as RestartWorker.
from opencensus-go.
-
AggregationDistributionValue and AggregationCountValue are not intended for testing only. They will be used by the exporters (stackdriver, zpages...).
-
RestartWorker is for testing. It is already used in:
https://github.com/census-instrumentation/opencensus-go/blob/master/plugins/grpc/stats/client_handler_test.go
https://github.com/census-instrumentation/opencensus-go/blob/master/plugins/grpc/stats/server_handler_test.go
from opencensus-go.
I wonder whether AggregationValue and Aggregation can export their APIs. Then, we can organize the testing-focused implementations to stats/statstest, in the same fashion as http/httptest.
The package's surface layer is too noisy for the user to be able to focus on the essential and get started. I think we can improve it easily by the stats/statstest package.
from opencensus-go.
Not sure I understand what you mean by "can export their APIs".
AggregationValue is an interface where the other libraries don't need access to any of their methods.
However export libraries will need access to some other non common methods implemented by AggregationCountValue, AggregationDistributionValue which are "subclasses" of that interface.
The problem is that Go doesn't have generics and methods on AggregationDistributionValue need to return a different types than the methods on AggregationCountValue.
/cc @jcd2 as it might be of interest to him
from opencensus-go.
A named empty interface (or an interface without any exported methods) is a very odd thing in Go. It gives users no way to discover the implementations by looking at the godoc. If I was not reading the source code, I'd have little or no clue that AggregationCount is implementing Aggregation.
My suggestion is to export the methods on interface, so implementations can live anywhere.
// Aggregation represents ....
type Aggregation interface {
Value() func() AggregationValue
}
Then, the exporters can always switch type and do whatever for the types provided from the blessed packages.
Or we can make the interface depend on an internal symbol (example) not to allow anyone outside of the opencensus packages to implement the interface. But within the Census packages, we will have flexibility to organize stuff in multiple packages.
from opencensus-go.
type Aggregation interface {
Value() func() AggregationValue
}
Why export something that is not necessary or even useful? This function is only useful because of the implementation details I decided to go with. If tomorrow we decide to change the implementation details and don't need this function it will be easier if it is not exported.
Having the interface depend on an internal symbol is fine with me. It will allow the user to know which types are actually aggregations but I think the same can be achieved with documentation.
from opencensus-go.
Let's wait for the implementation details, and we can ask others to provide some more feedback/ideas. Anything can be fixed by docs but docs should always be the last resort.
from opencensus-go.
Won't fix because we need these types provide accessors to their fields and exporters will depend on them when uploading data.
from opencensus-go.
Related Issues (20)
- Remove rakyll from being an auto-assignee for reviews HOT 3
- metric: document how to use the Registry and export metrics out HOT 1
- Test_Worker_MultiExport intermittently fails: Mismatched value
- Defining stats and views for dynamically created endpoints HOT 4
- stats: defaultWorker can not be stopped HOT 1
- [ochttp] KeyClientHost tag doesn't change in exported Prometheus metrics
- compile error HOT 1
- Improve performance of stats recording HOT 6
- Tracestate header not generated or mutated
- race condition inside opencensus ochttp when used inside google storage API
- ProbabilitySampler always sample when incoming trace-id is 64-bit (B3/Jaeger)
- Span name with stack trace
- Tag has concurrent access problem
- Is there a function or way to transfor `view.Data` to `WriteRequest` HOT 2
- Testify needs updating due to DOS and Null ptr dereference - plz update testify to >= 1.7.5
- Security issue: recording query params insecure (tokens) HOT 7
- Panic when running stats.Record without importing the view package
- ochttp.Handler.ServeHTTP func param r * http.Request did not modify r.MultipartForm correctly HOT 3
- Hash pin github workflow dependencies
- Memory statistics never collected unless UseDerivedCumulative is used
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from opencensus-go.