Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add limitador tracing-endpoint command #130

Merged
merged 2 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ spec:
* [Storage Options](./doc/storage.md)
* [Rate Limit Headers](./doc/rate-limit-headers.md)
* [Logging](./doc/logging.md)
* [Tracing](./doc/tracing.md)
## Contributing
Expand Down
7 changes: 7 additions & 0 deletions api/v1alpha1/limitador_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ type LimitadorSpec struct {
// +optional
Telemetry *Telemetry `json:"telemetry,omitempty"`

// +optional
Tracing *Tracing `json:"tracing,omitempty"`

// +optional
Limits []RateLimit `json:"limits,omitempty"`

Expand Down Expand Up @@ -324,6 +327,10 @@ type Ports struct {
GRPC int32 `json:"grpc,omitempty"`
}

type Tracing struct {
Endpoint string `json:"endpoint"`
}

type PodDisruptionBudgetType struct {
// An eviction is allowed if at most "maxUnavailable" limitador pods
// are unavailable after the eviction, i.e. even in absence of
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ metadata:
capabilities: Basic Install
categories: Integration & Delivery
containerImage: quay.io/kuadrant/limitador-operator:latest
createdAt: "2024-04-04T14:34:19Z"
createdAt: "2024-04-15T10:48:14Z"
operators.operatorframework.io/builder: operator-sdk-v1.32.0
operators.operatorframework.io/project_layout: go.kubebuilder.io/v3
repository: https://github.com/Kuadrant/limitador-operator
Expand Down
7 changes: 7 additions & 0 deletions bundle/manifests/limitador.kuadrant.io_limitadors.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1083,6 +1083,13 @@ spec:
- basic
- exhaustive
type: string
tracing:
properties:
endpoint:
type: string
required:
- endpoint
type: object
verbosity:
description: Sets the level of verbosity
maximum: 4
Expand Down
7 changes: 7 additions & 0 deletions config/crd/bases/limitador.kuadrant.io_limitadors.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1084,6 +1084,13 @@ spec:
- basic
- exhaustive
type: string
tracing:
properties:
endpoint:
type: string
required:
- endpoint
type: object
verbosity:
description: Sets the level of verbosity
maximum: 4
Expand Down
30 changes: 30 additions & 0 deletions doc/tracing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Tracing

Limitador offers distributed tracing enablement using the `.spec.tracing` CR configuration:

```yaml
---
apiVersion: limitador.kuadrant.io/v1alpha1
kind: Limitador
metadata:
name: limitador-sample
spec:
listener:
http:
port: 8080
grpc:
port: 8081
limits:
- conditions: ["get_toy == 'yes'"]
max_value: 2
namespace: toystore-app
seconds: 30
variables: []
verbosity: 3
tracing:
endpoint: rpc://my-otlp-collector:4317
```
Currently limitador only supports collectors using the OpenTelemetry Protocol with TLS disabled. The `endpoint` configuration option should contain the scheme, host and port of the service. The quantity and level of the information provided by the spans is configured via the `verbosity` argument.

![Limitador tracing example](https://github.com/Kuadrant/limitador-operator/assets/6575004/7bdc7c17-37a5-4dfe-ac56-432efa1070c4)
4 changes: 4 additions & 0 deletions pkg/limitador/deployment_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ func DeploymentCommand(limObj *limitadorv1alpha1.Limitador, storageOptions Deplo
command = append(command, "--limit-name-in-labels")
}

if limObj.Spec.Tracing != nil {
command = append(command, "--tracing-endpoint", limObj.Spec.Tracing.Endpoint)
}

if limObj.Spec.Verbosity != nil {
command = append(command, fmt.Sprintf("-%s", strings.Repeat("v", int(*limObj.Spec.Verbosity))))
}
Expand Down
20 changes: 20 additions & 0 deletions pkg/limitador/deployment_options_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,26 @@ func TestDeploymentCommand(t *testing.T) {
})
}
})

t.Run("command from tracing endpoint appended", func(subT *testing.T) {
testEndpoint := "rpc://tracing-endpoint:4317"
limObj := basicLimitador()
limObj.Spec.Tracing = &limitadorv1alpha1.Tracing{
Endpoint: testEndpoint,
}
command := DeploymentCommand(limObj, DeploymentStorageOptions{})
assert.DeepEqual(subT, command,
[]string{
"limitador-server",
"--tracing-endpoint",
testEndpoint,
"--http-port",
strconv.Itoa(int(limitadorv1alpha1.DefaultServiceHTTPPort)),
"--rls-port",
strconv.Itoa(int(limitadorv1alpha1.DefaultServiceGRPCPort)),
"/home/limitador/etc/limitador-config.yaml",
})
})
}

func TestDeploymentVolumeMounts(t *testing.T) {
Expand Down
Loading