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

[receiver/statsd] Add self-telemetry #31839

Closed

Conversation

sirianni
Copy link
Contributor

Description:
Add telemetry to statsdreceiver

  • otelcol_receiver_accepted_metric_points
  • otelcol_receiver_refused_metric_points
  • otelcol_receiver_statsd_flushed_metric_points
  • otelcol_receiver_statsd_flushes

Implementation note

I debated trying to use the existing receiverhelper.ObsReport for this but rejected that approach for a few reasons

  1. It's less code to just create the instruments directly and use them here.
  2. I don't think we really want Spans getting created for every single statsd line that's sent through the system.
  3. This wouldn't support the statsd-specific metric for flushes

Link to tracking Issue: #24278

Testing:
Tested locally using prometheus

$ nc -u -q0 localhost 8125 <<EOF
a:1|c
a:2|c
a:3|c
b:4|c
b:5|c
EOF
$ http :8888/metrics | grep -e '^otelcol.*statsd' -e '^otelcol.*sent.*debug'
otelcol_receiver_accepted_metric_points{receiver="statsd",service_instance_id="d9fcd320-9662-47ad-b6b4-e901e3b40592",service_name="collector",service_version="development"} 5
otelcol_receiver_statsd_flushed_metric_points{receiver="statsd",service_instance_id="d9fcd320-9662-47ad-b6b4-e901e3b40592",service_name="collector",service_version="development",status="success"} 2
otelcol_receiver_statsd_flushes{receiver="statsd",service_instance_id="d9fcd320-9662-47ad-b6b4-e901e3b40592",service_name="collector",service_version="development",status="success"} 1

otelcol_exporter_sent_metric_points{exporter="debug",service_instance_id="d9fcd320-9662-47ad-b6b4-e901e3b40592",service_name="collector",service_version="development"} 2

}
}

func (r *reporter) RecordFlushedMetrics(count int64, err error) {
Copy link
Contributor

@hardproblems hardproblems Mar 19, 2024

Choose a reason for hiding this comment

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

again compared to the prometheusreceiver, i think the flushed metrics should be the receiver accepted/refused metrics. The parser should be the place where the instrumentation for received and parse error counts are added

Copy link
Contributor Author

@sirianni sirianni Mar 20, 2024

Choose a reason for hiding this comment

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

Hmm. I'm not sure about this one. In our monitoring, we are comparing the received datapoint count to the sent metrics count from statsd clients. See https://github.com/DataDog/datadog-go/blob/9d920252c04efe4e5f4d3a283002b72253a7da47/statsd/telemetry.go#L271

Is prometheus a valid comparison? In prometheus there is no aggregation in the receiver itself so there's only one measure for a "received metric", right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm OK with flipping the logic if that's the consensus. The naming becomes a bit harder though 🙂

Copy link
Contributor

github-actions bot commented Apr 3, 2024

This PR was marked stale due to lack of activity. It will be closed in 14 days.

@github-actions github-actions bot added the Stale label Apr 3, 2024
@codeboten codeboten removed the Stale label Apr 3, 2024
@codeboten
Copy link
Contributor

Pinging code owners @jmacd @dmitryax please take a look

Copy link
Contributor

This PR was marked stale due to lack of activity. It will be closed in 14 days.

@github-actions github-actions bot added the Stale label Apr 26, 2024
@hardproblems
Copy link
Contributor

@TylerHelmuth would you please review this? I stopped work on #31822 in favor of this.

// for the metric naming conventions

r.acceptedMetricPoints, err = metadata.Meter(set.TelemetrySettings).Int64Counter(
"receiver/accepted_metric_points",
Copy link
Member

Choose a reason for hiding this comment

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

Does this receiver not use receiverhelper? If it is it should be producing this metric already.

Copy link
Member

Choose a reason for hiding this comment

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

I'm with @TylerHelmuth here. I've read the PR description but still don't understand why we cannot use receiverhelper.NewObsReport as other receivers. Excessive tracing is a concern for any receiver, so collector's tracing is expected to be sampled.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Does this receiver not use receiverhelper? If it is it should be producing this metric already.

It does not use receiverhelper. It previously used the obsreport package, but that was dead code as mentioned in the issue #24278 (comment)

Copy link
Contributor Author

@sirianni sirianni May 6, 2024

Choose a reason for hiding this comment

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

don't understand why we cannot use receiverhelper.NewObsReport as other receivers.

It's messy to use obsreport because the asynchronous nature of this receiver (the flush happening in the background) does not align with the StartMetricsOp() / EndMetricsOp() pattern of obsreport. This is likely why the obsreport integration was abandoned in #1670 when aggregation / async flush was implemented in this receiver.

Excessive tracing is a concern for any receiver, so collector's tracing is expected to be sampled.

I'm more concerned with the performance overhead of the tracing instrumentation code than I am the volume of traces. Since submitting this PR we actually had to rewrite this instrumentation because even the overhead of incrementing the metric counter synchronously was causing statsd packet loss.

You can see in the attached flame graph that simply calling metric.(*int64Inst).Add() is significant overhead (12% of overall CPU).

image

image

@TylerHelmuth
Copy link
Member

Code owners @jmacd @dmitryax please review

@github-actions github-actions bot removed the Stale label May 4, 2024
Copy link
Contributor

This PR was marked stale due to lack of activity. It will be closed in 14 days.

@github-actions github-actions bot added the Stale label May 21, 2024
Copy link
Contributor

github-actions bot commented Jun 4, 2024

Closed as inactive. Feel free to reopen if this PR is still being worked on.

@github-actions github-actions bot closed this Jun 4, 2024
dmitryax pushed a commit that referenced this pull request Jun 11, 2024
Description:
Add received statsd / accepted/refused metrics to statsdreceiver

Resurrecting
#31822
since #31839 is closed.

Link to tracking Issue:

#24278

Testing:
This works in our internal testing environments. Took a profile and
didn't see metric recording taking much cpu
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.

5 participants