http.server.requests and http.client.requests metrics not coming in spring actuator json - spring-boot-actuator

In my springboot application i can not see any http metrics.
I can only see below metrics:
// 20230120164530
// http://localhost:8081/actuator/metrics
{
"names": [
"application.ready.time",
"application.started.time",
"disk.free",
"disk.total",
"executor.active",
"executor.completed",
"executor.pool.core",
"executor.pool.max",
"executor.pool.size",
"executor.queue.remaining",
"executor.queued",
"jvm.buffer.count",
"jvm.buffer.memory.used",
"jvm.buffer.total.capacity",
"jvm.classes.loaded",
"jvm.classes.unloaded",
"jvm.gc.live.data.size",
"jvm.gc.max.data.size",
"jvm.gc.memory.allocated",
"jvm.gc.memory.promoted",
"jvm.gc.overhead",
"jvm.gc.pause",
"jvm.memory.committed",
"jvm.memory.max",
"jvm.memory.usage.after.gc",
"jvm.memory.used",
"jvm.threads.daemon",
"jvm.threads.live",
"jvm.threads.peak",
"jvm.threads.states",
"logback.events",
"process.cpu.usage",
"process.files.max",
"process.files.open",
"process.start.time",
"process.uptime",
"resilience4j.retry.calls",
"system.cpu.count",
"system.cpu.usage",
"system.load.average.1m",
"tomcat.sessions.active.current",
"tomcat.sessions.active.max",
"tomcat.sessions.alive.max",
"tomcat.sessions.created",
"tomcat.sessions.expired",
"tomcat.sessions.rejected"
]
}

Making the rest call to the api generated the http.server.requests and http.client.requests metrics

Related

Number of dimensions allowed in GA4 data API

While going through the new GA4 data API documentation, I didn't come across any specification for the number of dimensions allowed in a single request.
It seemed like there was no upper limit. This document doesn’t mention an upper limit and states the following:
“In a report request, you can specify zero or more dimensions.”
However when I try executing the v1alpha:runReport API via postman I get this response if I give more than 8 dimensions:
{
"error": {
"code": 400,
"message": "Requests are limited to 8 dimensions within a nested request.\n This request is for 9 dimensions.",
"status": "INVALID_ARGUMENT"
}
}
Has the number of dimensions allowed in a request been reduced to 8? If yes, can you point me to some document that states this?
The earlier UA batchGet API used to allow max 9 dimensions and I was expecting the same limit with the new GA4 data API.
Steps to Reproduce:
Post a request to v1alpha:runReport with more than 8 dimensions:
Request URL: https://analyticsdata.googleapis.com/v1alpha:runReport
Request Auth: A valid bearer token
Request Body:
{
"entity":{
"propertyId":"123456789"
},
"dateRanges":[
{
"startDate":"2021-03-29",
"endDate":"2021-03-29"
}
],
"dimensions":[
{
"name":"eventName"
},
{
"name":"source"
},
{
"name":"medium"
},
{
"name":"hostname"
},
{
"name":"dateHour"
},
{
"name":"deviceCategory"
},
{
"name":"browser"
},
{
"name":"city"
},
{
"name":"country"
}
],
"metrics":[
{
"name":"screenPageViews"
},
{
"name":"userEngagementDuration"
},
{
"name":"eventCount"
}
]
}
The Google analytics GA4 data api is a brand new api, released as part of GA4. As such it has not been reduced to 8 dimensions this is the current limit as it stands
Requests are limited to 8 dimensions within a nested request.
The Google analytics reporting api may allow for additional dimensions and metrics but they are it's a completely different system. You can't compare universal analytics and GA4
Note: i have submitted a note about the lack of documentation to the team
Updated docs state up to 9 dimensions are now allowed.
https://developers.google.com/analytics/devguides/reporting/data/v1/basics#dimensions

WireMock To Use As Proxy For SOAP Service

Here is the scenario I'm trying to work on:
I'm writing Contract Driven Tests using Spring Cloud Contract. The tests for inter-communication between the microservices works fine.
Some microservices are calling SOAP-based services. As part of integration tests, I'm trying to use
WireMock as a proxy for the SOAP-based services. Basically, the WireMock should intercept the call, then call the target live environment with the same request, return the same response to the test as a stub.
Unfortunately, I couldn't find any examples how to proceed with that. These services use the HTTP protocol. Any examples of how or any pointers to achieve this would be great. Thanks!
Firstly you need to point your SOAP client to the WireMock base URL, so e.g. if you're using a Spring properties file you might have something like this:
soap.api.host=wiremock-host.internal
soap.api.port=8888
Then you need to configure the WireMock server with a low-priority, broad matching proxy stub. Here's an example of how that would look in JSON form:
{
"priority": 8,
"response": {
"proxyBaseUrl" : "http://target.soap.endpoint"
}
}
Then finally, you would create additional stubs (at the default priority) for each request you want to intercept e.g.
{
"request": {
"method": "POST",
"urlPath": "/v1/some/thing",
"headers": {
"SOAPAction": {
"contains": "MyAction"
}
}
},
"response": {
"status": 200,
"body": "<soap:Envelope ..."
}
}

Filtering results from Google Analytics Reporting API

I am successfully downloading results from Google Analytics using the reporting API (version 4), with the PHP client library. But I have not figured out how to correctly filter these results.
I see how this would work via cURL, but not through the client library. I looked through the client library code, and there is a class method:
apiclient-services/Google/Service/AnalyticsReporting/ReportRequest.php:
public function setMetricFilterClauses($metricFilterClauses)
I do not see any documentation or any usage of the associated get method:
public function getMetricFilterClauses()
Are there examples of using filters through the PHP client library?
Background
The Google API Client libraries are generated from the Google Discovery Service. And the PHP client library generates a setProperty and getProperty for every property of a resource.
Analytics Reporting API V4
The Analytics Reporting API V4 reference docs exhustively describe the API. The Developer Guide gives the underlying JSON example which the client libraries will generate:
POST https://analyticsreporting.googleapis.com/v4/reports:batchGet
{
"reportRequests":
[
{
"viewId": "XXXX",
"dateRanges": [
{"endDate": "2014-11-30", "startDate": "2014-11-01"}
],
"metrics": [
{"expression": "ga:pageviews"},
{"expression": "ga:sessions"}
],
"dimensions": [{"name": "ga:browser"}, {"name": "ga:country"}],
"dimensionFilterClauses": [
{
"filters": [
{
"dimensionName": "ga:browser",
"operator": "EXACT",
"expressions": ["Chrome"]
}
]
}
]
}
]
}
And the Samples page gives many examples requests in Python, Java, PHP and JavaScript, which should give you a good sense of how to work with the individual client libraries. But you are correct there is not an explicit example of PHP using a filter.
PHP Filter Example
Below is the same example as the request above:
// Create the DateRange object.
$dateRange = new Google_Service_AnalyticsReporting_DateRange();
$dateRange->setStartDate("2014-11-01");
$dateRange->setEndDate("2014-11-30");
// Create the Metrics object.
$pageviews = new Google_Service_AnalyticsReporting_Metric();
$pageviews->setExpression("ga:pageviews");
$sessions = new Google_Service_AnalyticsReporting_Metric();
$sessions->setExpression("ga:sessions");
//Create the Dimensions object.
$browser = new Google_Service_AnalyticsReporting_Dimension();
$browser->setName("ga:browser");
$country = new Google_Service_AnalyticsReporting_Dimension();
$country->setName("ga:country");
// Create the DimensionFilter.
$dimensionFilter = new Google_Service_AnalyticsReporting_DimensionFilter();
$dimensionFilter->setDimensionName('ga:browser');
$dimensionFilter->setOperator('EXACT');
$dimensionFilter->setExpressions(array('Chrome'));
// Create the DimensionFilterClauses
$dimensionFilterClause = new Google_Service_AnalyticsReporting_DimensionFilterClause();
$dimensionFilterClause->setFilters(array($dimensionFilter));
// Create the ReportRequest object.
$request = new Google_Service_AnalyticsReporting_ReportRequest();
$request->setViewId("XXXX");
$request->setDateRanges($dateRange);
$request->setDimensions(array($browser, $country));
$request->setDimensionFilterClauses(array($dimensionFilterClause));
$request->setMetrics(array($pageviews, $sessions));
$body = new Google_Service_AnalyticsReporting_GetReportsRequest();
$body->setReportRequests( array( $request) );
return $analyticsreporting->reports->batchGet( $body );
As you probably noticed I never once used a $object->getProperty(). Basically All it would do is give me its current value. When Calling the API you should only ever need to $object->setProperty($value); Hence why I gave you the background that the client libraries are generated.
Conclusion
The Analytics Reporting API itself is complex and there are many client library languages. It is not always possible to give an example every possible usage of an API in every possible client library language. That is why it is necessary to understand how to look at the reference docs and understand how the client libraries are generated from the structure described.
There is an issue with DimensionFilter() class in a script above, i get error that it is not defined, but i have changed it to Google_Service_AnalyticsReporting_DimensionFilter() class and now it is working hope that will help to someone.

How can I consume Spring Hateoas embedded?

I am studying Spring Projects (Web, Security, DATA JPA, Hateoas)
And I am developing sample web service.
It is consist of two module.
Rest API server (provide data, Spring Data JPA, Spring Data Rest, Spring Hateoas)
Web server (provide Web service, Spring MVC, Spring Security)
Actually "Rest API server" is simple and easy.
I just defined some Entity class, and just use "#RepositoryRestResource"
#RepositoryRestResource generated RestController, right?
So when I call REST API like "localhost:8080/users", I can receive the responses.
But there is very critical issue.
I got the response like below:
{
"_links":{
"self":{
"href": "http://localhost:8888/users{?page,size,sort}",
"templated": true
},
"search":{
"href": "http://localhost:8888/users/search"
}
},
"_embedded":{
"users":[
{
"email": "test#gmail.com", "name": null, "isShowName": null, "nickName": null
}
]
},
"page":{
"size": 20,
"totalElements": 5,
"totalPages": 1,
"number": 0
}
}
When I print the response as toString, there are no "Embedded" values.
There are just "link" values.
I need the "Embedded" values.
I tried to googling, but there are no clear resolutions.
So I am contemplating using not Hateoas but RestController.
If I use RestController, I can resolve this easily.
Who can help me please?

How to handle submitted array of json with fosrest bundle and nemio api doc bundle

I have a controller in my Rest API that expects an array of json (in POST)
{
data: [
{
name: "marc"
},
{
name: "john"
}
]
}
Submitted data are then saved in database.
I don't know what annotation to use in order to tell "nelmio api doc bundle" to generate the appropriate html page in order to have capability to test my API by creating multiple items (an array of items).
To resume the question is : Can nelmio documentation generates a dynamic collection of forms ?
You can test your API through nelmio sandbox.
Nelmio have the "New Parameter" button which is can add multiple key => value parameters.

Resources