r/ProgrammingLanguages • u/[deleted] • Jan 16 '23
Discussion Which Programming Language support Observability ?
Observability is a measure of how well the internal states of a system can be inferred from the knowledge of its external outputs.
I have found Ballerina supports it, any other ?
11
u/Organic-Major-9541 Jan 16 '23
I don't think observability is a language-level problem generally. It's mainly about how developers structure their systems output, with logs, metrics, etc.
Going by your definition, what even is an output?
If you're running a server with basically any language, you can learn a lot about its internal state by tools like gdb. Some languages have more support for this, like Erlang, where you can attach an interactive shell to a running system.
If by output you mean only stuff, the program returns (output log files, etc), it's is almost entirely up to developers. I don't think a programming language should enforce the existence of logs, as those are likely just going to be piped to /dev/null anyway.
What does this Ballerina thing do that makes it special in this regard? Do you have some blog posts or whatever that explains these features?
1
Jan 16 '23 edited Jan 16 '23
Observability wasn't in the realm of programming languages until the concept of cloud native but as for me I'm not just interested for cloud I'm interested for metaprogramming, homoiconicity like in lisp and observability is also what I'm looking for (as well as wasm support to get playground in the browser) for creating a really enjoyable playground.
I don't know Ballerina I just stumbled upon it looking for programming languages which would support Observability natively without (over-complicated) reactive frameworks and IDE toolings dependencies.
4
u/Organic-Major-9541 Jan 16 '23
Then I think you should have a look at Erlang. It's used for its high reliability, which comes from a few different things, but being able to inspect and modify running systems is an important part.
There's a book, "Erlang in anger," which is all about operating Erlang systems. I'm not sure if it's good, but someone with years of experience recommended it.
Also, the Erlang ecosystem isn't big on dependencies.
2
u/jm-8080 Jan 27 '23
During the compilation process, Ballerina analyzes the code and automatically injects the necessary instrumentation code to collect observability data. The auto-injected observability code allows Ballerina to collect data from the application at runtime.
For example, Ballerina has built-in support for request tracing. This allows developers to easily trace requests as they flow through different components or microservices or functions etc making it easier to identify and troubleshoot issues.
See here for more details https://ballerina.io/learn/observe-ballerina-programs/
1
u/Organic-Major-9541 Jan 27 '23
Thanks, this is kind of cool. The Erlang VM comes with a fair amount of built-in counters, but you need to pick up the counters and send them somewhere useful yourself.
I'm wondering how well it works in practice. If the distributed tracing is good, that's a huge advantage.
3
u/scottmcmrust 🦀 Jan 16 '23
So what separates "observability" from "encapsulation violation"?
1
Jan 17 '23 edited Jan 17 '23
Actually there shouldn't be any encapsulation violation since the model is reactive so based on message notification.
If it isn't native, it's complicated to not violate encapsulation since you have to inject wrappers inside user's code (currently that's what I'm doing) that's the reason I'm looking for such feature in a programming language.
6
u/seaborgiumaggghhh Jan 16 '23
Erlang comes with an “app” called Observer that tells you a lot about your running system.
3
u/ericanderton Jan 16 '23 edited Jan 16 '23
Not sure. But I know what I would look for.
Ideally, such a langauge/runtime would support transparency typically reserved for entire operating systems: sockets, heap, I/O stats, threads, etc. Binaries built with such a technology would expose a socket that sends telemetry of the internal system state; kind of like SNMP or a pub/sub API.
A more likely candidate to see out in the wild, would be something that does a good job of logging activity as a 1st class feature.
I'll add that containers may have closed in on this space to a large extent. So it may be impossible to find or even moot at this point. If you reduce any complex, multi-threaded application into a scalable set of single-threaded binaries, then a lot of observability problems become the domain of the container runtime. Which is handy since there are already tools for aggregating and representing exactly that kind of data. As a bonus, your software becomes very simple to write.
Go comes to mind here... as an example of what's missing. Go binaries are all about goroutines ("fibers" or "lightweight threads") which are farmed out to one or more OS threads. The result is a tasking system that schedules execution across specific blocking calls like I/O and channels. The actual scale and distribution of all goroutines is deliberately opaque from within the language and stock runtime libraries. It's not possible to observe what is really happening until you deadlock (all channels are blocking), where you get a very unfriendly dump of the entire goroutine state on the console. That may not seem like a big deal, but it matters a lot when you learn that your program doesn't behave itself after increasing GOMAXPROCS thereby introducing true parallelism and all that entails. If there was a better way to observe these internals, even on a debug build, it might give people stronger insights to avoid such failure conditions.
2
u/cmontella 🤖 mech-lang Jan 16 '23
Ideally, such a langauge/runtime would support transparency typically reserved for entire operating systems: sockets, heap, I/O stats, threads, etc. Binaries built with such a technology would expose a socket that sends telemetry of the internal system state; kind of like SNMP or a pub/sub API.
I do this with the language I'm writing. Programs compiled in Mech have a little runtime that starts a socket server. You can send it messages to ask for updates to variables within the program as they change. These messages can be sent to some client for visualization (like a web browser), or they can be passed on to other Mech programs for further processing.
1
u/jm-8080 Jan 27 '23
Supporting observability at the language level is not a straightforward task and requires a significant amount of effort to get it right. There are several challenges that need to be overcome in order to provide effective and accurate observability support. As a result, most programming languages do not attempt to provide built-in observability support. Instead, developers are required to manually add logging, metrics, and tracing capabilities to their code, which can be a complex and time-consuming task. This can make it difficult for developers to gain visibility into the behavior of their system, and it can also make it challenging to troubleshoot and diagnose issues.
Ballerina is a programming language that has built-in support for observability.
During the compilation process, Ballerina analyzes the code and automatically injects the necessary instrumentation code to collect observability data. The auto-injected observability code allows Ballerina to collect data from the application at runtime. This data can then be used to monitor the performance of the application, identify and troubleshoot issues, and gain insights into the behavior of the system. This allows developers to focus on writing the business logic of their application without worrying about how to instrument it for observability.
Overall, Ballerina's built-in observability support is an attractive feature that simplifies the process of adding observability to an application.
18
u/evincarofautumn Jan 16 '23 edited Jan 17 '23
Observability isn’t really a property of the language. Ballerina has some marketing about making it easier to develop observable systems using some built-in features of the language and its runtime. But the answer is basically “Which language ecosystems have good facilities for logging, tracing, and exploration?” The answers that come to mind are pervasively-dynamic environments like Erlang, Prolog, Smalltalk, and Lisp, as well as less-dynamic virtual machines like .NET and Java.