Coder Social home page Coder Social logo

Comments (8)

rakyll avatar rakyll commented on July 19, 2024

As well as some testing helpers such as RestartWorker.

from opencensus-go.

acetechnologist avatar acetechnologist commented on July 19, 2024

from opencensus-go.

rakyll avatar rakyll commented on July 19, 2024

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.

acetechnologist avatar acetechnologist commented on July 19, 2024

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.

rakyll avatar rakyll commented on July 19, 2024

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.

acetechnologist avatar acetechnologist commented on July 19, 2024

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.

rakyll avatar rakyll commented on July 19, 2024

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.

rakyll avatar rakyll commented on July 19, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.