Open telemetry integration (#3972)

This PR adds opentelemetry and chi wrapper to have basic instrumentation

<!--start release-notes-assistant-->

## Draft release notes
<!--URL:https://codeberg.org/forgejo/forgejo-->
- Features
  - [PR](https://codeberg.org/forgejo/forgejo/pulls/3972): <!--number 3972 --><!--line 0 --><!--description YWRkIHN1cHBvcnQgZm9yIGJhc2ljIHJlcXVlc3QgdHJhY2luZyB3aXRoIG9wZW50ZWxlbWV0cnk=-->add support for basic request tracing with opentelemetry<!--description-->
<!--end release-notes-assistant-->

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/3972
Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org>
Co-authored-by: TheFox0x7 <thefox0x7@gmail.com>
Co-committed-by: TheFox0x7 <thefox0x7@gmail.com>
This commit is contained in:
TheFox0x7 2024-08-05 06:04:39 +00:00 committed by Earl Warren
parent 7c74def6ff
commit c738542201
19 changed files with 1281 additions and 10 deletions

View file

@ -1963,7 +1963,7 @@ LEVEL = Info
;; Url lookup for the minio bucket only available when STORAGE_TYPE is `minio`
;; Available values: auto, dns, path
;; If empty, it behaves the same as "auto" was set
;MINIO_BUCKET_LOOKUP =
;MINIO_BUCKET_LOOKUP =
;;
;; Minio location to create bucket only available when STORAGE_TYPE is `minio`
;MINIO_LOCATION = us-east-1
@ -2606,6 +2606,70 @@ LEVEL = Info
;; Enable RPM re-signing by default. (It will overwrite the old signature ,using v4 format, not compatible with CentOS 6 or older)
;DEFAULT_RPM_SIGN_ENABLED = false
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;[opentelemetry]
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; https://opentelemetry.io/docs/specs/otel/configuration/sdk-environment-variables/#general-sdk-configuration&ia=web
;; Enable the feature, Inverse of OTEL_SDK_DISABLED
;ENABLED = false
;; Comma separated custom attributes for the application
;RESOURCE_ATTRIBUTES =
;; Service name for the application
;SERVICE_NAME = forgejo
;; Set sampler used by trace exporter, accepted values are:
;; - `always_off` - never samples spans
;; - `always_on` - always samples spans
;; - `traceidratio` - samples based on given ratio given in SAMPLER_ARG
;; - `parentbased_always_off` - samples based on parent span, never samples spans without parent spans
;; - `parentbased_always_on` - samples based on parent span, always samples spans without parent spans
;; - `parentbased_traceidratio` - samples based on parent span, samples spans without parent spans on given ratio given in SAMPLER_ARG
;TRACES_SAMPLER = parentbased_always_on
;; Argument for the sampler, only applies to traceidratio based samplers
;; `traceidratio` expects a value between 0-1 based on which it samples (`0` it acts like `always_off`, `1` like `always_on`)
;TRACES_SAMPLER_ARG =
;; https://opentelemetry.io/docs/specs/otel/configuration/sdk-environment-variables/#exporter-selection
;; Controls the exporter used to send data, set to `none` to fully disable the signal
;TRACES_EXPORTER=otlp
;; Active decoders for attributes, available values:
;; - `sdk` - adds information about opentelemetry sdk used
;; - `process` - adds information about the process
;; - `os` - adds information about the OS forgejo is running on
;; - `host` - adds information about the host forgejo is running on
;; This setting is non-standard and subject to changes!
;RESOURCE_DETECTORS = host,process
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;[opentelemetry.exporter.otlp]
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; https://opentelemetry.io/docs/specs/otel/protocol/exporter/#configuration-options
;; Target URL to which the exporter is going to send spans, metrics, or logs.
;ENDPOINT=http://localhost:4318
;; The trusted certificate to use when verifying a servers TLS credentials. Should only be used for a secure connection.
;CERTIFICATE=
;; Client certificate/chain trust for clients private key to use in mTLS communication in PEM format.
;CLIENT_CERTIFICATE=
;; Clients private key to use in mTLS communication in PEM format.
;CLIENT_KEY=
;; Compression key for supported compression types. Supported compression: `gzip`.
;COMPRESSION=
;; Key-value pairs to be used as headers associated with gRPC or HTTP requests
;HEADERS=
;; The transport protocol. Options MUST be one of: `grpc`, or `http/protobuf`
;PROTOCOL=http/protobuf
;; Maximum time the OTLP exporter will wait for each batch export.
;TIMEOUT=10s
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; default storage for attachments, lfs and avatars
@ -2686,7 +2750,7 @@ LEVEL = Info
;; Url lookup for the minio bucket only available when STORAGE_TYPE is `minio`
;; Available values: auto, dns, path
;; If empty, it behaves the same as "auto" was set
;MINIO_BUCKET_LOOKUP =
;MINIO_BUCKET_LOOKUP =
;;
;; Minio location to create bucket only available when STORAGE_TYPE is `minio`
;MINIO_LOCATION = us-east-1