Skip to content

Commit

Permalink
Merge pull request #110 from Kuadrant/authorino-tracing-opts
Browse files Browse the repository at this point in the history
feat: add support for authorino tracing options
  • Loading branch information
guicassolato authored Mar 21, 2023
2 parents a137f07 + 1262f28 commit 96576c2
Show file tree
Hide file tree
Showing 11 changed files with 109 additions and 3 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ Each [`Authorino`](https://github.com/Kuadrant/authorino-operator/tree/main/conf
| logMode | String | Defines the log mode in Authorino (`development` or `production`). | Default: `production` |
| listener | [Listener](#listener) | Specification of the authorization service (gRPC interface). | Required |
| oidcServer | [OIDCServer](#oidcserver) | Specification of the OIDC service. | Required |
| tracing | [Tracing](#tracing) | Configuration of the OpenTelemetry tracing exporter. | Optional |
| metrics | [Metrics](#metrics) | Configuration of the metrics server (port, level). | Optional |
| healthz | [Healthz](#healthz) | Configuration of the health/readiness probe (port). | Optional |
| volumes | [VolumesSpec](#volumesspec) | Additional volumes to be mounted in the Authorino pods. | Optional |
Expand Down Expand Up @@ -169,6 +170,15 @@ Port numbers of the authorization server.
| grpc | Integer | Port number of the gRPC interface of the authorization server. Set to 0 to disable this interface. | Default: `50001` |
| http | Integer | Port number of the raw HTTP interface of the authorization server. Set to 0 to disable this interface. | Default: `5001` |

#### Tracing

Configuration of the OpenTelemetry tracing exporter.

| Field | Type | Description | Required/Default |
|----------|:------:|-------------|------------------|
| endpoint | String | Full endpoint of the OpenTelemetry tracing collector service (e.g. http://jaeger:14268/api/traces). | Required |
| tags | Map | Key-value map of fixed tags to add to all OpenTelemetry traces emitted by Authorino. | Optional |

#### Metrics

Configuration of the metrics server.
Expand Down
6 changes: 6 additions & 0 deletions api/v1beta1/authorino_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ type AuthorinoSpec struct {
AuthConfigLabelSelectors string `json:"authConfigLabelSelectors,omitempty"`
SecretLabelSelectors string `json:"secretLabelSelectors,omitempty"`
EvaluatorCacheSize *int `json:"evaluatorCacheSize,omitempty"`
Tracing Tracing `json:"tracing,omitempty"`
Metrics Metrics `json:"metrics,omitempty"`
Healthz Healthz `json:"healthz,omitempty"`
}
Expand Down Expand Up @@ -100,6 +101,11 @@ type Ports struct {
HTTP *int32 `json:"http,omitempty"`
}

type Tracing struct {
Endpoint string `json:"endpoint"`
Tags map[string]string `json:"tags,omitempty"`
}

type Metrics struct {
Port *int32 `json:"port,omitempty"`
DeepMetricsEnabled *bool `json:"deep,omitempty"`
Expand Down
4 changes: 2 additions & 2 deletions api/v1beta1/groupversion_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ limitations under the License.
*/

// Package v1beta1 contains API Schema definitions for the authorino-operator v1beta1 API group
//+kubebuilder:object:generate=true
//+groupName=operator.authorino.kuadrant.io
// +kubebuilder:object:generate=true
// +groupName=operator.authorino.kuadrant.io
package v1beta1

import (
Expand Down
23 changes: 23 additions & 0 deletions api/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions bundle/manifests/operator.authorino.kuadrant.io_authorinos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,17 @@ spec:
type: integer
secretLabelSelectors:
type: string
tracing:
properties:
endpoint:
type: string
tags:
additionalProperties:
type: string
type: object
required:
- endpoint
type: object
volumes:
properties:
defaultMode:
Expand Down
11 changes: 11 additions & 0 deletions config/crd/bases/operator.authorino.kuadrant.io_authorinos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,17 @@ spec:
type: integer
secretLabelSelectors:
type: string
tracing:
properties:
endpoint:
type: string
tags:
additionalProperties:
type: string
type: object
required:
- endpoint
type: object
volumes:
properties:
defaultMode:
Expand Down
11 changes: 11 additions & 0 deletions config/deploy/manifests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2564,6 +2564,17 @@ spec:
type: integer
secretLabelSelectors:
type: string
tracing:
properties:
endpoint:
type: string
tags:
additionalProperties:
type: string
type: object
required:
- endpoint
type: object
volumes:
properties:
defaultMode:
Expand Down
11 changes: 11 additions & 0 deletions config/install/manifests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,17 @@ spec:
type: integer
secretLabelSelectors:
type: string
tracing:
properties:
endpoint:
type: string
tags:
additionalProperties:
type: string
type: object
required:
- endpoint
type: object
volumes:
properties:
defaultMode:
Expand Down
8 changes: 8 additions & 0 deletions controllers/authorino_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,14 @@ func (r *AuthorinoReconciler) buildAuthorinoArgs(authorino *api.Authorino) []str
args = append(args, fmt.Sprintf("--%s=%d", flagEvaluatorCacheSize, *evaluatorCacheSize))
}

// tracing-service-endpoint and tracing-service-tag
if tracingServiceEndpoint := authorino.Spec.Tracing.Endpoint; tracingServiceEndpoint != "" {
args = append(args, fmt.Sprintf("--%s=%s", flagTracingServiceEndpoint, tracingServiceEndpoint))
for key, value := range authorino.Spec.Tracing.Tags {
args = append(args, fmt.Sprintf(`--%s="%s=%s"`, flagTracingServiceTag, key, value))
}
}

// deep-metrics-enabled
if enabled := authorino.Spec.Metrics.DeepMetricsEnabled; enabled != nil && *enabled {
args = append(args, fmt.Sprintf("--%s", flagDeepMetricsEnabled))
Expand Down
15 changes: 14 additions & 1 deletion controllers/authorino_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,13 @@ func newFullAuthorinoInstance() *api.Authorino {
},
},
},
Tracing: api.Tracing{
Endpoint: "http://tracing/authorino",
Tags: map[string]string{
"env": "test",
"version": "1.0.0",
},
},
},
}
}
Expand All @@ -308,7 +315,7 @@ func checkAuthorinoArgs(authorinoInstance *api.Authorino, args []string) {
flag := flagAndValue[0]
var value string
if len(flagAndValue) > 1 {
value = flagAndValue[1]
value = strings.Join(flagAndValue[1:], "=")
}

switch flag {
Expand Down Expand Up @@ -339,6 +346,12 @@ func checkAuthorinoArgs(authorinoInstance *api.Authorino, args []string) {
Expect(value).Should(SatisfyAny(Equal(defaultOidcTlsCertPath), Equal(defaultOidcTlsCertKeyPath)))
case flagEvaluatorCacheSize:
Expect(value).Should(Equal(fmt.Sprintf("%v", *authorinoInstance.Spec.EvaluatorCacheSize)))
case flagTracingServiceEndpoint:
Expect(value).Should(Equal(authorinoInstance.Spec.Tracing.Endpoint))
case flagTracingServiceTag:
kv := strings.Split(strings.TrimPrefix(strings.TrimSuffix(value, `"`), `"`), "=")
Expect(len(kv)).Should(Equal(2))
Expect(kv[1]).Should(Equal(authorinoInstance.Spec.Tracing.Tags[kv[0]]))
case flagDeepMetricsEnabled:
Expect(authorinoInstance.Spec.Metrics.DeepMetricsEnabled).ShouldNot(BeNil())
Expect(*authorinoInstance.Spec.Metrics.DeepMetricsEnabled).Should(BeTrue())
Expand Down
2 changes: 2 additions & 0 deletions controllers/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ const (
flagOidcTLSCertPath string = "oidc-tls-cert"
flagOidcTLSCertKeyPath string = "oidc-tls-cert-key"
flagEvaluatorCacheSize string = "evaluator-cache-size"
flagTracingServiceEndpoint string = "tracing-service-endpoint"
flagTracingServiceTag string = "tracing-service-tag"
flagDeepMetricsEnabled string = "deep-metrics-enabled"
flagMetricsAddr string = "metrics-addr"
flagHealthProbeAddr string = "health-probe-addr"
Expand Down

0 comments on commit 96576c2

Please sign in to comment.