mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2024-12-25 11:42:11 +00:00
[feature] add support for sending headers to tracing system
Add support for sending additional HTTP or gRPC headers which can be used for authentication or other additional information for the tracing system without having to set up a local instance of the OpenTelemetry Collector to add these headers. Example with Dash0: ```yaml tracing-enabled: false tracing-transport: "grpc" tracing-endpoint: "ingress.eu-west-1.aws.dash0.com:4317" tracing-headers: "Authorization": "Bearer DASH0_AUTH_TOKEN" "Dash0-Dataset": "gotosocial" ``` Example with Honeycomb: ```yaml tracing-enabled: false tracing-transport: "grpc" tracing-endpoint: "api.honeycomb.io:443" tracing-headers: "x-honeycomb-team": "YOUR_API_KEY" "x-honeycomb-dataset": "YOUR_DATASET" ```
This commit is contained in:
parent
8504043024
commit
56204cc2f4
|
@ -12,6 +12,9 @@ You'll need the files in [`example/tracing`][ext]. Once you have those you can r
|
|||
tracing-enabled: true
|
||||
tracing-transport: "grpc"
|
||||
tracing-endpoint: "localhost:4317"
|
||||
tracing-headers:
|
||||
"Authorization": "Bearer super-secret-token"
|
||||
"Dataset": "gotosocial"
|
||||
tracing-insecure-transport: true
|
||||
```
|
||||
|
||||
|
|
|
@ -35,6 +35,13 @@ tracing-transport: "grpc"
|
|||
# Default: ""
|
||||
tracing-endpoint: ""
|
||||
|
||||
# Map of strings. Additional headers to send to the trace ingester.
|
||||
# Additional HTTP or gRPC headers can be used for authentication or other additional
|
||||
# information for the tracing system.
|
||||
# Examples: {"Authorization": "Bearer super-secret-token", "Dataset": "gotosocial"}
|
||||
# Default: {}
|
||||
tracing-headers: {}
|
||||
|
||||
# Bool. Disable TLS for the gRPC and HTTP transport protocols.
|
||||
# Default: false
|
||||
tracing-insecure-transport: false
|
||||
|
|
|
@ -12,6 +12,9 @@ GoToSocial 内置了基于 [OpenTelemetry][otel] 的追踪功能。虽然并没
|
|||
tracing-enabled: true
|
||||
tracing-transport: "grpc"
|
||||
tracing-endpoint: "localhost:4317"
|
||||
tracing-headers:
|
||||
"Authorization": "Bearer super-secret-token"
|
||||
"Dataset": "gotosocial"
|
||||
tracing-insecure-transport: true
|
||||
```
|
||||
|
||||
|
|
|
@ -31,6 +31,11 @@ tracing-transport: "grpc"
|
|||
# 默认值: ""
|
||||
tracing-endpoint: ""
|
||||
|
||||
# TODO
|
||||
# 示例: {"Authorization": "Bearer super-secret-token", "Dataset": "gotosocial"}
|
||||
# 默认值: {}
|
||||
tracing-headers: {}
|
||||
|
||||
# 布尔值。禁用gRPC和HTTP传输协议的TLS。
|
||||
# 默认值: false
|
||||
tracing-insecure-transport: false
|
||||
|
|
|
@ -928,6 +928,13 @@ tracing-transport: "grpc"
|
|||
# Default: ""
|
||||
tracing-endpoint: ""
|
||||
|
||||
# Map of strings. Additional headers to send to the trace ingester.
|
||||
# Additional HTTP or gRPC headers can be used for authentication or other additional
|
||||
# information for the tracing system.
|
||||
# Examples: {"Authorization": "Bearer super-secret-token", "Dataset": "gotosocial"}
|
||||
# Default: {}
|
||||
tracing-headers: {}
|
||||
|
||||
# Bool. Disable TLS for the gRPC and HTTP transport protocols.
|
||||
# Default: false
|
||||
tracing-insecure-transport: false
|
||||
|
|
|
@ -140,10 +140,11 @@ type Configuration struct {
|
|||
OIDCAllowedGroups []string `name:"oidc-allowed-groups" usage:"Membership of one of the listed groups allows access to GtS. If this is empty, all groups are allowed."`
|
||||
OIDCAdminGroups []string `name:"oidc-admin-groups" usage:"Membership of one of the listed groups makes someone a GtS admin"`
|
||||
|
||||
TracingEnabled bool `name:"tracing-enabled" usage:"Enable OTLP Tracing"`
|
||||
TracingTransport string `name:"tracing-transport" usage:"grpc or http"`
|
||||
TracingEndpoint string `name:"tracing-endpoint" usage:"Endpoint of your trace collector. Eg., 'localhost:4317' for gRPC, 'localhost:4318' for http"`
|
||||
TracingInsecureTransport bool `name:"tracing-insecure-transport" usage:"Disable TLS for the gRPC or HTTP transport protocol"`
|
||||
TracingEnabled bool `name:"tracing-enabled" usage:"Enable OTLP Tracing"`
|
||||
TracingTransport string `name:"tracing-transport" usage:"grpc or http"`
|
||||
TracingEndpoint string `name:"tracing-endpoint" usage:"Endpoint of your trace collector. Eg., 'localhost:4317' for gRPC, 'localhost:4318' for http"`
|
||||
TracingHeaders map[string]string `name:"tracing-headers" usage:"Headers for your trace collector. Eg., 'Authorization: Bearer super-secret-token' for sending an 'Authorization' header"`
|
||||
TracingInsecureTransport bool `name:"tracing-insecure-transport" usage:"Disable TLS for the gRPC or HTTP transport protocol"`
|
||||
|
||||
MetricsEnabled bool `name:"metrics-enabled" usage:"Enable OpenTelemetry based metrics support."`
|
||||
MetricsAuthEnabled bool `name:"metrics-auth-enabled" usage:"Enable HTTP Basic Authentication for Prometheus metrics endpoint"`
|
||||
|
|
|
@ -120,6 +120,7 @@
|
|||
TracingEnabled: false,
|
||||
TracingTransport: "grpc",
|
||||
TracingEndpoint: "",
|
||||
TracingHeaders: map[string]string{},
|
||||
TracingInsecureTransport: false,
|
||||
|
||||
MetricsEnabled: false,
|
||||
|
|
|
@ -2191,6 +2191,22 @@ func (st *ConfigState) SetTracingEndpoint(v string) {
|
|||
st.reloadToViper()
|
||||
}
|
||||
|
||||
// GetTracingHeaders safely fetches the Configuration value for state's 'TracingHeaders' field
|
||||
func (st *ConfigState) GetTracingHeaders() (v map[string]string) {
|
||||
st.mutex.RLock()
|
||||
v = st.config.TracingHeaders
|
||||
st.mutex.RUnlock()
|
||||
return
|
||||
}
|
||||
|
||||
// SetTracingEndpoint safely sets the Configuration value for state's 'TracingHeaders' field
|
||||
func (st *ConfigState) SetTracingHeaders(v map[string]string) {
|
||||
st.mutex.Lock()
|
||||
defer st.mutex.Unlock()
|
||||
st.config.TracingHeaders = v
|
||||
st.reloadToViper()
|
||||
}
|
||||
|
||||
// TracingEndpointFlag returns the flag name for the 'TracingEndpoint' field
|
||||
func TracingEndpointFlag() string { return "tracing-endpoint" }
|
||||
|
||||
|
|
|
@ -60,6 +60,7 @@ func Initialize() error {
|
|||
case "grpc":
|
||||
opts := []otlptracegrpc.Option{
|
||||
otlptracegrpc.WithEndpoint(config.GetTracingEndpoint()),
|
||||
otlptracegrpc.WithHeaders(config.NewState().GetTracingHeaders()),
|
||||
}
|
||||
if insecure {
|
||||
opts = append(opts, otlptracegrpc.WithInsecure())
|
||||
|
|
Loading…
Reference in a new issue