Skip to content
This repository has been archived by the owner on Sep 2, 2024. It is now read-only.

Support eventing metrics #688

Merged

Conversation

skonto
Copy link
Contributor

@skonto skonto commented Jun 7, 2021

Fixes #683

Sample output:

# HELP kafkachannel_dispatcher_event_count Number of events dispatched by the channel
# TYPE kafkachannel_dispatcher_event_count counter
kafkachannel_dispatcher_event_count{container_name="dispatcher",event_type="dev.knative.apiserver.resource.add",namespace_name="default",response_code="200",response_code_class="2xx",unique_name="kafka-ch-dispatcher-68895d8745-bd888bfba0cbe24fb46b24bb140e613a"} 2
kafkachannel_dispatcher_event_count{container_name="dispatcher",event_type="dev.knative.apiserver.resource.update",namespace_name="default",response_code="200",response_code_class="2xx",unique_name="kafka-ch-dispatcher-68895d8745-bd888bfba0cbe24fb46b24bb140e613a"} 3
# HELP kafkachannel_dispatcher_event_dispatch_latencies The time spent by the channel dispatching an event
# TYPE kafkachannel_dispatcher_event_dispatch_latencies histogram
kafkachannel_dispatcher_event_dispatch_latencies_bucket{container_name="dispatcher",event_type="dev.knative.apiserver.resource.add",namespace_name="default",response_code="200",response_code_class="2xx",unique_name="kafka-ch-dispatcher-68895d8745-bd888bfba0cbe24fb46b24bb140e613a",le="1"} 0
kafkachannel_dispatcher_event_dispatch_latencies_bucket{container_name="dispatcher",event_type="dev.knative.apiserver.resource.add",namespace_name="default",response_code="200",response_code_class="2xx",unique_name="kafka-ch-dispatcher-68895d8745-bd888bfba0cbe24fb46b24bb140e613a",le="2"} 0
kafkachannel_dispatcher_event_dispatch_latencies_bucket{container_name="dispatcher",event_type="dev.knative.apiserver.resource.add",namespace_name="default",response_code="200",response_code_class="2xx",unique_name="kafka-ch-dispatcher-68895d8745-bd888bfba0cbe24fb46b24bb140e613a",le="5"} 1
kafkachannel_dispatcher_event_dispatch_latencies_bucket{container_name="dispatcher",event_type="dev.knative.apiserver.resource.add",namespace_name="default",response_code="200",response_code_class="2xx",unique_name="kafka-ch-dispatcher-68895d8745-bd888bfba0cbe24fb46b24bb140e613a",le="10"} 2
kafkachannel_dispatcher_event_dispatch_latencies_bucket{container_name="dispatcher",event_type="dev.knative.apiserver.resource.add",namespace_name="default",response_code="200",response_code_class="2xx",unique_name="kafka-ch-dispatcher-68895d8745-bd888bfba0cbe24fb46b24bb140e613a",le="20"} 2
kafkachannel_dispatcher_event_dispatch_latencies_bucket{container_name="dispatcher",event_type="dev.knative.apiserver.resource.add",namespace_name="default",response_code="200",response_code_class="2xx",unique_name="kafka-ch-dispatcher-68895d8745-bd888bfba0cbe24fb46b24bb140e613a",le="50"} 2
kafkachannel_dispatcher_event_dispatch_latencies_bucket{container_name="dispatcher",event_type="dev.knative.apiserver.resource.add",namespace_name="default",response_code="200",response_code_class="2xx",unique_name="kafka-ch-dispatcher-68895d8745-bd888bfba0cbe24fb46b24bb140e613a",le="100"} 2
kafkachannel_dispatcher_event_dispatch_latencies_bucket{container_name="dispatcher",event_type="dev.knative.apiserver.resource.add",namespace_name="default",response_code="200",response_code_class="2xx",unique_name="kafka-ch-dispatcher-68895d8745-bd888bfba0cbe24fb46b24bb140e613a",le="200"} 2
kafkachannel_dispatcher_event_dispatch_latencies_bucket{container_name="dispatcher",event_type="dev.knative.apiserver.resource.add",namespace_name="default",response_code="200",response_code_class="2xx",unique_name="kafka-ch-dispatcher-68895d8745-bd888bfba0cbe24fb46b24bb140e613a",le="500"} 2
kafkachannel_dispatcher_event_dispatch_latencies_bucket{container_name="dispatcher",event_type="dev.knative.apiserver.resource.add",namespace_name="default",response_code="200",response_code_class="2xx",unique_name="kafka-ch-dispatcher-68895d8745-bd888bfba0cbe24fb46b24bb140e613a",le="1000"} 2
kafkachannel_dispatcher_event_dispatch_latencies_bucket{container_name="dispatcher",event_type="dev.knative.apiserver.resource.add",namespace_name="default",response_code="200",response_code_class="2xx",unique_name="kafka-ch-dispatcher-68895d8745-bd888bfba0cbe24fb46b24bb140e613a",le="2000"} 2
kafkachannel_dispatcher_event_dispatch_latencies_bucket{container_name="dispatcher",event_type="dev.knative.apiserver.resource.add",namespace_name="default",response_code="200",response_code_class="2xx",unique_name="kafka-ch-dispatcher-68895d8745-bd888bfba0cbe24fb46b24bb140e613a",le="5000"} 2
kafkachannel_dispatcher_event_dispatch_latencies_bucket{container_name="dispatcher",event_type="dev.knative.apiserver.resource.add",namespace_name="default",response_code="200",response_code_class="2xx",unique_name="kafka-ch-dispatcher-68895d8745-bd888bfba0cbe24fb46b24bb140e613a",le="10000"} 2
kafkachannel_dispatcher_event_dispatch_latencies_bucket{container_name="dispatcher",event_type="dev.knative.apiserver.resource.add",namespace_name="default",response_code="200",response_code_class="2xx",unique_name="kafka-ch-dispatcher-68895d8745-bd888bfba0cbe24fb46b24bb140e613a",le="+Inf"} 2
kafkachannel_dispatcher_event_dispatch_latencies_sum{container_name="dispatcher",event_type="dev.knative.apiserver.resource.add",namespace_name="default",response_code="200",response_code_class="2xx",unique_name="kafka-ch-dispatcher-68895d8745-bd888bfba0cbe24fb46b24bb140e613a"} 7
kafkachannel_dispatcher_event_dispatch_latencies_count{container_name="dispatcher",event_type="dev.knative.apiserver.resource.add",namespace_name="default",response_code="200",response_code_class="2xx",unique_name="kafka-ch-dispatcher-68895d8745-bd888bfba0cbe24fb46b24bb140e613a"} 2
kafkachannel_dispatcher_event_dispatch_latencies_bucket{container_name="dispatcher",event_type="dev.knative.apiserver.resource.update",namespace_name="default",response_code="200",response_code_class="2xx",unique_name="kafka-ch-dispatcher-68895d8745-bd888bfba0cbe24fb46b24bb140e613a",le="1"} 0
kafkachannel_dispatcher_event_dispatch_latencies_bucket{container_name="dispatcher",event_type="dev.knative.apiserver.resource.update",namespace_name="default",response_code="200",response_code_class="2xx",unique_name="kafka-ch-dispatcher-68895d8745-bd888bfba0cbe24fb46b24bb140e613a",le="2"} 0
kafkachannel_dispatcher_event_dispatch_latencies_bucket{container_name="dispatcher",event_type="dev.knative.apiserver.resource.update",namespace_name="default",response_code="200",response_code_class="2xx",unique_name="kafka-ch-dispatcher-68895d8745-bd888bfba0cbe24fb46b24bb140e613a",le="5"} 1
kafkachannel_dispatcher_event_dispatch_latencies_bucket{container_name="dispatcher",event_type="dev.knative.apiserver.resource.update",namespace_name="default",response_code="200",response_code_class="2xx",unique_name="kafka-ch-dispatcher-68895d8745-bd888bfba0cbe24fb46b24bb140e613a",le="10"} 1
kafkachannel_dispatcher_event_dispatch_latencies_bucket{container_name="dispatcher",event_type="dev.knative.apiserver.resource.update",namespace_name="default",response_code="200",response_code_class="2xx",unique_name="kafka-ch-dispatcher-68895d8745-bd888bfba0cbe24fb46b24bb140e613a",le="20"} 1
kafkachannel_dispatcher_event_dispatch_latencies_bucket{container_name="dispatcher",event_type="dev.knative.apiserver.resource.update",namespace_name="default",response_code="200",response_code_class="2xx",unique_name="kafka-ch-dispatcher-68895d8745-bd888bfba0cbe24fb46b24bb140e613a",le="50"} 1
kafkachannel_dispatcher_event_dispatch_latencies_bucket{container_name="dispatcher",event_type="dev.knative.apiserver.resource.update",namespace_name="default",response_code="200",response_code_class="2xx",unique_name="kafka-ch-dispatcher-68895d8745-bd888bfba0cbe24fb46b24bb140e613a",le="100"} 2
kafkachannel_dispatcher_event_dispatch_latencies_bucket{container_name="dispatcher",event_type="dev.knative.apiserver.resource.update",namespace_name="default",response_code="200",response_code_class="2xx",unique_name="kafka-ch-dispatcher-68895d8745-bd888bfba0cbe24fb46b24bb140e613a",le="200"} 3
kafkachannel_dispatcher_event_dispatch_latencies_bucket{container_name="dispatcher",event_type="dev.knative.apiserver.resource.update",namespace_name="default",response_code="200",response_code_class="2xx",unique_name="kafka-ch-dispatcher-68895d8745-bd888bfba0cbe24fb46b24bb140e613a",le="500"} 3
kafkachannel_dispatcher_event_dispatch_latencies_bucket{container_name="dispatcher",event_type="dev.knative.apiserver.resource.update",namespace_name="default",response_code="200",response_code_class="2xx",unique_name="kafka-ch-dispatcher-68895d8745-bd888bfba0cbe24fb46b24bb140e613a",le="1000"} 3
kafkachannel_dispatcher_event_dispatch_latencies_bucket{container_name="dispatcher",event_type="dev.knative.apiserver.resource.update",namespace_name="default",response_code="200",response_code_class="2xx",unique_name="kafka-ch-dispatcher-68895d8745-bd888bfba0cbe24fb46b24bb140e613a",le="2000"} 3
kafkachannel_dispatcher_event_dispatch_latencies_bucket{container_name="dispatcher",event_type="dev.knative.apiserver.resource.update",namespace_name="default",response_code="200",response_code_class="2xx",unique_name="kafka-ch-dispatcher-68895d8745-bd888bfba0cbe24fb46b24bb140e613a",le="5000"} 3
kafkachannel_dispatcher_event_dispatch_latencies_bucket{container_name="dispatcher",event_type="dev.knative.apiserver.resource.update",namespace_name="default",response_code="200",response_code_class="2xx",unique_name="kafka-ch-dispatcher-68895d8745-bd888bfba0cbe24fb46b24bb140e613a",le="10000"} 3
kafkachannel_dispatcher_event_dispatch_latencies_bucket{container_name="dispatcher",event_type="dev.knative.apiserver.resource.update",namespace_name="default",response_code="200",response_code_class="2xx",unique_name="kafka-ch-dispatcher-68895d8745-bd888bfba0cbe24fb46b24bb140e613a",le="+Inf"} 3
kafkachannel_dispatcher_event_dispatch_latencies_sum{container_name="dispatcher",event_type="dev.knative.apiserver.resource.update",namespace_name="default",response_code="200",response_code_class="2xx",unique_name="kafka-ch-dispatcher-68895d8745-bd888bfba0cbe24fb46b24bb140e613a"} 190
kafkachannel_dispatcher_event_dispatch_latencies_count{container_name="dispatcher",event_type="dev.knative.apiserver.resource.update",namespace_name="default",response_code="200",response_code_class="2xx",unique_name="kafka-ch-dispatcher-68895d8745-bd888bfba0cbe24fb46b24bb140e613a"} 3

Emit metrics when they are consumed successfully by the subscriber.

@google-cla google-cla bot added the cla: yes Indicates the PR's author has signed the CLA. label Jun 7, 2021
@knative-prow-robot
Copy link
Contributor

Hi @skonto. Thanks for your PR.

I'm waiting for a knative-sandbox member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@knative-prow-robot knative-prow-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jun 7, 2021
@skonto skonto changed the title Support eventing metrics [wip]Support eventing metrics Jun 7, 2021
@knative-prow-robot knative-prow-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jun 7, 2021
@skonto
Copy link
Contributor Author

skonto commented Jun 7, 2021

Need to update eventing to make metric description more generic as it is incorrect.

@codecov
Copy link

codecov bot commented Jun 7, 2021

Codecov Report

Merging #688 (385d8ae) into main (24bc388) will decrease coverage by 0.23%.
The diff coverage is 8.00%.

❗ Current head 385d8ae differs from pull request most recent head 2a85d15. Consider uploading reports for the commit 2a85d15 to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##             main     #688      +/-   ##
==========================================
- Coverage   75.17%   74.93%   -0.24%     
==========================================
  Files         132      132              
  Lines        5784     5801      +17     
==========================================
- Hits         4348     4347       -1     
- Misses       1215     1234      +19     
+ Partials      221      220       -1     
Impacted Files Coverage Δ
...onsolidated/dispatcher/consumer_message_handler.go 0.00% <0.00%> (ø)
pkg/channel/consolidated/dispatcher/dispatcher.go 61.58% <66.66%> (+0.10%) ⬆️
pkg/source/adapter/adapter.go 59.64% <0.00%> (+0.48%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2f12463...2a85d15. Read the comment docs.

Comment on lines 103 to 104
// Ideally this should be moved to Eventing
func parseDispatchResultAndReportMetrics(info *eventingchannels.DispatchExecutionInfo, reporter eventingchannels.StatsReporter, reportArgs eventingchannels.ReportArgs, dispatchErr error) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

why can't we do that?

Copy link
Contributor Author

@skonto skonto Jun 7, 2021

Choose a reason for hiding this comment

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

I am going to create a new PR pointing to this one showing that I need to copy the same code. This is to justify the change only, will go away. That is why this is in wip ;)

Copy link
Contributor Author

@skonto skonto Jun 7, 2021

Choose a reason for hiding this comment

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

Also will fix test coverage once code is eliminated and see what is left.

@matzew
Copy link
Contributor

matzew commented Jun 7, 2021 via email

@skonto
Copy link
Contributor Author

skonto commented Jun 8, 2021

When updates from Eventing land here I will update the PR.

@matzew
Copy link
Contributor

matzew commented Jun 8, 2021

When updates from Eventing land here I will update the PR.

@skonto they are in 😄

@skonto skonto changed the title [wip]Support eventing metrics Support eventing metrics Jun 9, 2021
@knative-prow-robot knative-prow-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jun 9, 2021
@skonto
Copy link
Contributor Author

skonto commented Jun 9, 2021

@matzew this is ready.

Copy link
Contributor

@matzew matzew left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve

thanks for doing the upstream changes to keep this small

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Jun 9, 2021
@knative-prow-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: matzew, skonto

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@knative-prow-robot knative-prow-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 9, 2021
@matzew
Copy link
Contributor

matzew commented Jun 9, 2021

/ok-to-test

@knative-prow-robot knative-prow-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jun 9, 2021
@knative-metrics-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-knative-sandbox-eventing-kafka-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/channel/consolidated/dispatcher/dispatcher.go 65.0% 64.5% -0.5

@knative-prow-robot knative-prow-robot merged commit 3a1ef91 into knative-extensions:main Jun 9, 2021
skonto added a commit to skonto/eventing-kafka that referenced this pull request Jun 10, 2021
* support eventing metrics

* lint

* imports

* update with latest deps
openshift-merge-robot pushed a commit to openshift-knative/eventing-kafka that referenced this pull request Jun 15, 2021
* patch vendor

* Support eventing metrics (knative-extensions#688)

* support eventing metrics

* lint

* imports

* update with latest deps

* use transformers in dispatchWithRetries instead of copying

* fix use of transformers

* updates

* pass transformers to executeRequest
skonto added a commit to skonto/eventing-kafka that referenced this pull request Jun 16, 2021
…ons#234)

* patch vendor

* Support eventing metrics (knative-extensions#688)

* support eventing metrics

* lint

* imports

* update with latest deps

* use transformers in dispatchWithRetries instead of copying

* fix use of transformers

* updates

* pass transformers to executeRequest
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cla: yes Indicates the PR's author has signed the CLA. lgtm Indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Event counts are not properly exported for the consolidated channel
4 participants