From 077bdf4ce333f346245bd87211e0c67c219aa906 Mon Sep 17 00:00:00 2001 From: Grace Wehner Date: Thu, 6 Mar 2025 11:22:18 -0800 Subject: [PATCH 1/6] update ref app for more constant test values --- internal/referenceapp/golang/main.go | 104 ++++++++++++++++++++++++++- 1 file changed, 103 insertions(+), 1 deletion(-) diff --git a/internal/referenceapp/golang/main.go b/internal/referenceapp/golang/main.go index 35ecf61b..2bbc59d8 100644 --- a/internal/referenceapp/golang/main.go +++ b/internal/referenceapp/golang/main.go @@ -306,6 +306,53 @@ func recordPerfMetrics() { }() } +func recordTestMetrics() { + go func() { + i := 0 + + ctx := context.Background() + metricAttributes := attribute.NewSet( + attribute.String("label.1", "label.1-value"), + attribute.String("label.2", "label.2-value"), + ) + for { + otlpIntCounterTest.Add(ctx, 1, metric.WithAttributeSet(metricAttributes)) + otlpFloatCounterTest.Add(ctx, 1.8, metric.WithAttributeSet(metricAttributes)) + + // Add 2 on even loop, subtract 1 on odd loop + if i%2 == 0 { + otlpIntGaugeTest.Record(ctx, 2, metric.WithAttributeSet(metricAttributes)) + otlpFloatGaugeTest.Record(ctx, 2.8, metric.WithAttributeSet(metricAttributes)) + + otlpIntUpDownCounterTest.Add(ctx, 2, metric.WithAttributeSet(metricAttributes)) + otlpFloatUpDownCounterTest.Add(ctx, 2.8, metric.WithAttributeSet(metricAttributes)) + + otlpIntExponentialHistogramTest.Record(ctx, 1, metric.WithAttributeSet(metricAttributes)) + otlpFloatExponentialHistogramTest.Record(ctx, 0.8, metric.WithAttributeSet(metricAttributes)) + + otlpIntExplicitHistogramTest.Record(ctx, 1, metric.WithAttributeSet(metricAttributes)) + otlpFloatExplicitHistogramTest.Record(ctx, 0.8, metric.WithAttributeSet(metricAttributes)) + + } else { + otlpIntGaugeTest.Record(ctx, 1, metric.WithAttributeSet(metricAttributes)) + otlpFloatGaugeTest.Record(ctx, 1.8, metric.WithAttributeSet(metricAttributes)) + + otlpIntUpDownCounterTest.Add(ctx, -1, metric.WithAttributeSet(metricAttributes)) + otlpFloatUpDownCounterTest.Add(ctx, -1.8, metric.WithAttributeSet(metricAttributes)) + + otlpIntExponentialHistogramTest.Record(ctx, 2, metric.WithAttributeSet(metricAttributes)) + otlpFloatExponentialHistogramTest.Record(ctx, 1.8, metric.WithAttributeSet(metricAttributes)) + + otlpIntExplicitHistogramTest.Record(ctx, 2, metric.WithAttributeSet(metricAttributes)) + otlpFloatExplicitHistogramTest.Record(ctx, 1.8, metric.WithAttributeSet(metricAttributes)) + } + + i++ + time.Sleep(60 * time.Second) + } + }() +} + func createGauges() { for i := 0; i < metricCount; i++ { name := fmt.Sprintf("myapp_temperature_%d", i) @@ -331,6 +378,17 @@ var ( otlpExponentialRainfallHistogram metric.Float64Histogram otlpExplicitRainfallHistogram metric.Float64Histogram + otlpIntCounterTest metric.Int64Counter + otlpFloatCounterTest metric.Float64Counter + otlpIntGaugeTest metric.Int64Gauge + otlpFloatGaugeTest metric.Float64Gauge + otlpIntUpDownCounterTest metric.Int64UpDownCounter + otlpFloatUpDownCounterTest metric.Float64UpDownCounter + otlpIntExponentialHistogramTest metric.Int64Histogram + otlpFloatExponentialHistogramTest metric.Float64Histogram + otlpIntExplicitHistogramTest metric.Int64Histogram + otlpFloatExplicitHistogramTest metric.Float64Histogram + scrapeIntervalSec = 60 metricCount = 10000 gaugeList = make([]*prometheus.GaugeVec, 0, metricCount) @@ -516,7 +574,8 @@ func main() { createGauges() recordPerfMetrics() } else { - recordMetrics() + //recordMetrics() + recordTestMetrics() } untypedServer := http.NewServeMux() @@ -643,6 +702,49 @@ func setupOTLP() { // Actually register metrics with the meter provider. These will then be used to record values otlpMeter := provider.Meter("referenceapp") + otlpIntCounterTest, _ = otlpMeter.Int64Counter( + "otlpapp.intcounter.total", + metric.WithUnit("1"), + ) + otlpFloatCounterTest, _ = otlpMeter.Float64Counter( + "otlpapp.floatcounter.total", + metric.WithUnit("1"), + ) + otlpIntGaugeTest, _ = otlpMeter.Int64Gauge( + "otlpapp.intgauge", + metric.WithUnit("1"), + ) + otlpFloatGaugeTest, _ = otlpMeter.Float64Gauge( + "otlpapp.floatgauge", + metric.WithUnit("1"), + ) + otlpIntUpDownCounterTest, _ = otlpMeter.Int64UpDownCounter( + "otlpapp.intupdowncounter", + metric.WithUnit("1"), + ) + otlpFloatUpDownCounterTest, _ = otlpMeter.Float64UpDownCounter( + "otlpapp.floatupdowncounter", + metric.WithUnit("1"), + ) + otlpIntExponentialHistogramTest, _ = otlpMeter.Int64Histogram( + "otlpapp.intexponentialhistogram", + metric.WithUnit("1"), + ) + otlpFloatExponentialHistogramTest, _ = otlpMeter.Float64Histogram( + "otlpapp.floatexponentialhistogram", + metric.WithUnit("1"), + ) + otlpIntExplicitHistogramTest, _ = otlpMeter.Int64Histogram( + "otlpapp.intexplicithistogram", + metric.WithUnit("1"), + metric.WithExplicitBucketBoundaries(0, 1, 2, 3, 4, 5, 6, 7, 8, 9), + ) + otlpFloatExplicitHistogramTest, _ = otlpMeter.Float64Histogram( + "otlpapp.floatexplicithistogram", + metric.WithUnit("1"), + metric.WithExplicitBucketBoundaries(0, 0.25, 0.5, 0.75, 1.0, 1.25, 1.5, 1.75, 2.0, 2.25), + ) + otlpCounter, _ = otlpMeter.Int64Counter( "myotelapp.measurements.total", metric.WithUnit("1"), From 7e6126fa14482469c70c20718d0d8f63bfa55f34 Mon Sep 17 00:00:00 2001 From: Grace Wehner Date: Fri, 7 Mar 2025 12:42:33 -0800 Subject: [PATCH 2/6] final changes --- internal/referenceapp/golang/main.go | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/internal/referenceapp/golang/main.go b/internal/referenceapp/golang/main.go index 2bbc59d8..356bdcd4 100644 --- a/internal/referenceapp/golang/main.go +++ b/internal/referenceapp/golang/main.go @@ -314,37 +314,38 @@ func recordTestMetrics() { metricAttributes := attribute.NewSet( attribute.String("label.1", "label.1-value"), attribute.String("label.2", "label.2-value"), + attribute.String("temporality", temporalityLabel), ) for { otlpIntCounterTest.Add(ctx, 1, metric.WithAttributeSet(metricAttributes)) - otlpFloatCounterTest.Add(ctx, 1.8, metric.WithAttributeSet(metricAttributes)) + otlpFloatCounterTest.Add(ctx, 1.5, metric.WithAttributeSet(metricAttributes)) // Add 2 on even loop, subtract 1 on odd loop if i%2 == 0 { otlpIntGaugeTest.Record(ctx, 2, metric.WithAttributeSet(metricAttributes)) - otlpFloatGaugeTest.Record(ctx, 2.8, metric.WithAttributeSet(metricAttributes)) + otlpFloatGaugeTest.Record(ctx, 2.5, metric.WithAttributeSet(metricAttributes)) otlpIntUpDownCounterTest.Add(ctx, 2, metric.WithAttributeSet(metricAttributes)) - otlpFloatUpDownCounterTest.Add(ctx, 2.8, metric.WithAttributeSet(metricAttributes)) + otlpFloatUpDownCounterTest.Add(ctx, 2.5, metric.WithAttributeSet(metricAttributes)) otlpIntExponentialHistogramTest.Record(ctx, 1, metric.WithAttributeSet(metricAttributes)) - otlpFloatExponentialHistogramTest.Record(ctx, 0.8, metric.WithAttributeSet(metricAttributes)) + otlpFloatExponentialHistogramTest.Record(ctx, 0.5, metric.WithAttributeSet(metricAttributes)) otlpIntExplicitHistogramTest.Record(ctx, 1, metric.WithAttributeSet(metricAttributes)) - otlpFloatExplicitHistogramTest.Record(ctx, 0.8, metric.WithAttributeSet(metricAttributes)) + otlpFloatExplicitHistogramTest.Record(ctx, 0.5, metric.WithAttributeSet(metricAttributes)) } else { otlpIntGaugeTest.Record(ctx, 1, metric.WithAttributeSet(metricAttributes)) - otlpFloatGaugeTest.Record(ctx, 1.8, metric.WithAttributeSet(metricAttributes)) + otlpFloatGaugeTest.Record(ctx, 1.5, metric.WithAttributeSet(metricAttributes)) otlpIntUpDownCounterTest.Add(ctx, -1, metric.WithAttributeSet(metricAttributes)) - otlpFloatUpDownCounterTest.Add(ctx, -1.8, metric.WithAttributeSet(metricAttributes)) + otlpFloatUpDownCounterTest.Add(ctx, -1.5, metric.WithAttributeSet(metricAttributes)) otlpIntExponentialHistogramTest.Record(ctx, 2, metric.WithAttributeSet(metricAttributes)) - otlpFloatExponentialHistogramTest.Record(ctx, 1.8, metric.WithAttributeSet(metricAttributes)) + otlpFloatExponentialHistogramTest.Record(ctx, 1.5, metric.WithAttributeSet(metricAttributes)) otlpIntExplicitHistogramTest.Record(ctx, 2, metric.WithAttributeSet(metricAttributes)) - otlpFloatExplicitHistogramTest.Record(ctx, 1.8, metric.WithAttributeSet(metricAttributes)) + otlpFloatExplicitHistogramTest.Record(ctx, 1.5, metric.WithAttributeSet(metricAttributes)) } i++ @@ -389,6 +390,8 @@ var ( otlpIntExplicitHistogramTest metric.Int64Histogram otlpFloatExplicitHistogramTest metric.Float64Histogram + temporalityLabel string + scrapeIntervalSec = 60 metricCount = 10000 gaugeList = make([]*prometheus.GaugeVec, 0, metricCount) @@ -625,6 +628,10 @@ func setupOTLP() { // The default temporality should be cumulative unless specified as delta otherwise deltaTemporality := os.Getenv("OTEL_TEMPORALITY") == "delta" + temporalityLabel = "cumulative" + if deltaTemporality { + temporalityLabel = "delta" + } // Export as stdout logs instead for debugging if os.Getenv("OTEL_CONSOLE_METRICS") == "true" { From bbe02dcab62c92fa716ade9bf56fae5d3176b866 Mon Sep 17 00:00:00 2001 From: Grace Wehner Date: Fri, 7 Mar 2025 12:44:36 -0800 Subject: [PATCH 3/6] add pr trigger for feature branch --- .pipelines/azure-pipeline-build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.pipelines/azure-pipeline-build.yml b/.pipelines/azure-pipeline-build.yml index 6a059e0a..50ce1ef7 100644 --- a/.pipelines/azure-pipeline-build.yml +++ b/.pipelines/azure-pipeline-build.yml @@ -9,6 +9,7 @@ pr: branches: include: - main + - feature/otlpmain variables: HELM_CHART_NAME: 'prometheus-collector' From 65268d3c6864a0bfcb7a492aa761639c894b1fef Mon Sep 17 00:00:00 2001 From: Grace Wehner Date: Fri, 7 Mar 2025 13:05:53 -0800 Subject: [PATCH 4/6] readme for data quality --- internal/referenceapp/golang/README.md | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/internal/referenceapp/golang/README.md b/internal/referenceapp/golang/README.md index 3ae1aed2..e3179615 100644 --- a/internal/referenceapp/golang/README.md +++ b/internal/referenceapp/golang/README.md @@ -19,4 +19,22 @@ This app generates both Prometheus and OTLP metrics. | `OTEL_TEMPORALITY` | string | `cumulative` or `delta` | `cumulative` | | `OTEL_CONSOLE_METRICS` | bool | Print metrics to stdout instead of exporting | `false` | | `OTEL_EXPORT_ENDPOINT` | string | GRPC endpoint to export metrics to | `localhost:4317` | -| `OTEL_INTERVAL` | int | How often to export metrics in seconds | `15` | \ No newline at end of file +| `OTEL_INTERVAL` | int | How often to export metrics in seconds | `15` | + +### OTLP Data Quality Testing +The logic for each metric recorded is [here](main.go?plain=1#L309) with function `recordTestMetrics()`. + +Each metric is emitted with cumulative and delta settings. Each metric will have a one time series with label `temporality`=`cumulative` and one with label `temporality`=`delta`. + +| Metric Name | Type | Int/Float | Labels | Values Emitted | +|---------------------------|----------|-----------|-----------------|----------------| +| `otlpapp.intcounter.total`| counter | int | `label.1`=`label.1-value`, `label.2`=`label.2-value`, `temporality`=`` | Increment by 1 every 60s | +| `otlpapp.floatcounter.total`| counter| float | `label.1`=`label.1-value`, `label.2`=`label.2-value`, `temporality`=``| Increment by 1.5 every 60s | +| `otlpapp.intgauge` | gauge | int | `label.1`=`label.1-value`, `label.2`=`label.2-value`, `temporality`=`` | Alternate between recording 1 and 2 every 60s | +| `otlpapp.floatgauge` | gauge | float | `label.1`=`label.1-value`, `label.2`=`label.2-value`, `temporality`=`` | Alternate between recording 1.5 and 2.5 every 60s | +| `otlpapp.intupdowncounter`| updown counter | int | `label.1`=`label.1-value`, `label.2`=`label.2-value`, `temporality`=``| Alternate between incrementing by 2 every 60s and decrementing by 1 every 60s | +| `otlpapp.floatupdowncounter`| updown counter | float | `label.1`=`label.1-value`, `label.2`=`label.2-value`, `temporality`=``| Alternate between incrementing by 2.5 every 60s and decrementing by 1.5 every 60s | +| `otlpapp.intexponentialhistogram` | exponential histogram | int | `label.1`=`label.1-value`, `label.2`=`label.2-value`, `temporality`=`` | Alternate between recording 1 and 2 every 60s | +| `otlpapp.floatexponentialhistogram` | exponential histogram | float | `label.1`=`label.1-value`, `label.2`=`label.2-value`, `temporality`=`` | Alternate between recording 0.5 and 1.5 every 60s | +| `otlpapp.intexplicithistogram` | explicit histogram | int | `label.1`=`label.1-value`, `label.2`=`label.2-value`, `temporality`=`` | Alternate between recording 1 and 2 every 60s | +| `otlpapp.floatexplicithistogram` | explicit histogram | float | `label.1`=`label.1-value`, `label.2`=`label.2-value`, `temporality`=`` | Alternate between recording 0.5 and 1.5 every 60s | \ No newline at end of file From 8127ddc8b0949ebbd201e200ccfd85b2acf62ead Mon Sep 17 00:00:00 2001 From: Grace Wehner Date: Fri, 7 Mar 2025 13:08:08 -0800 Subject: [PATCH 5/6] add branch to build --- .pipelines/azure-pipeline-build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.pipelines/azure-pipeline-build.yml b/.pipelines/azure-pipeline-build.yml index 50ce1ef7..c3e207b1 100644 --- a/.pipelines/azure-pipeline-build.yml +++ b/.pipelines/azure-pipeline-build.yml @@ -3,6 +3,7 @@ trigger: include: - main - feature/otlpmain + - grace/ref-app-update-march pr: autoCancel: true From 1821c5b046e559058664079a949a8fbc9c123ea8 Mon Sep 17 00:00:00 2001 From: Grace Wehner Date: Fri, 7 Mar 2025 14:29:35 -0800 Subject: [PATCH 6/6] remove toolchain for windows build --- internal/referenceapp/golang/go.mod | 2 -- 1 file changed, 2 deletions(-) diff --git a/internal/referenceapp/golang/go.mod b/internal/referenceapp/golang/go.mod index e338e28f..923c1a8f 100644 --- a/internal/referenceapp/golang/go.mod +++ b/internal/referenceapp/golang/go.mod @@ -2,8 +2,6 @@ module github.com/vishiy/opentelemetry-collector-builder go 1.22.7 -toolchain go1.23.2 - require ( github.com/prometheus/client_golang v1.11.1 go.opentelemetry.io/otel v1.33.0