Skip to content

Commit d68ca07

Browse files
committed
Address code review
1 parent a8dad37 commit d68ca07

File tree

1 file changed

+56
-52
lines changed

1 file changed

+56
-52
lines changed

docs/proposals/observability.md

Lines changed: 56 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ This Enhancement Proposal introduces the `ObservabilityPolicy` API, which allows
2020

2121
### Observability Policy
2222

23-
The Observability Policy contains settings to configure NGINX to expose information through tracing, metrics, and/or logging. This is a Direct Policy that is attached to an HTTPRoute or HTTPRoute Rule by an Application Developer. It works in conjunction with a [Gateway Settings](gateway-settings.md) configuration that contains higher level settings to enable Observability at this lower level. The [Gateway Settings](gateway-settings.md) configuration is managed by a Cluster Operator.
23+
The Observability Policy contains settings to configure NGINX to expose information through tracing, metrics, and/or logging. This is a Direct Policy that is attached to an HTTPRoute by an Application Developer. It works in conjunction with a [Gateway Settings](gateway-settings.md) configuration that contains higher level settings to enable Observability at this lower level. The [Gateway Settings](gateway-settings.md) configuration is managed by a Cluster Operator.
2424

25-
Since this policy is attached to an HTTPRoute or HTTPRoute rule, the Observability settings should just apply to the relevant `location` contexts of the NGINX config for that route or rule.
25+
Since this policy is attached to an HTTPRoute, the Observability settings should just apply to the relevant `location` contexts of the NGINX config for that route.
2626

2727
To begin, the Observability Policy will include the following NGINX directives (focusing on OpenTelemetry tracing):
2828

@@ -39,7 +39,7 @@ In the future, this config will be extended to support other functionality, such
3939

4040
## API, Customer Driven Interfaces, and User Experience
4141

42-
The `ObservabilityPolicy` API is a CRD that is a part of the `gateway.nginx.org` Group. It is a namespaced resource that will reference an HTTPRoute or HTTPRoute Rule as its target.
42+
The `ObservabilityPolicy` API is a CRD that is a part of the `gateway.nginx.org` Group. It is a namespaced resource that will reference an HTTPRoute as its target.
4343

4444
### Go
4545

@@ -49,90 +49,90 @@ Below is the Golang API for the `ObservabilityPolicy` API:
4949
package v1alpha1
5050

5151
import (
52-
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
53-
gatewayv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2"
52+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
53+
gatewayv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2"
5454
)
5555

5656
type ObservabilityPolicy struct {
57-
metav1.TypeMeta `json:",inline"`
58-
metav1.ObjectMeta `json:"metadata,omitempty"`
57+
metav1.TypeMeta `json:",inline"`
58+
metav1.ObjectMeta `json:"metadata,omitempty"`
5959

60-
// Spec defines the desired state of the ObservabilityPolicy.
61-
Spec ObservabilityPolicySpec `json:"spec"`
60+
// Spec defines the desired state of the ObservabilityPolicy.
61+
Spec ObservabilityPolicySpec `json:"spec"`
6262

63-
// Status defines the state of the ObservabilityPolicy.
64-
Status gatewayv1alpha2.PolicyStatus `json:"status,omitempty"`
63+
// Status defines the state of the ObservabilityPolicy.
64+
Status gatewayv1alpha2.PolicyStatus `json:"status,omitempty"`
6565
}
6666

6767
type ObservabilityPolicySpec struct {
68-
// TargetRef identifies an API object to apply the policy to.
69-
// Object must be in the same namespace as the policy.
70-
// Support: HTTPRoute and HTTPRoute rule
71-
TargetRef gatewayv1alpha2.PolicyTargetReferenceWithSectionName `json:"targetRef"`
68+
// TargetRef identifies an API object to apply the policy to.
69+
// Object must be in the same namespace as the policy.
70+
// Support: HTTPRoute
71+
TargetRef gatewayv1alpha2.PolicyTargetReference `json:"targetRef"`
7272

73-
// Tracing allows for enabling and configuring tracing.
73+
// Tracing allows for enabling and configuring tracing.
7474
//
75-
// +optional
76-
Tracing *Tracing `json:"tracing,omitempty"`
75+
// +optional
76+
Tracing *Tracing `json:"tracing,omitempty"`
7777
}
7878

7979
// Tracing allows for enabling and configuring OpenTelemetry tracing.
8080
type Tracing struct {
81-
// Ratio is the percentage of traffic that should be sampled. Integer from 0 to 100.
82-
// By default, 100% of http requests are traced. Not applicable for parent-based tracing.
81+
// Ratio is the percentage of traffic that should be sampled. Integer from 0 to 100.
82+
// By default, 100% of http requests are traced. Not applicable for parent-based tracing.
8383
//
84-
// +optional
85-
Ratio *int32 `json:"ratio,omitempty"`
84+
// +optional
85+
Ratio *int32 `json:"ratio,omitempty"`
8686

87-
// Context specifies how to propagate traceparent/tracestate headers. By default is 'ignore'.
87+
// Context specifies how to propagate traceparent/tracestate headers. By default is 'ignore'.
8888
//
89-
// +optional
90-
Context *TraceContext `json:"context,omitempty"`
89+
// +optional
90+
Context *TraceContext `json:"context,omitempty"`
9191

92-
// SpanName defines the name of the Otel span. By default is the name of the location for a request.
92+
// SpanName defines the name of the Otel span. By default is the name of the location for a request.
9393
//
94-
// +optional
95-
SpanName *string `json:"spanName,omitempty"`
94+
// +optional
95+
SpanName *string `json:"spanName,omitempty"`
9696

97-
// SpanAttributes are custom key/value attributes that are added to each span.
97+
// SpanAttributes are custom key/value attributes that are added to each span.
9898
//
99-
// +optional
100-
SpanAttributes map[string]string `json:"spanAttributes,omitempty"`
99+
// +optional
100+
SpanAttributes map[string]string `json:"spanAttributes,omitempty"`
101101

102-
// Enable defines if tracing is enabled, disabled, or parent-based.
103-
Enable TraceType `json:"enable"`
102+
// Enable defines if tracing is enabled, disabled, or parent-based.
103+
Enable TraceType `json:"enable"`
104104
}
105105

106106
// TraceType defines if tracing is enabled.
107107
type TraceType string
108108

109109
const (
110-
// TraceTypeOn enables tracing.
111-
TraceTypeOn TraceType = "on"
110+
// TraceTypeOn enables tracing.
111+
TraceTypeOn TraceType = "on"
112112

113-
// TraceTypeOff disables tracing.
114-
TraceTypeOff TraceType = "off"
113+
// TraceTypeOff disables tracing.
114+
TraceTypeOff TraceType = "off"
115115

116-
// TraceTypeParent enables tracing and only records spans if the parent span was sampled.
117-
TraceTypeParent TraceType = "parent"
116+
// TraceTypeParent enables tracing and only records spans if the parent span was sampled.
117+
TraceTypeParent TraceType = "parent"
118118
)
119119

120120
// TraceContext specifies how to propagate traceparent/tracestate headers.
121121
type TraceContext string
122122

123123
const (
124-
// TraceContextExtract uses an existing trace context from the request, so that the identifiers
125-
// of a trace and the parent span are inherited from the incoming request.
126-
TraceContextExtract TraceContext = "extract"
124+
// TraceContextExtract uses an existing trace context from the request, so that the identifiers
125+
// of a trace and the parent span are inherited from the incoming request.
126+
TraceContextExtract TraceContext = "extract"
127127

128-
// TraceContextInject adds a new context to the request, overwriting existing headers, if any.
129-
TraceContextInject TraceContext = "inject"
128+
// TraceContextInject adds a new context to the request, overwriting existing headers, if any.
129+
TraceContextInject TraceContext = "inject"
130130

131-
// TraceContextPropagate updates the existing context (combines extract and inject).
132-
TraceContextPropagate TraceContext = "propagate"
131+
// TraceContextPropagate updates the existing context (combines extract and inject).
132+
TraceContextPropagate TraceContext = "propagate"
133133

134-
// TraceContextIgnore skips context headers processing.
135-
TraceContextIgnore TraceContext = "ignore"
134+
// TraceContextIgnore skips context headers processing.
135+
TraceContextIgnore TraceContext = "ignore"
136136
)
137137
```
138138

@@ -159,7 +159,7 @@ spec:
159159
spanAttributes:
160160
attribute1: value1
161161
attribute2: value2
162-
enable: on
162+
enable: "on"
163163
status:
164164
ancestors:
165165
ancestorRef:
@@ -210,6 +210,8 @@ According to the [Policy and Metaresources GEP](https://gateway-api.sigs.k8s.io/
210210

211211
The `Accepted` Condition must be populated on the `ObservabilityPolicy` CRD using the reasons defined in the [PolicyCondition API](https://github.com/kubernetes-sigs/gateway-api/blob/main/apis/v1alpha2/policy_types.go). If these reasons are not sufficient, we can add implementation-specific reasons.
212212

213+
One reason for being `not Accepted` would be the fact that the `GatewaySettings` Policy is not configured, which is a requirement in order for the `ObservabilityPolicy` to work.
214+
213215
The Condition stanza may need to be namespaced using the `controllerName` if more than one controller could reconcile the Policy.
214216

215217
In the updated version of the [Policy and Metaresources GEP](https://github.com/kubernetes-sigs/gateway-api/pull/2813/files), which is still under review, the `PolicyAncestorStatus` applies to Direct Policies.
@@ -260,9 +262,11 @@ Some additional rules:
260262

261263
## Attachment
262264

263-
An `ObservabilityPolicy` can be attached to an HTTPRoute or an HTTPRoute rule (using a [sectionName](https://gateway-api.sigs.k8s.io/geps/gep-713/#apply-policies-to-sections-of-a-resource)).
265+
An `ObservabilityPolicy` can be attached to an HTTPRoute.
266+
267+
The policy will only take effect if a [GatewaySettings](gateway-settings.md) configuration has been linked to the GatewayClass. Otherwise, the `ObservabilityPolicy` should not be `Accepted`.
264268

265-
The policy will only take effect if a [GatewaySettings](gateway-settings.md) configuration has been linked to the GatewayClass.
269+
Future: Attached to an HTTPRoute rule, using a [sectionName](https://gateway-api.sigs.k8s.io/geps/gep-713/#apply-policies-to-sections-of-a-resource).
266270

267271
### Creating the Effective Policy in NGINX Config
268272

@@ -288,7 +292,7 @@ For this attachment scenario, specifying the directives in the _final_ location
288292
## Testing
289293

290294
- Unit tests
291-
- Functional tests that verify the attachment of the CRD to a Route or Route rule, and that NGINX behaves properly based on the configuration. This includes verifying tracing works as expected.
295+
- Functional tests that verify the attachment of the CRD to a Route, and that NGINX behaves properly based on the configuration. This includes verifying tracing works as expected.
292296

293297
## Security Considerations
294298

0 commit comments

Comments
 (0)