How to get execution times of Azure Function steps? - performance

I have an Azure Function set up as illustrated bellow. I need to understand the execution times for Trigger, Function, and Output steps because even after the function is "warm", first request takes up to 7 seconds. After that the execution time drops to something like 100 ms.
So far I switched the logging level in host.json to
"logging": {
"fileLoggingMode": "always",
"logLevel": {
"default": "Information",
"Host.Results": "Error",
"Function": "Trace",
"Host.Aggregator": "Trace"
}
}
and watched the simple telemetry in live logs:
8:48:07 AM | Trace Request successfully matched the route with name 'main' and template 'api/{*segments}'
8:48:06 AM | Trace Executing 'Functions.main' (Reason='This function was programmatically called via the host APIs.', Id=...)
That's pretty much all I see. Also, when opening the Application - Functions - Function - main log from Visual Studio, the log levels still have [Information] preable.
What I would like to see is basically a duration-time output as in the monitor (from Functions - Main in web portal) section, but split by steps. For example:
date | step | success | result code | duration (ms)
---------------------------------------------------------
.... | trigger | success | 200 | 39
.... | function | success | 200 | 32
.... | output | success | 200 | 37
How to get the duration time for Trigger, Function, and Output steps on every execution?

Related

How do I get Istanbul to recognize code coverage when using ESM?

I'm using ESM to loading my modules and I use them in this way:
// More info on why this is needed see (https://github.com/mochajs/mocha/issues/3006)
async function wire(){
await import("./Sanity.spec.mjs");
await import("./Other.spec.mjs");
run();
}
wire();
I run these tests using nyc mocha --delay --exit ./test/suite.js, but when I run Istanbul it does not seems to recognize my imports and fails to provide coverage information...
3 passing (14ms)
----------|----------|----------|----------|----------|-------------------|
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s |
----------|----------|----------|----------|----------|-------------------|
All files | 0 | 0 | 0 | 0 | |
----------|----------|----------|----------|----------|-------------------|
How can I get Istanbul to recognize the ESM loaded code?
Native ESM support is available from Mocha v7.1.0 (February 2020).
See:
Relase notes: https://github.com/mochajs/mocha/releases/tag/v7.1.0
Pull request: https://github.com/mochajs/mocha/pull/4038

Stuck building gatsby-starter-netlify-cms

I recently switched from react static to gatsby & hit a wall. When I install & build gatsby-starter-netlify-cms I get an error:
success open and validate gatsby-configs — 0.049 s
success load plugins — 1.757 s
success onPreInit — 53.736 s
success delete html and css files from previous builds — 0.013 ssuccess initialize cache — 0.725 s
success copy gatsby files — 4.323 s
success onPreBootstrap — 0.261 s
success source and transform nodes — 1.672 s
success building schema — 6.302 s
success createPages — 0.634 s
success createPagesStatefully — 0.525 s
success onPreExtractQueries — 0.211 s
success update schema — 1.565 s
error GraphQL Error Field "image" must not have a selection since type "String" has no subfields.
file: C:/Users/Jason/Dropbox/Documents/Projects/jamamuuga-s-portfolio-gatsby-netlifycms/src/templates/product-page.js
1 |
2 | query ProductPage($id: String!) {
3 | markdownRemark(id: { eq: $id }) {
4 | frontmatter {
5 | title
> 6 | image {
| ^
7 | childImageSharp {
8 | fluid(maxWidth: 2048, quality: 100) {
9 | ...GatsbyImageSharpFluid
10 | }
11 | }
12 | }
13 | heading
14 | description
15 | intro {
16 | blurbs {
error Command failed with exit code 1.
I tried with both yarn & npm seperately to no avail.
You should check your markdown files and find files which have empty values for the field image, or values that point to non existing image. Frontmatter of a markdown file referes to the top of the file which containes some metadata of the file and is surrounded with ---. For example:
---
image:
//my coment: list of some other variables follow, like heading, title....
---

use smo to clone azure SQL database?

I'm writing a program to test update scripts for Azure sql.
The idea is to
- first clone a database (or fill a clone with the source schema and content)
- then run the update script on the clone
Locally I have this working, but for azure I have the probem that I don't see any file names. If I restore one database to another on the same azure "server", don't I have to rename the data files during restore too?
For local restore I do this:
restore.Devices.AddDevice(settings.BackupFileName, DeviceType.File);
restore.RelocateFiles.Add(new RelocateFile("<db>", Path.Combine(settings.DataFileDirectory, settings.TestDatabaseName + ".mdf")));
restore.RelocateFiles.Add(new RelocateFile("<db>_log", Path.Combine(settings.DataFileDirectory, settings.TestDatabaseName + "_1.ldf")));
restore.SqlRestore(srv);
Is something similar required for cloning a database on azure?
Lots of Greetings!
Volker
You can create a database as a copy of [source]:
CREATE DATABASE database_name [ COLLATE collation_name ]
| AS COPY OF [source_server_name].source_database_name
{
(<edition_options> [, ...n])
}
<edition_options> ::=
{
MAXSIZE = { 100 MB | 500 MB | 1 | 5 | 10 | 20 | 30 … 150…500 } GB
| EDITION = { 'web' | 'business' | 'basic' | 'standard' | 'premium' }
| SERVICE_OBJECTIVE =
{ 'basic' | 'S0' | 'S1' | 'S2' | 'S3'
| 'P1' | 'P2' | 'P3' | 'P4'| 'P6' | 'P11'
| { ELASTIC_POOL(name = <elastic_pool_name>) } }
}
[;]

How to match output spanning several lines

I have a expect session that looks similar to this:
spawn myapp
stratos> list-tenants
Available Tenants:
+-----------+-----------+-------------+--------+---------------------------+
| Domain | Tenant ID | Email | State | Created Date |
+-----------+-----------+-------------+--------+---------------------------+
| frank.com | 1 | foo#bar.com | Active | 2014-02-26T11:33:23+05:30 |
+-----------+-----------+-------------+--------+---------------------------+
stratos>
The flow is roughly:
The application outputs stratos>
The user enters list-tenants
The application outputs Available Tenants: with the table shown in the example above.
How can I match the output from step 3 in expect? I.e. what do I need to replace ????, below?
Note that the expect script is part of a test with the output generated by a mock service that the application calls, so I am expecting to match the whole output verbatim.
expect "stratos>"
send "list-tenants\r"
expect {
???? { exp_continue; }
timeout { puts stderr "Expect could not match 'Available Tenants:'"; exit 1; }
}
Many thanks.
Try this: (untested)
spawn myapp
set prompt_re {stratos> $}
expect -re $prompt_re
send -- "list-tenants\r"
expect {
timeout {error "could not match available tenants"}
-re "list-tenants(.+)$prompt_re"
}
set available_tenants [string trim $expect_out(1,string)]

Error Handling in CI

I read Error Handling but if I use log_message('debug', 'Hi I m in Cart Controller'); or log_message('info', 'Hi I m in Cart Controller'); it does not log any message but work only for log_message('error', 'Hi I m in Cart Controller');
Any idea what my mistake is?
You have to set the log threshold in app/config/config.php:
/*
|--------------------------------------------------------------------------
| Error Logging Threshold
|--------------------------------------------------------------------------
|
| If you have enabled error logging, you can set an error threshold to
| determine what gets logged. Threshold options are:
| You can enable error logging by setting a threshold over zero. The
| threshold determines what gets logged. Threshold options are:
|
| 0 = Disables logging, Error logging TURNED OFF
| 1 = Error Messages (including PHP errors)
| 2 = Debug Messages
| 3 = Informational Messages
| 4 = All Messages
|
| For a live site you'll usually only enable Errors (1) to be logged otherwise
| your log files will fill up very fast.
|
*/
$config['log_threshold'] = 2;

Resources