text
stringlengths
0
2.35k
**Bartlomiej Płotka:** Yeah. And this is why I solved those issues, because you were nice to me. Yeah, exactly.
**Mat Ryer:** There you go. Yeah.
**Björn Rabenstein:** Even for features that are really non-controversial, if a package is used so frequently, you are really, really, really concerned about not breaking anyone, and that sometimes is weird, right? Also, when we added exemplars... Exemplars is also a huge thing, right? Perhaps we can talk about that la...
**Mat Ryer:** Yeah.
**Björn Rabenstein:** Guess what we all thought?
**Mat Ryer:** For consistency.
**Björn Rabenstein:** ...channels are the coolest thing, right? So we put channels in the function signatures, essentially used them as concurrency-safe iterators, which, you know, that's not what they're supposed to be used for. But they're still there, because if you now just change it \[unintelligible 00:27:42.22\] ...
**Mat Ryer:** \[27:58\] Yeah. The cruft you mentioned is interesting, because in Go especially we pay a lot of attention to writing very easy-to-read, maintainable code, and sometimes we'll sacrifice performance, in the right place, for readability. And then whenever you have to then optimize, of course, you're doing d...
**Bartlomiej Płotka:** Yeah, lots of trade-offs that are there. And I think what's also cool about this is it's just one module. These days it's so popular to create instrumentation libraries with like 10 modules, because you want to be, I don't know, generic, or have different versioning across. It's really hard to co...
**Björn Rabenstein:** I didn't start it, right? I took over from the founders of the Prometheus project, Matt and Julius. They started this, and when I joined the team in 2013, I think, then one of the tasks I took over was this instrumentation library. And even back then, it started essentially with a whole rewrite, b...
Yeah, we thought a lot about optimizing, because we knew this is in every path, if you instrument your code; but often, we were wrong. And micro-benchmarks is a cool tool. Actually, my first GopherCon talk - that was at the second GopherCon ever, or third, I don't know. Back then, it was really, really exciting. It wen...
It's interesting how also later you realize, when your programs get faster and they want to increment this counter really often, how that is problematic. Then you have histograms where you want to increment pockets, and then you realize they have to be incremented all together, because otherwise you can get inconsisten...
**Johnny Boursiquot:** So speaking for -- I like to sort of put myself in the shoes of a user of these instrumentation libraries, not necessarily a maintainer of them; that's sort of the lens we've been using for a little bit... So if I wanted to instrument my code -- so we've already teased out what instrumentation me...
**Björn Rabenstein:** \[32:48\] I think there is a problem that - who knows if you use Prometheus for metrics collection? Perhaps you use something else, and then you want to instrument not just for metrics, but for all the other things. And of course, you have a lot of choices to make. And then there are a lot of effo...
So the first question in a practical context is you should look at what your organization you're working in is doing. Often, they use some framework, right? They use -- whatever. Let's start with a web router. You have your favorite Go web router, or whatever. And then from there on, you can kind of inform that decisio...
So just merely by using this framework, which you would use anyway, you were instrumented for traces, for metrics... You've got some logging, some standardized logging... It's all in there. We phrased this coin -- yeah, no, we coined the phrase that at SoundCloud it was easier to get monitoring than to not get monitori...
I mean, rarely you have like a greenfield approach. If you do -- I mean, that's also fun, of course. You start your first Go program, and then you could just link in the Prometheus Client Golang... It's like, they're very minimalist programs in the documentation where you can just link it in, expose an HTTP endpoint, a...
**Bartlomiej Płotka:** Yeah. It's hard to mention, because you don't need to reimplement every possible metric instrumentation. So for example, if your application is doing an HTTP request, which probably 90% of applications do, you don't need to create a special separate HTTP request metric, or actually logline and tr...
\[36:08\] And actually, the other plus of it is that you are getting lots of observability for free. So someone probably already built some Grafana dashboards, and maybe alerts, and maybe recording rules for this information, right? So we think you already created from HTTP package in Prometheus Client Golang, which al...
Break: \[36:49\]
**Mat Ryer:** Well, that brings us to a new segment that I've just literally made up, but the editors do a great job when I do this... It's time for "Explain it quickly". So I'm going to challenge you, Bartek, to explain exemplars as quick as you can. Exemplars. We mentioned them earlier. What are they?
**Bartlomiej Płotka:** Okay, quickest.
**Mat Ryer:** Go!
**Bartlomiej Płotka:** I think the easiest way to mention this - it is essentially an information that allows you to show an example situation that triggered some metric increment or metric latency observation, size observation, whatever you are measuring. And you can essentially -- usually, it's just a string, some ch...
**Mat Ryer:** \[40:32\] Cool. Congratulations. That was very well explained, and pretty quick as well, which really gets into the spirit of things, so thank you for that. Okay. But you don't include an example in every case, right? Do you do this kind of randomly, or how do you decide when to emit an exemplar?
**Bartlomiej Płotka:** Björn, go for it. I can see you want to explain that.
**Björn Rabenstein:** Do I? \[laughs\] I'm not even sure if I'm the most qualified person for that, but anyway... if you use metrics to measure something that is essentially just a whole bunch of events, like your HTTP request, then metrics means you count them all together, you kind of aggregate along certain dimensio...
That's actually a super-interesting question. We have a similar thing when you do like logging or tracing, where you do try to collect every single event, and you realize you can't really do this. So the naive thing is I just sample every thousandth - complicated word... Then you realize, "No, that's just getting me th...
The current -- like, if you have a normal Prometheus histogram and put exemplars there, they just put the last observation that fell into each pocket, which I think is a pretty good heuristic, because you get exactly one exemplar for every latency band you're interested in... Which is a good start, I think, but I think...
**Bartlomiej Płotka:** And I think it's important to mention exactly what you did say about sampling... We have to make sure the example you put there, for example, trace ID - it is the one that will be sampled and provided in your tracing backend, right? So those systems have to be, at some point, connected. And I mad...
**Björn Rabenstein:** Yeah, we had those discussions a lot like you should... The tracing system should just sample those that Prometheus has as examplers. That's the one direction. Or the other is you somehow want to tell your binary to pick the exemplars according to what your tracing system has sampled. So it's a bi...
**Bartlomiej Płotka:** Anyway, if you are using Client Golang, and you are using tracing, and you are not using exemplars, you are missing out. It's a very underestimated feature. Please use it.
**Mat Ryer:** There you go.
**Johnny Boursiquot:** When should you adjust your sampling? In the beginning are you just basically saying, "Okay, I don't want any sampling. I want everything, because I don't understand the system yet. I want to see -- I want to detect patterns", or something like that, and then maybe before production you pick some...
**Björn Rabenstein:** Bartek, you should be in a better position to answer.
**Bartlomiej Płotka:** \[44:07\] Sure. So it's really tough situation, because it's really around tracing instrumentation and libraries. Usually, sampling is not application-driven. It's really communicated or done on a collector level, or agents. And so there are different phases you can do that. So it has to be colla...
**Johnny Boursiquot:** Can you define tail sampling?
**Bartlomiej Płotka:** Yeah, of course. So tail sampling is when you decide that you save--
**Mat Ryer:** You can do this slowly, Bartek. This isn't part of the segment "Do it fast." You can just take your time on this one.
**Bartlomiej Płotka:** So data sampling is when you decide if you are throwing a trace span, or you are saving it in your backend system, after even the request happened, because as we know, traces are really bound to some request. And it's very useful, because you can also then have a heuristic that will decide if you...
**Mat Ryer:** Yeah. Actually, the more I learn and hear about this, the more complicated it seems. Should everyone pay attention to this now? What point in a career should a young engineer really start paying attention to this? Because like you said, Björn, we used to -- we didn't really do it at all. It was kind of ha...
**Björn Rabenstein:** I wrote this little piece in this 97 Things Every SRE Should Know About The Third Age of SRE, and it kind of ends with that sentence where we are really in the third age of SRE, if SRE is taught at universities. Just as if you're a computer scientist student and even before you get your bachelor y...
If you are looking for your first job, you might even check out if that company you're working for is already doing this, because if you're experienced with that already, you could even evangelize this in an organization, and it's great fun, because it's so satisfying to see all the progress you made by just introducin...
**Mat Ryer:** Oh, good question for the interview there maybe. Johnny, aren't you an SRE? Aren't you literally an SRE right now?
**Johnny Boursiquot:** Yeah. And I just realize where I've come across Björn before. We were both co-authors in the same book, 97 Things Every SRE Should Know. \[laughter\] That's how we met.
**Mat Ryer:** Okay.
**Johnny Boursiquot:** Yeah.
**Mat Ryer:** That's a nice way to meet.
**Johnny Boursiquot:** I know, right?
**Mat Ryer:** The other 95 should -- you should all get together with the other 95 and have a big party.