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

fixes #2207 by adding server-url to JaegerMetricsStorageSpec #2481

Merged
merged 17 commits into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
3 changes: 3 additions & 0 deletions apis/v1/jaeger_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,9 @@ type JaegerStorageSpec struct {
type JaegerMetricsStorageSpec struct {
// +optional
Type JaegerStorageType `json:"type,omitempty"`

// +optional
ServerUrl string `json:"server-url,omitempty"`
}

// ElasticsearchSpec represents the ES configuration options that we pass down to the OpenShift Elasticsearch operator.
Expand Down
4 changes: 4 additions & 0 deletions config/crd/bases/jaegertracing.io_jaegers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2561,6 +2561,8 @@ spec:
type: object
metricsStorage:
properties:
server-url:
type: string
type:
type: string
type: object
Expand Down Expand Up @@ -8847,6 +8849,8 @@ spec:
type: object
metricsStorage:
properties:
server-url:
type: string
type:
type: string
type: object
Expand Down
8 changes: 8 additions & 0 deletions pkg/deployment/all_in_one.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,14 @@ func (a *AllInOne) Get() *appsv1.Deployment {
Value: strconv.FormatBool(jaegerDisabled),
},
}

if a.jaeger.Spec.AllInOne.MetricsStorage.Type == "prometheus" {
antoniomerlin marked this conversation as resolved.
Show resolved Hide resolved
envVars = append(envVars, corev1.EnvVar{
Name: "PROMETHEUS_SERVER_URL",
Value: a.jaeger.Spec.AllInOne.MetricsStorage.ServerUrl,
})
}

envVars = append(envVars, proxy.ReadProxyVarsFromEnv()...)

ports := []corev1.ContainerPort{
Expand Down
12 changes: 12 additions & 0 deletions pkg/deployment/all_in_one_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,18 @@ func TestAllInOnePriorityClassName(t *testing.T) {
assert.Equal(t, priorityClassName, dep.Spec.Template.Spec.PriorityClassName)
}

func TestAllInOnePrometheusMetricStorage(t *testing.T) {
jaeger := v1.NewJaeger(types.NamespacedName{Name: "TestAllInOnePrometheusMetricStorage"})

jaeger.Spec.AllInOne.MetricsStorage.Type = "prometheus"
jaeger.Spec.AllInOne.MetricsStorage.ServerUrl = "http://prometheus:9090"

d := NewAllInOne(jaeger).Get()

assert.Equal(t, "prometheus", getEnvVarByName(d.Spec.Template.Spec.Containers[0].Env, "METRICS_STORAGE_TYPE").Value)
assert.NotEmpty(t, getEnvVarByName(d.Spec.Template.Spec.Containers[0].Env, "PROMETHEUS_SERVER_URL").Value)
}

func getEnvVarByName(vars []corev1.EnvVar, name string) corev1.EnvVar {
envVar := corev1.EnvVar{}
for _, v := range vars {
Expand Down
8 changes: 8 additions & 0 deletions pkg/deployment/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,14 @@ func (q *Query) Get() *appsv1.Deployment {
Value: strconv.FormatBool(jaegerDisabled),
},
}

if q.jaeger.Spec.Query.MetricsStorage.Type == "prometheus" {
envVars = append(envVars, corev1.EnvVar{
Name: "PROMETHEUS_SERVER_URL",
Value: q.jaeger.Spec.Query.MetricsStorage.ServerUrl,
})
}

envVars = append(envVars, proxy.ReadProxyVarsFromEnv()...)
deployment := &appsv1.Deployment{
TypeMeta: metav1.TypeMeta{
Expand Down
13 changes: 13 additions & 0 deletions pkg/deployment/query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -510,3 +510,16 @@ func TestQueryNodeSelector(t *testing.T) {

assert.Equal(t, nodeSelector, dep.Spec.Template.Spec.NodeSelector)
}

func TestQueryPrometheusMetricStorage(t *testing.T) {

jaeger := v1.NewJaeger(types.NamespacedName{Name: "TestQueryPrometheusMetricStorage"})

jaeger.Spec.Query.MetricsStorage.Type = "prometheus"
jaeger.Spec.Query.MetricsStorage.ServerUrl = "http://prometheus:9090"

d := NewQuery(jaeger).Get()

assert.Equal(t, "prometheus", getEnvVarByName(d.Spec.Template.Spec.Containers[0].Env, "METRICS_STORAGE_TYPE").Value)
assert.NotEmpty(t, getEnvVarByName(d.Spec.Template.Spec.Containers[0].Env, "PROMETHEUS_SERVER_URL").Value)
}
Loading