{"repo":"amanbolat/ft","free":true,"listed":false,"github":"https://github.com/amanbolat/ft","clone":"git clone https://github.com/amanbolat/ft.git","description":"Logs, traces and metrics for any function","language":"Go","stars":44,"topics":["go","logging","metrics","tracing"],"license":"0BSD","category":"analytics","readme_excerpt":"ft – function trace A lightweight library for tracing function execution with OpenTelemetry integration, structured logging, and metrics collection. Why? In most of my projects, I start by relying on simple logs to get quick insights into the application. As the project evolves, I usually add metrics and traces for improved observability, but setting up all the libraries can be time-consuming. This library allows you to enable the observability of your functions with just two lines of code. Features - Structured logging using slog . - OpenTelemetry tracing integration. - Metrics for execution counts and duration. - Configurable log level. - Option to opt out of metrics and tracing. Usage Just add two lines to the beginning of the function: If you run the code above, you will see the following output: Adding attributes dynamically You can add attributes to a span after it has been created using the AddAttrs method. This is useful when you want to add contextual information that becomes available during function execution: The AddAttrs method is thread-safe and can be called multiple times throughout the function execution. All attributes will be included in the final log output and, if enabled, added to the OpenTelemetry span. OpenTelemetry Integration Setup OTEL tracer and meter globally and ft will start sending metrics and traces to the OTLP collector: [!TIP] In the example above I use go-faster/sdk to setup OTEL based on environment variables. Configuration ft package prov","default_branch":null,"files":null,"tree":[],"storefront":"/r/amanbolat","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/amanbolat/ft/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}