Skip to content

Commit

Permalink
add le to bucket metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
hgiasac committed Sep 28, 2024
1 parent ef0939e commit 80aa596
Show file tree
Hide file tree
Showing 14 changed files with 7,117 additions and 48 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ ci-build-configuration: clean
-output="$(OUTPUT_DIR)/ndc-prometheus-{{.OS}}-{{.Arch}}" \
./configuration

.PHONY: ci-build
.PHONY: build-supergraph-test
build-supergraph-test:
cd tests/engine && \
ddn connector-link update prometheus --add-all-resources --subgraph ./app/subgraph.yaml && \
Expand Down
14 changes: 9 additions & 5 deletions connector/metadata/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,20 +71,24 @@ func (scb *connectorSchemaBuilder) buildMetrics() error {
case model.MetricTypeHistogram, model.MetricTypeGaugeHistogram:
for _, suffix := range []string{"sum", "count", "bucket"} {
metricName := fmt.Sprintf("%s_%s", name, suffix)
if err := scb.buildMetricsItem(metricName, info); err != nil {
labels := info.Labels
if suffix == "bucket" {
labels["le"] = LabelInfo{}
}
if err := scb.buildMetricsItem(metricName, info, labels); err != nil {
return err
}
}
default:
if err := scb.buildMetricsItem(name, info); err != nil {
if err := scb.buildMetricsItem(name, info, info.Labels); err != nil {
return err
}
}
}
return nil
}

func (scb *connectorSchemaBuilder) buildMetricsItem(name string, info MetricInfo) error {
func (scb *connectorSchemaBuilder) buildMetricsItem(name string, info MetricInfo, labels map[string]LabelInfo) error {
if err := scb.checkDuplicatedOperation(name); err != nil {
return err
}
Expand All @@ -93,8 +97,8 @@ func (scb *connectorSchemaBuilder) buildMetricsItem(name string, info MetricInfo
Fields: createQueryResultValuesObjectFields(),
}

labelEnums := make([]string, 0, len(info.Labels))
for key, label := range info.Labels {
labelEnums := make([]string, 0, len(labels))
for key, label := range labels {
labelEnums = append(labelEnums, key)
objectType.Fields[key] = schema.ObjectField{
Description: label.Description,
Expand Down
10 changes: 5 additions & 5 deletions tests/configuration/configuration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@ connection_settings:
env: PROMETHEUS_USERNAME
password:
env: PROMETHEUS_PASSWORD
runtime:
flat: true
format:
timestamp: rfc3339
value: float64
generator:
metrics:
enabled: true
Expand Down Expand Up @@ -213,3 +208,8 @@ metadata:
type: String
job:
type: String
runtime:
flat: true
format:
timestamp: rfc3339
value: float64
Loading

0 comments on commit 80aa596

Please sign in to comment.