-
Notifications
You must be signed in to change notification settings - Fork 107
GATEWAYS-4306: exporting metrics for conntrack per zone #137
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
base: master
Are you sure you want to change the base?
Changes from all commits
e306589
80916dc
8b03af1
e8eeddb
dc73f17
7b31316
02ce3ca
15e3b1a
b1b102c
9796da5
df047c7
51dbc5b
0f97bc6
578db7f
33d1c71
3d1d088
68f438c
4809d11
ff11970
5ac45d4
64416ca
457550e
6b139de
3f97fdb
6b5e843
70905a1
1a1e9d1
4c0669e
96ff4a1
5125d48
eeb4fce
98dcb70
893e7c6
b77cf7d
48399e8
18d82e3
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,65 @@ | ||
// Copyright 2017 DigitalOcean. | ||
// | ||
// Licensed 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. | ||
|
||
package ovsnl | ||
|
||
import ( | ||
"sync" | ||
"time" | ||
|
||
"github.com/ti-mo/conntrack" | ||
) | ||
|
||
// Tunables - adjust for your environment | ||
const ( | ||
eventChanSize = 512 * 1024 | ||
eventWorkerCount = 100 | ||
destroyFlushIntvl = 100 * time.Millisecond // flush aggregated DESTROYs every 100ms for minimal lag | ||
destroyDeltaCap = 200000 // maximum distinct (zone,mark) entries in destroyDeltas | ||
dropsWarnThreshold = 100 // threshold of missedEvents to log a stronger warning | ||
) | ||
|
||
// ZoneMarkAggregator keeps live counts (zmKey -> count) with bounded ingestion | ||
type ZoneMarkAggregator struct { | ||
// primary counts (zmKey -> count) - simplified flat mapping | ||
counts map[ZmKey]int | ||
countsMu sync.RWMutex | ||
|
||
// conntrack listening connection | ||
listenCli *conntrack.Conn | ||
|
||
// lifecycle | ||
stopCh chan struct{} | ||
wg sync.WaitGroup | ||
|
||
// bounded event ingestion | ||
eventsCh chan conntrack.Event | ||
|
||
// aggregated DESTROY deltas (bounded by destroyDeltaCap) | ||
deltaMu sync.Mutex | ||
destroyDeltas map[ZmKey]int | ||
|
||
// metrics / health | ||
eventCount int64 | ||
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. would recommend using |
||
lastEventTime time.Time | ||
eventRate float64 | ||
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. it looks like
|
||
missedEvents int64 | ||
lastHealthCheck time.Time | ||
} | ||
|
||
// ZmKey is a compact key for (zone,mark) | ||
type ZmKey struct { | ||
Zone uint16 | ||
Mark uint32 | ||
} |
Uh oh!
There was an error while loading. Please reload this page.