Skip to content

Commit

Permalink
Remove support for OTEL spanmetrics processor (#5539)
Browse files Browse the repository at this point in the history
  • Loading branch information
varshith257 authored Jun 11, 2024
1 parent 6f2fe36 commit ada5569
Show file tree
Hide file tree
Showing 11 changed files with 66 additions and 193 deletions.
11 changes: 0 additions & 11 deletions docker-compose/monitor/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,6 @@ dev: export JAEGER_IMAGE_TAG = dev
dev:
docker compose -f docker-compose.yml up

# starts older spanmetrics processor setup, for example,
# to test backwards compatibility of Jaeger with spanmetrics processor.
.PHONY: dev-processor
dev-processor: export JAEGER_IMAGE_TAG = dev
# Fix to a version before the breaking changes were introduced.
dev-processor: export OTEL_IMAGE_TAG = 0.70.0
dev-processor: export OTEL_CONFIG_SRC = ./otel-collector-config-processor.yml
dev-processor: export PROMETHEUS_QUERY_SUPPORT_SPANMETRICS_CONNECTOR = false
dev-processor:
docker compose -f docker-compose.yml up

.PHONY: clean-jaeger
clean-jaeger:
# Also cleans up intermediate cached containers.
Expand Down
60 changes: 8 additions & 52 deletions docker-compose/monitor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ This environment consists the following backend components:

- [MicroSim](https://github.com/yurishkuro/microsim): a program to simulate traces.
- [Jaeger All-in-one](https://www.jaegertracing.io/docs/1.24/getting-started/#all-in-one): the full Jaeger stack in a single container image.
- [OpenTelemetry Collector](https://opentelemetry.io/docs/collector/): vendor agnostic integration layer for traces and metrics. Its main role in this particular development environment is to receive Jaeger spans, forward these spans untouched to Jaeger All-in-one while simultaneously aggregating metrics out of this span data. To learn more about span metrics aggregation, please refer to the [spanmetrics processor documentation][spanmetricsprocessor].
- [OpenTelemetry Collector](https://opentelemetry.io/docs/collector/): vendor agnostic integration layer for traces and metrics. Its main role in this particular development environment is to receive Jaeger spans, forward these spans untouched to Jaeger All-in-one while simultaneously aggregating metrics out of this span data. To learn more about span metrics aggregation, please refer to the [spanmetrics connector documentation][spanmetricsconnectorreadme].
- [Prometheus](https://prometheus.io/): a metrics collection and query engine, used to scrape metrics computed by OpenTelemetry Collector, and presents an API for Jaeger All-in-one to query these metrics.
- [Grafana](https://grafana.com/): a metrics visualization, analytics & monitoring solution supporting multiple metrics databases.

Expand Down Expand Up @@ -65,16 +65,6 @@ make build
make dev
```

## Backwards compatibility testing with spanmetrics processor

```bash
make dev-processor
```

For each "run" make target, you should expect to see the following in the Monitor tab after a few minutes:

![Monitor Screenshot](images/startup-monitor-tab.png)

## Sending traces

We will use [tracegen](https://github.com/jaegertracing/jaeger/tree/main/cmd/tracegen)
Expand Down Expand Up @@ -114,45 +104,6 @@ Then navigate to the Monitor tab at http://localhost:16686/monitor to view the R

![TraceGen RED Metrics](images/tracegen_metrics.png)

## Migrating to Span Metrics Connector

### Background

A new [Connector](https://pkg.go.dev/go.opentelemetry.io/collector/connector#section-readme) API was introduced
to the OpenTelemetry Collector to provide a means of receiving and exporting between any type of telemetry.

The existing [Span Metrics Processor][spanmetricsprocessor] was a good candidate to migrate over to the connector type,
resulting in the new [Span Metrics Connector][spanmetricsconnector] component.

The Span Metrics Connector variant introduces some [breaking changes][processor-to-connector], and the following
section aims to provide the instructions necessary to use the metrics produced by this component.

### Migrating

Assuming the OpenTelemetry Collector is running with the [Span Metrics Connector][spanmetricsconnector] correctly
configured, the minimum configuration required for jaeger-query or jaeger-all-in-one are as follows:

as command line parameters:
```shell
--prometheus.query.support-spanmetrics-connector=true
```

as environment variables:
```shell
PROMETHEUS_QUERY_SUPPORT_SPANMETRICS_CONNECTOR=true
```

If the Span Metrics Connector is configured with a namespace and/or an alternative duration unit,
the following configuration options are available, as both command line and environment variables:

```shell
--prometheus.query.namespace=span_metrics
--prometheus.query.duration-unit=s

PROMETHEUS_QUERY_NAMESPACE=span_metrics
PROMETHEUS_QUERY_DURATION_UNIT=s
```

## Querying the HTTP API

### Example 1
Expand Down Expand Up @@ -278,7 +229,13 @@ For example:
},
"timestamp": "2021-06-03T09:12:11Z"
},
]
...
}
...
]
...
}
```

If the `groupByOperation=true` parameter is set, the response will include the operation name in the labels like so:
Expand Down Expand Up @@ -318,6 +275,5 @@ $ curl http://localhost:16686/api/metrics/minstep | jq .
}
```

[spanmetricsprocessor]: https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/processor/spanmetricsprocessor
[spanmetricsconnector]: https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/connector/spanmetricsconnector
[processor-to-connector]: https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/connector/spanmetricsconnector#span-to-metrics-processor-to-span-to-metrics-connector
[spanmetricsconnectorreadme]: https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/connector/spanmetricsconnector/README.md
42 changes: 0 additions & 42 deletions docker-compose/monitor/otel-collector-config-processor.yml

This file was deleted.

9 changes: 4 additions & 5 deletions pkg/prometheus/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,8 @@ type Configuration struct {
TokenFilePath string
TokenOverrideFromContext bool

SupportSpanmetricsConnector bool
MetricNamespace string
LatencyUnit string
NormalizeCalls bool
NormalizeDuration bool
MetricNamespace string
LatencyUnit string
NormalizeCalls bool
NormalizeDuration bool
}
13 changes: 0 additions & 13 deletions plugin/metrics/prometheus/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,22 +53,11 @@ func TestWithDefaultConfiguration(t *testing.T) {
assert.Equal(t, "http://localhost:9090", f.options.Primary.ServerURL)
assert.Equal(t, 30*time.Second, f.options.Primary.ConnectTimeout)

assert.True(t, f.options.Primary.SupportSpanmetricsConnector)
assert.Empty(t, f.options.Primary.MetricNamespace)
assert.Equal(t, "ms", f.options.Primary.LatencyUnit)
}

func TestWithConfiguration(t *testing.T) {
t.Run("still supports the deprecated spanmetrics processor", func(t *testing.T) {
f := NewFactory()
v, command := config.Viperize(f.AddFlags)
err := command.ParseFlags([]string{
"--prometheus.query.support-spanmetrics-connector=false",
})
require.NoError(t, err)
f.InitFromViper(v, zap.NewNop())
assert.False(t, f.options.Primary.SupportSpanmetricsConnector)
})
t.Run("with custom configuration and no space in token file path", func(t *testing.T) {
f := NewFactory()
v, command := config.Viperize(f.AddFlags)
Expand Down Expand Up @@ -99,13 +88,11 @@ func TestWithConfiguration(t *testing.T) {
f := NewFactory()
v, command := config.Viperize(f.AddFlags)
err := command.ParseFlags([]string{
"--prometheus.query.support-spanmetrics-connector=true",
"--prometheus.query.namespace=mynamespace",
"--prometheus.query.duration-unit=ms",
})
require.NoError(t, err)
f.InitFromViper(v, zap.NewNop())
assert.True(t, f.options.Primary.SupportSpanmetricsConnector)
assert.Equal(t, "mynamespace", f.options.Primary.MetricNamespace)
assert.Equal(t, "ms", f.options.Primary.LatencyUnit)
})
Expand Down
4 changes: 2 additions & 2 deletions plugin/metrics/prometheus/metricsstore/dbmodel/to_domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ type Translator struct {
// New returns a new Translator.
func New(spanNameLabel string) Translator {
return Translator{
// "operator" is the label name that Jaeger UI expects.
labelMap: map[string]string{spanNameLabel: "operation"},
// "span_name" is the label name that Jaeger UI expects.
labelMap: map[string]string{spanNameLabel: "span_name"},
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func TestToDomainMetricsFamily(t *testing.T) {

wantMetricLabels := map[string]string{
"label_key": "label_value",
"operation": "span_name_value", // assert the name is translated to a Jaeger-friendly label.
"span_name": "span_name_value", // assert the name is translated to a Jaeger-friendly label.
}
assert.Len(t, mf.Metrics, 1)
for _, ml := range mf.Metrics[0].Labels {
Expand Down
15 changes: 2 additions & 13 deletions plugin/metrics/prometheus/metricsstore/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,7 @@ func NewMetricsReader(cfg config.Configuration, logger *zap.Logger, tracer trace
return nil, fmt.Errorf("failed to initialize prometheus client: %w", err)
}

operationLabel := "operation"
if cfg.SupportSpanmetricsConnector {
operationLabel = "span_name"
}
operationLabel := "span_name"

mr := &MetricsReader{
client: promapi.NewAPI(client),
Expand Down Expand Up @@ -134,11 +131,7 @@ func (m MetricsReader) GetLatencies(ctx context.Context, requestParams *metricss
}

func buildFullLatencyMetricName(cfg config.Configuration) string {
metricName := "latency"
if !cfg.SupportSpanmetricsConnector {
return metricName
}
metricName = "duration"
metricName := "duration"

if cfg.MetricNamespace != "" {
metricName = cfg.MetricNamespace + "_" + metricName
Expand Down Expand Up @@ -181,10 +174,6 @@ func (m MetricsReader) GetCallRates(ctx context.Context, requestParams *metricss

func buildFullCallsMetricName(cfg config.Configuration) string {
metricName := "calls"
if !cfg.SupportSpanmetricsConnector {
return metricName
}

if cfg.MetricNamespace != "" {
metricName = cfg.MetricNamespace + "_" + metricName
}
Expand Down
Loading

0 comments on commit ada5569

Please sign in to comment.