-
Notifications
You must be signed in to change notification settings - Fork 857
Add metrics for H2/3 frames and a way to access them from plugins #10627
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| .. Licensed to the Apache Software Foundation (ASF) under one or more | ||
| contributor license agreements. See the NOTICE file distributed | ||
| with this work for additional information regarding copyright | ||
| ownership. The ASF licenses this file to you under the Apache | ||
| License, Version 2.0 (the "License"); you may not use this file | ||
| except in compliance with the License. You may obtain a copy of | ||
| the License at | ||
|
|
||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, software | ||
| distributed under the License is distributed on an "AS IS" BASIS, | ||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or | ||
| implied. See the License for the specific language governing | ||
| permissions and limitations under the License. | ||
|
|
||
|
|
||
| TSHttpSsnInfoIntGet | ||
| =================== | ||
|
|
||
| Synopsis | ||
| -------- | ||
|
|
||
| .. code-block:: cpp | ||
|
|
||
| #include <ts/ts.h> | ||
|
|
||
| .. c:function:: TSReturnCode TSHttpSsnInfoIntGet(TSHttpSsn ssnp, TSHttpSsnInfoKey key, TSMgmtInt * value, uint64_t subkey = 0) | ||
|
|
||
| Description | ||
| ----------- | ||
|
|
||
| :c:func:`TSHttpSsnInfoIntGet` returns arbitrary integer-typed info about a session as defined in | ||
| :c:type:`TSHttpSsnInfoKey`. The API will be part of a generic API umbrella that can support returning | ||
| arbitrary info about a session using custom log tags. | ||
|
|
||
| The :c:type:`TSHttpSsnInfoKey` currently supports the below integer-based info about a transaction | ||
|
|
||
| .. c:enum:: TSHttpSsnInfoKey | ||
|
|
||
| .. c:enumerator:: TS_SSN_INFO_TRANSACTION_COUNT | ||
|
|
||
| The value indicate the number of transactions made on the session. | ||
|
|
||
| .. c:enumerator:: TS_SSN_INFO_RECEIVED_FRAME_COUNT | ||
|
|
||
| The value indicate the number of HTTP/2 or HTTP/3 frames received on the session. | ||
| A frame type must be specified by passing it to subkey. | ||
| You can use TS_SSN_INFO_RECEIVED_FRAME_COUNT_H2_UNKNOWN and TS_SSN_INFO_RECEIVED_FRAME_COUNT_H3_UNKNOWN to get the value for | ||
| unknown frames. | ||
|
|
||
| Return values | ||
| ------------- | ||
|
|
||
| The API returns :c:data:`TS_SUCCESS`, if the requested info is supported, :c:data:`TS_ERROR` otherwise. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| /** @file | ||
| * | ||
| * A brief file description | ||
| * | ||
| * @section license License | ||
| * | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| #pragma once | ||
|
|
||
| #include "proxy/http3/Http3Types.h" | ||
| #include "proxy/http3/Http3FrameHandler.h" | ||
|
|
||
| class Http3FrameCounter : public Http3FrameHandler | ||
| { | ||
| public: | ||
| Http3FrameCounter(){}; | ||
|
|
||
| // Http3FrameHandler | ||
| std::vector<Http3FrameType> interests() override; | ||
| Http3ErrorUPtr handle_frame(std::shared_ptr<const Http3Frame> frame, int32_t frame_seq = -1, | ||
| Http3StreamType s_type = Http3StreamType::UNKNOWN) override; | ||
|
|
||
| uint64_t get_count(uint64_t type) const; | ||
|
|
||
| private: | ||
| // Counter for received frames | ||
| std::atomic<uint64_t> _frame_counts_in[static_cast<int>(Http3FrameType::UNKNOWN) + 1] = { | ||
| 0, // DATA | ||
| 0, // HEADERS | ||
| 0, // X_RESERVED_1 | ||
| 0, // CANCEL_PUSH | ||
| 0, // SETTINGS | ||
| 0, // PUSH_PROMISE | ||
| 0, // X_RESERVED_2 | ||
| 0, // GOAWAY | ||
| 0, // X_RESERVED_3 | ||
| 0, // X_RESERVED_4 | ||
| 0, // UNDEFINED | ||
| 0, // UNDEFINED | ||
| 0, // UNDEFINED | ||
| 0, // MAX_PUSH_ID | ||
| 0 // UNKNOWN | ||
| }; | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -647,6 +647,15 @@ char const TS_VERSION_STRING[] = "@TS_VERSION_STRING@"; | |
| TS_TXN_INFO_LAST_ENTRY, | ||
| }; | ||
|
|
||
| enum TSHttpSsnInfoKey { | ||
| TS_SSN_INFO_NONE = -1, | ||
| TS_SSN_INFO_TRANSACTION_COUNT, | ||
| TS_SSN_INFO_RECEIVED_FRAME_COUNT, | ||
| }; | ||
|
|
||
| #define TS_SSN_INFO_RECEIVED_FRAME_COUNT_H2_UNKNOWN 999 | ||
| #define TS_SSN_INFO_RECEIVED_FRAME_COUNT_H3_UNKNOWN 0x21 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this 0x21 when the index enum value is 0x0e?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because 0x0e is just an unassigned number (it could be used later for something). 0x21 is reserved for exercising and will never be used. |
||
|
|
||
| enum TSVConnCloseFlags { | ||
| TS_VC_CLOSE_ABORT = -1, | ||
| TS_VC_CLOSE_NORMAL = 1, | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why doesd this need to be atomic? h2 connections shouldn't be handled on multiple threads.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that is true, but we have a lot of SCOPED_MUTEX_LOCK in http2 code and other counters for H2 use atomic too. I don't want any surprise from this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there an index enum for these values?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is Http2FrameType, and HTTP2_FRAME_TYPE_MAX is the last item. We need one extra space for unknown type.