Application Insights - Custom Performance Counter - azure-application-insights

I can instantiate a new performance counter object, but how can i "track" it? there's "TrackTrace", "TrackException", and etc, but theres no "TrackPerformanceCounter"... Any work around that?

if you're using a real performance counter, then you'd configure your applicationinsights.config to collect that performance counter, and it just would happen normally. (https://learn.microsoft.com/en-us/azure/application-insights/app-insights-performance-counters)
<Add Type="Microsoft.ApplicationInsights.Extensibility.PerfCounterCollector.PerformanceCollectorModule, Microsoft.AI.PerfCounterCollector">
<Counters>
<Add PerformanceCounter="\Objects\Processes"/>
<Add PerformanceCounter="\Sales(photo)\# Items Sold" ReportAs="Photo sales"/>
</Counters>
</Add>
if you're not using real performance counters and simply want to track the value of a number, you'd use either TrackMetric(nameOfThing, valueOfThing) directly, or you can track the value of that metric at any time by passing it in the metrics param in any of the TrackEvent( nameOfEvent, properties, metrics) calls.

There's no workaround... there are some open issues on the GITHUB project to increase/configure the recurrence of data capture but nothing concrete as of sep/2017

Related

IBpy cannot cancel open orders placed manually

When using ibpy trying to close some positions placed on TWS manually, it turns our we could not do this. Specifically, when performing:
self._tws.reqAllOpenOrders()
sleep(0.2)
We get the orders with id 0 (probably because i placecd it manually on TWS)
<openOrder orderId=0, contract=<ib.ext.Contract.Contract object at 0x103b78ad0>, order=<ib.ext.Order.Order object at 0x103b78a50>, orderState=<ib.ext.OrderState.OrderState object at 0x103b78b10>>
<orderStatus orderId=0, status=Submitted, filled=0, remaining=100, avgFillPrice=0.0, permId=134994568, parentId=0, lastFillPrice=0.0, clientId=0, whyHeld=None>
<openOrder orderId=0, contract=<ib.ext.Contract.Contract object at 0x103b78c90>, order=<ib.ext.Order.Order object at 0x103b78c50>, orderState=<ib.ext.OrderState.OrderState object at 0x103b78cd0>>
<orderStatus orderId=0, status=Submitted, filled=0, remaining=1, avgFillPrice=0.0, permId=134994562, parentId=0, lastFillPrice=0.0, clientId=0, whyHeld=None>
<openOrderEnd>
When trying to close it with:
self._tws.cancelOrder(0)
or
self._tws.cancelOrder(134994568)
I get the error:
<error id=0, errorCode=135, errorMsg=Can't find order with id =0>
<error id=134994562, errorCode=135, errorMsg=Can't find order with id =134994562>
Any idea how could we close them? Thank you.
You have to 'bind' the orders to the new client. Use this method tws.reqAutoOpenOrders(True). From the docs,
Finally, IBApi.EClient.reqAutoOpenOrders will allow to obtain those
orders manually placed using the TWS itself. This method also allows
the client application to take over these orders and modify them by
setting the autoBind parameter to true. If successfully bound, The
orders will be assigned (i.e. bound to) an API order id and as such be
eligible for modification.
client.reqAutoOpenOrders(true); Important: only those applications connecting with client Id 0 will be able to take over
manually submitted orders
Through the TWS' API settings it is possible to configure this
method's behaviour to some extent. As shown in the image below,
manually placed orders can be given a negative order Id which can
serve to easily tell manual from API submitted orders. The TWS'
tooltip elaborates further:
The callback will look like <openOrder orderId=-3,... and then you just call tws.cancelOrder(-3)
Note that you don't get orders placed previously in TWS, only those placed after the call to reqAutoOpenOrders.

Oozie coordinator - file event based trigger - multiple firing

Im trying to understand why an oozie 4.2 based coordinator job which should wait for a dataset fires multiple times. My coordinator job looks like this
<coordinator-app name="ConfirmDataMasterTrigger"
frequency="${frequencyMins}"
start="${startTime}"
end="${endTime}"
timezone="${timeZoneDef}"
xmlns="uri:oozie:coordinator:0.4"
xmlns:sla="uri:oozie:sla:0.2">
<controls>
<timeout>${TimeOutMins}</timeout>
<concurrency>${Concurrency}</concurrency>
<execution>${Execution}</execution>
</controls>
<datasets>
<dataset name="inputDS"
frequency="${coord:days(1)}"
initial-instance="${startTime}"
timezone="${timeZoneDef}">
<uri-template>${triggerFileDir}</uri-template>
<done-flag></done-flag>
</dataset>
</datasets>
<input-events>
<data-in name="ConfirmDataMasterTrigInput"
dataset="inputDS">
<instance>${coord:current(0)}</instance>
</data-in>
</input-events>
<action>
<workflow>
<app-path>${workflowAppPath}</app-path>
<configuration>
<property>
<name>SaveDateString</name>
<value>${coord:formatTime(coord:actualTime(),"-yyyyMMdd-HHmmss")}</value>
</property>
<property>
<name>WaitForThisInputData</name>
<value>${coord:dataIn('ConfirmDataMasterTrigInput')}</value>
</property>
</configuration>
</workflow>
</action>
With a properties file that looks like this
nameNode=hdfs://hc1m1.nec.co.nz:8020
jobTracker=hc1r1m2.nec.co.nz:8050
hdfsUser=oozie
wfProject=ConfirmDataMaster
oozie.libpath=${nameNode}/user/oozie/share/lib
oozie.use.system.libpath=true
oozie.wf.rerun.failnodes=true
moveFile=ConfirmDataMaster_edit.csv
sourceDir=${nameNode}/mule/sheets/input/ConfirmDataMaster/
targetDir=/mule/sheets/store/
sourceFile=${sourceDir}${moveFile}
targetFile=${targetDir}${moveFile}
frequencyMins=10
startTime=2016-07-31T12:00Z
endTime=2099-01-01T12:00Z
timeZoneDef=GMT+12:00
TimeOutMins=10
Concurrency=1
Execution=FIFO
triggerDir=trigger/
triggerFileDir=${sourceDir}${triggerDir}
doneFlag=trigger.dat
workflowAppPath=${nameNode}/user/${hdfsUser}/wf/${wfProject}
oozie.coord.application.path=${nameNode}/user/${hdfsUser}/wf/${wfProject}
I am not having a problem in getting a work flow to to be triggered by a
coordinator given a data set based event. What I am seeing is that the under lying workflow is continuously triggered. Can anyone advise changes I should make or my error. Obviously my workflow cleans up and deletes the trigger path. Thanks in advance.
Ill answer my own question because Ive worked out the solution and its a bit obvious really. I was just a little confused. The Firing frequency is controlled by the coordinator and data set frequencies and also the trigger directory and file. If you dont want a trigger file then leave done-flag empty. If that is not added then a default flag file is _SUCCESS.
So if the trigger is available the workflow will fire at those frequencies specified. So I have changed my cord and data set frequencies to be 30 ( mins ). As a final task my workflow removes the trigger.

Is my query getting cached?

I'm used to Adobe ColdFusion and have been caching queries using cachedafter with a "simple" date:
<cfparam name="application.icons_last_changed" default="#now()#">
<cfquery name="get_icons" cachedafter="02/02/1978" datasource="#application.datasources.main#">
SELECT icon_id, icon_name
FROM REF_Icon
WHERE #application.icons_last_changed#=#application.icons_last_changed#
ORDER BY sort_order
</cfquery>
I transitioned my project from ColdFusion/MSSQL to Railo/PostgreSQL. Today, something in the Railo diagnostics caught my eye.
I'm used to seeing "get_ref_icon (Datasource=Workstream, Time=cached, Records=39) in /path/qry_get_ref_icon.cfm"
but in Railo I see "get_ref_icon (Datasource=Workstream, Time=0.974 ms, Records=39) in /pathqry_get_ref_icon.cfm".
Thinking that perhaps the simple data value ("02/02/1978") for cachedafter isn't supported by Railo, I tried setting the date with createodbcdatetime('1978-02-02 16:37:00'), but that didn't seem to make a difference.
Of course, 0.974 ms is such a small time that perhaps the query is cached, and Railo just isn't as explicit as ColdFusion.
Is my query getting cached, or am I going about it the wrong way?
No, the query is not getting cached.
I followed Busches's suggestion and reviewed the results from <cfdump var="#get_icons#" />:
Query
Template:/super/double/secret/path/qry_get_ref_icon.cfm
Execution Time (ms):0.624
Recordcount:39
Cached:No <--UH OH, SPAGHETTI-O's
Lazy:No
SQL:
SELECT icon_id, icon_name
FROM REF_Icon
WHERE active_ind=1 /*{ts '1978-02-02 16:37:00'}*/
AND {ts '2013-02-20 22:25:14'}={ts '2013-02-20 22:25:14'}
ORDER BY sort_order
Because I'm a distrustful type, I also followed Adam Cameron's suggestion and changed some data then reran the query. Query results updated, so no caching.
I've reported the issue to the fine Railo folks: https://issues.jboss.org/browse/RAILO-2318

File sharing violation using SQL Server Compact Edition

I have a personal website written in ASP.NET Web Pages, with a small SQL Server Compact Edition database. This is handy for me because the database is stored as a file (.sdf), and when I add, modify or delete any records and test it out locally, I can just use Publish... in WebMatrix and copy the .sdf file over.
This works great except for a random error message I get when it accesses the .sdf file.
I get...
There is a file sharing violation. A different process might be using the file.
Sometimes a page refresh will fix it, sometimes I have to refresh the page a couple of times. I suppose migrating the database to a SQL Server database will fix it, but I don't really want to do that. Is that the best option though?
Here's a link to the site, maybe you'll hit the error: http://www.garethlewisweb.com
Is there something I have to change in the code, or will I need to ask my hosting company to change something. I don't really have a lot of experience in this area.
Thanks!
Update
Here's my code
_AppStart.cshtml
#{
WebSecurity.InitializeDatabaseConnection("GarethLewisWeb", "UserProfile", "UserId", "Email", true);
// WebMail.SmtpServer = "mailserver.example.com";
// WebMail.EnableSsl = true;
// WebMail.UserName = "username#example.com";
// WebMail.Password = "your-password";
// WebMail.From = "your-name-here#example.com";
}
Default.cshtml
#{
Layout = "~/Shared/_SiteLayout.cshtml";
Page.Title = "Home";
var db = Database.Open("GarethLewisWeb");
var featuredPhotoSQL = " SELECT col " +
" FROM tablename ";
var featuredPhoto = db.QuerySingle(featuredPhotoSQL);
}
[Lots of HTML and C# code here...]
Well, you know- that is like trying to wash dishes in an oven. It won't work.
Basically - most likely you try to create multiple instances of SQL Server CE and then use the same DB and guess what - the old one still has the exclusive lock.
In general, you CAN NOT USE SQL CE ON A WEBSITE. It is not made for concurrent access, and even if you are one of the few, that is like asking for trouble. Google comes around, a fiend comes around, and occaionally your browser comes around with 2 requests that overlap and boom - dead.
You do not show any code, so I can only guess what causes the problem, but the documentation for CE is QUITE strict - it is NOT for multi threaded scenarios.
Not really an answer to this specific problem, but the migration to SQL Server solved this issue.
When we added Mode=Read Only; Temp Path=c:/Temp in the connection string then it fixed.
<connectionStrings>
<add name="XYZ" providerName="System.Data.SqlServerCe.4.0" connectionString="Data Source=|DataDirectory|\XYZ.sdf;Max Database Size = 4091;Enlist=false;encryption mode=engine default;password=!secret!;Mode = Read Only;Temp Path=c:/temp" />
</connectionStrings>
It worked for us !

BizTalk Business Rules Engine - Repeating Elements

I'm trying to create what I think should be a relatively simple business rule to operate over repeating elements in an XML schema.
Consider the following XML snippet (this is simplified with namespaces removed, for readability):
<Root>
<AllAccounts>
<Account id="1" currentPayment="10.00" arrearsAmount="25.00">
<AllCustomers>
<Customer id="20" primary="true" canSelfServe="false" />
<Customer id="21" primary="false" canSelfServe="false" />
</AllCustomers>
</Account>
<Account id="2" currentPayment="10.00" arrearsAmount="15.00">
<AllCustomers>
<Customer id="30" primary="true" canSelfServe="false" />
<Customer id="31" primary="false" canSelfServe="false" />
</AllCustomers>
</AllAccounts>
</Root>
What I want to do is to have two rules:
Set /Root/AllAccounts/Account[x]/AllCustomers/Customer[primary='true']/canSelfServe
= true IF arrearsAmount < currentPayment
Set /Root/AllAccounts/Account[x]/AllCustoemrs/Customer[primary='true']/canSelfServer
= false IF arrearsAmount >= currentPayment
Where [x] is 0...number of /Root/AllAccounts/Account records present in the XML.
I've tried two simple rules for this, and each rule seems to fire x * x times, where x is the number of Account records in the XML. I only want each rule to fire once for each Account record.
Any help greatly appreciated!
Thanks
Andrew
Make sure that the rules have the same Priority, just in case (I had issues with priorities before). I've also saw that at the Rules level, there is a property called maximum Execution Loop Depth, which assigns how many times can a rule be reevaluated. Try to put 1 there, if you're sure that your rules should only be evaluated once per payload. I hope this helps.
Check your predicate. The rule fires once for each matching combo of fields used in the predicate.

Resources