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

[exporter/loadbalancing] allow metrics routing #26378

Merged
merged 20 commits into from
Sep 21, 2023

Conversation

claudiobastos
Copy link
Contributor

Closes #25858

Description: Add metrics exporter that will balance its metrics considering new routing choices

Link to tracking Issue: #25858

Testing: Add tests for new routing choices and metrics exporter

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Sep 2, 2023

CLA Signed

The committers listed above are authorized under a signed CLA.

@claudiobastos
Copy link
Contributor Author

In this second iteration I've tought about it and decide that for metrics, if routing key is empty or set to traceId, metrics exporter will consider service's.

@claudiobastos claudiobastos marked this pull request as ready for review September 7, 2023 14:18
@claudiobastos claudiobastos requested a review from a team September 7, 2023 14:18
@claudiobastos claudiobastos marked this pull request as draft September 7, 2023 16:29
@jpkrohling
Copy link
Member

In this second iteration I've tought about it and decide that for metrics, if routing key is empty or set to traceId, metrics exporter will consider service's.

If it's set to traceID, it should return an error: the user has explicitly stated something that cannot be honored. We also have a

@claudiobastos claudiobastos marked this pull request as ready for review September 11, 2023 01:47
@claudiobastos claudiobastos marked this pull request as draft September 11, 2023 12:54
@claudiobastos claudiobastos marked this pull request as ready for review September 12, 2023 01:12
Copy link
Member

@jpkrohling jpkrohling left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry that it took so long, but this LGTM. I did some basic manual testing as well, as follows:

Config used:

receivers:
  otlp/loadbalancer:
    protocols:
      grpc:
      http:

  otlp/backend-1:
    protocols:
      grpc:
        endpoint: localhost:5317
  otlp/backend-2:
    protocols:
      grpc:
        endpoint: localhost:6317
  otlp/backend-3:
    protocols:
      grpc:
        endpoint: localhost:7317

processors:

exporters:
  logging/loadbalancer:
  logging/backend-1:
  logging/backend-2:
  logging/backend-3:

  loadbalancing:
    routing_key: "service"
    protocol:
      otlp:
        tls:
          insecure: true
    resolver:
      static:
        hostnames:
        - localhost:5317
        - localhost:6317
        - localhost:7317

service:
  pipelines:
    metrics/loadbalancer:
      receivers:
        - otlp/loadbalancer
      processors: []
      exporters:
        - logging/loadbalancer
        - loadbalancing

    metrics/backend-1:
      receivers:
        - otlp/backend-1
      processors: []
      exporters:
        - logging/backend-1
    metrics/backend-2:
      receivers:
        - otlp/backend-2
      processors: []
      exporters:
        - logging/backend-2
    metrics/backend-3:
      receivers:
        - otlp/backend-3
      processors: []
      exporters:
        - logging/backend-3

Commands used to test:

> telemetrygen metrics --otlp-insecure --otlp-attributes='service.name="foo"' --metrics 100
> telemetrygen metrics --otlp-insecure --otlp-attributes='service.name="bar"' --metrics 100
> telemetrygen metrics --otlp-insecure --otlp-attributes='service.name="acme"' --metrics 100

Relevant metrics:

otelcol_exporter_sent_metric_points{exporter="logging/backend-1",service_instance_id="bbd1a465-b152-40ff-9a0f-281bad72c957",service_name="otelcontribcol",service_version="0.84.0-dev"} 100
otelcol_exporter_sent_metric_points{exporter="logging/backend-2",service_instance_id="bbd1a465-b152-40ff-9a0f-281bad72c957",service_name="otelcontribcol",service_version="0.84.0-dev"} 100
otelcol_exporter_sent_metric_points{exporter="logging/backend-3",service_instance_id="bbd1a465-b152-40ff-9a0f-281bad72c957",service_name="otelcontribcol",service_version="0.84.0-dev"} 100
otelcol_exporter_sent_metric_points{exporter="logging/loadbalancer",service_instance_id="bbd1a465-b152-40ff-9a0f-281bad72c957",service_name="otelcontribcol",service_version="0.84.0-dev"} 300

exporter/loadbalancingexporter/README.md Outdated Show resolved Hide resolved
exporter/loadbalancingexporter/README.md Outdated Show resolved Hide resolved
exporter/loadbalancingexporter/README.md Outdated Show resolved Hide resolved
exporter/loadbalancingexporter/metrics_exporter.go Outdated Show resolved Hide resolved
exporter/loadbalancingexporter/metrics_exporter.go Outdated Show resolved Hide resolved
claudiobastos and others added 4 commits September 14, 2023 13:47
Co-authored-by: Juraci Paixão Kröhling <[email protected]>
Co-authored-by: Juraci Paixão Kröhling <[email protected]>
@jpkrohling jpkrohling merged commit d9a5201 into open-telemetry:main Sep 21, 2023
90 checks passed
@github-actions github-actions bot added this to the next release milestone Sep 21, 2023
jmsnll pushed a commit to jmsnll/opentelemetry-collector-contrib that referenced this pull request Nov 12, 2023
Closes open-telemetry#25858

**Description:** Add metrics exporter that will balance its metrics
considering new routing choices

**Link to tracking Issue:** open-telemetry#25858

**Testing:** Add tests for new routing choices and metrics exporter

---------

Signed-off-by: Claudio B <[email protected]>
Co-authored-by: Juraci Paixão Kröhling <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Load balance metrics for cumulative to delta
5 participants