Opentelemetry provides vendor neutral standards and implementations to generate, collect, and export tracing data.
A Context is a propagation mechanism which carries execution-scoped values across API boundaries and between logically associated execution units. Cross-cutting concerns access their data in-process using the same shared Context object.
Context propagation is required when the tracing needs to cross process or service boundaries. Common ways to propagate the context is using W3C Trace Context or Zipkin B3 headers, while to inject the context is, for example, http headers or metadata fields in event messages.
Similar in syntax to scala3/dotty union types, although in Go is only allowed in constraints. The type set of this union element is the set {int, int8, int16, int32, int64}.
Doing code reviews, I have sometimes noticed libraries forcing dependencies on the users.
While it is perfectly acceptable if well justified and documented, it sometimes feels like adding unnecessary baggage.
A typical example would be something like the following snippet:
func(c*Client)HealthCheck(ctxcontext.Context)error{logrus.Debug("sending get request")req,err:=http.NewRequestWithContext(ctx,http.MethodGet,c.url,nil)iferr!=nil{returnerr}resp,err:=c.client.Do(req)iferr!=nil{returnerr}logrus.Debugf("http status code was %d",resp.StatusCode)deferresp.Body.Close()returnnil}
Using logrus, as example, picking this code, one would need to check how logrus works, which configurations are available, which version should be used and so on.
Each field is treated as an integer and has its value printed as a
zero-filled hexadecimal digit string with the most significant
digit first. The hexadecimal values "a" through "f" are output as
lower case characters and are case insensitive on input.
There are multiple ways of writing client libraries in Go. In this post, I will explore what I look for in a library depending if I am developing or checking if it is suitable for a project.
Without any specific order of importance, these are my thoughts on the subject.
Usage and Examples
Like a book can be judged by its cover, a project can be judged by its README. Therefore providing examples helps getting an idea of how the library works: if it will fit a project or how good the developer usability is (this includes function naming, usage difficulty or how easy it is to misuse).
log.dirs accepts a comma separated list of disks and will distribute partitions across them, however:
Doesn’t rebalance, some disks could be full and others empty.
Doesn’t tolerate any disk failure, more info in KIP-18.
Raid 10 is probably the best middle ground between performance and reliability.
*num.io.threads, *number of I/O threads that the server uses for executing requests. You should have at least as many threads as you have disks.
num.network.threads, number of network threads that the server uses for handling network requests. Increase based on number of producers/consumers and replication factor.
KAFKA_HEAP_OPTS, 5–8Gb heap should be enough for most deployments, file system cache is way more important. Linkedin runs 5Gb heap in 32Gb RAM servers.
pcstat can help understand how well the system is caching:
A circuit breaker is an automatically operated electrical switch designed to protect an electrical circuit from damage caused by over-current or overload or short circuit. Its basic function is to interrupt current flow after protective relays detect a fault. A circuit breaker can be reset (either manually or automatically) to resume normal operation.
The software analogue as described in Release it! chapter 5.2 can prevent repeated calls to a failing service by detecting issues and providing a fallback, by using this pattern it is possible to avoid cascading failures.