Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
opentrafficshaper
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Yuriy
opentrafficshaper
Commits
01d3ca1d
Commit
01d3ca1d
authored
11 years ago
by
Nigel Kukard
Browse files
Options
Downloads
Patches
Plain Diff
Added support for transforming basic stats name
Reworked some of the function names at the same time
parent
07c664f7
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
opentrafficshaper/plugins/statistics/statistics.pm
+44
-10
44 additions, 10 deletions
opentrafficshaper/plugins/statistics/statistics.pm
with
44 additions
and
10 deletions
opentrafficshaper/plugins/statistics/statistics.pm
+
44
−
10
View file @
01d3ca1d
...
@@ -774,7 +774,7 @@ sub getStatsBySID
...
@@ -774,7 +774,7 @@ sub getStatsBySID
foreach
my
$timestamp
(
keys
%
{
$statistics
})
{
foreach
my
$timestamp
(
keys
%
{
$statistics
})
{
my
$stat
=
$statistics
->
{
$timestamp
};
my
$stat
=
$statistics
->
{
$timestamp
};
# Use new item
# Use new item
$statistics
->
{
$timestamp
}
=
_
convertStat
(
$stat
,
$conversions
);
$statistics
->
{
$timestamp
}
=
_
fixStatDirection
(
$stat
,
$conversions
);
}
}
return
$statistics
;
return
$statistics
;
...
@@ -991,14 +991,22 @@ sub _processStatistics
...
@@ -991,14 +991,22 @@ sub _processStatistics
# Check if we have an event handler subscriber for this item
# Check if we have an event handler subscriber for this item
if
(
defined
(
my
$subscribers
=
$sidSubscribers
->
{
$sid
}))
{
if
(
defined
(
my
$subscribers
=
$sidSubscribers
->
{
$sid
}))
{
# Build the stat that our conversions understands
# Build the stat that our conversions understands
my
$eventStat
;
my
$eventStat
;
$eventStat
->
{
$stat
->
{'
direction
'}}
=
{
# This is a basic counter
'
rate
'
=>
$stat
->
{'
rate
'},
if
(
defined
(
$stat
->
{'
counter
'}))
{
'
pps
'
=>
$stat
->
{'
pps
'},
$eventStat
=
{
'
cir
'
=>
$stat
->
{'
cir
'},
'
counter
'
=>
$stat
->
{'
counter
'}
'
limit
'
=>
$stat
->
{'
limit
'},
};
};
}
else
{
$eventStat
->
{
$stat
->
{'
direction
'}}
=
{
'
rate
'
=>
$stat
->
{'
rate
'},
'
pps
'
=>
$stat
->
{'
pps
'},
'
cir
'
=>
$stat
->
{'
cir
'},
'
limit
'
=>
$stat
->
{'
limit
'}
};
}
# If we do, loop with them
# If we do, loop with them
foreach
my
$ssid
(
keys
%
{
$subscribers
})
{
foreach
my
$ssid
(
keys
%
{
$subscribers
})
{
...
@@ -1008,7 +1016,13 @@ sub _processStatistics
...
@@ -1008,7 +1016,13 @@ sub _processStatistics
my
$conversions
=
$subscriber
->
{'
conversions
'};
my
$conversions
=
$subscriber
->
{'
conversions
'};
# Get temp stat, this still refs the original one
# Get temp stat, this still refs the original one
my
$tempStat
=
_convertStat
(
$eventStat
,
$conversions
);
my
$tempStat
;
# This is a basic counter
if
(
defined
(
$eventStat
->
{'
counter
'}))
{
$tempStat
=
_fixCounterName
(
$eventStat
,
$conversions
);
}
else
{
$tempStat
=
_fixStatDirection
(
$eventStat
,
$conversions
);
}
# Send a copy! so we don't send refs to data used elsewhere
# Send a copy! so we don't send refs to data used elsewhere
$queuedEvents
->
{
$handler
}
->
{
$event
}
->
{
$ssid
}
->
{
$stat
->
{'
timestamp
'}}
=
dclone
(
$tempStat
);
$queuedEvents
->
{
$handler
}
->
{
$event
}
->
{
$ssid
}
->
{
$stat
->
{'
timestamp
'}}
=
dclone
(
$tempStat
);
}
}
...
@@ -1224,7 +1238,7 @@ sub _getStatsBasicBySID
...
@@ -1224,7 +1238,7 @@ sub _getStatsBasicBySID
# Function to transform stats before sending them
# Function to transform stats before sending them
sub
_
convertStat
sub
_
fixStatDirection
{
{
my
(
$stat
,
$conversions
)
=
@_
;
my
(
$stat
,
$conversions
)
=
@_
;
...
@@ -1254,7 +1268,27 @@ sub _convertStat
...
@@ -1254,7 +1268,27 @@ sub _convertStat
$newStat
->
{
$newKey
}
=
$oldStat
->
{
$item
};
$newStat
->
{
$newKey
}
=
$oldStat
->
{
$item
};
}
}
# We need to refactor the stat keys
return
$newStat
;
}
# Function to transform stats before sending them
sub
_fixCounterName
{
my
(
$stat
,
$conversions
)
=
@_
;
# Loop and set the identifier
my
$newStat
;
# If we have conversions defined...
my
$newKey
=
'
counter
';
if
(
defined
(
$conversions
)
&&
defined
(
$conversions
->
{'
name
'}))
{
$newKey
=
sprintf
('
%s
',
$conversions
->
{'
name
'});
}
$newStat
->
{
$newKey
}
=
$stat
->
{'
counter
'};
return
$newStat
;
return
$newStat
;
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment