Micrometer #Timed annotation write logs to file? - micrometer

How to configure spring-boot Micrometer #Timed annotation to write logs into some log file instead of endpoint?

To write all metrics to logs you can use the LoggingMeterRegistry. There is no autoconfiguration for this in spring boot so if you are using spring boot you will need to configure the required beans manually.
Source code: https://github.com/micrometer-metrics/micrometer/blob/master/micrometer-core/src/main/java/io/micrometer/core/instrument/logging/LoggingMeterRegistry.java

Related

Trying to add heartbeat for my console application

A discussion on github mentions that heartbeat is automatically sent when Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.DiagnosticsTelemetryModule& is added to the applicationinsights.config file. I want to create an alert in case the app hangs or crashes. Where can I track the heart beat on the AI instance? Also, currently its not sending anything . I am using .net framework 4.7.2. Am I configuring it wrong? I am not able to track the heartbeat on application insights instance. Where can I track it? Can someone provide a snippet for config file?
Currently, there is an issue involving this telemetry module AppServicesHeartbeatTelemetryModule .
Can someone provide a snippet for config file?
There is given a temporary workaround for WorkerServices.
Add application insights to worker service using services.AddApplicationInsightsTelemetryWorkerService().
Not only this DiagnosticsTelemetryModule adding to DI and also we need to configure it's heartbeat interval/module using the below snippet:
services.TryAddSingleton<ITelemetryModule, DiagnosticsTelemetryModule>();
services.ConfigureTelemetryModule<DiagnosticsTelemetryModule>((mod,opt) => mod.HeartbeatInterval = TimeSpan.FromSeconds(30));
services.AddApplicationInsightsTelemetryWorkerService();
The TelemetryConfiguration.Active is not recommended because Worker service is new SDK, its not touching .active or any other static singletons.
Where can I track it?
After Deploying, Look for "HeartbeatState" in customMetrics.
Note:
Disabling DiagnosticsTelemetryModule will cause the following settings to be ignored: EnableHeartbeat, EnableAzureInstanceMetadataTelemetryModule, EnableAppServicesHeartbeatTelemetryModule.
Enable Azure Monitor from the Portal.
References:
Configuring or removing default TelemetryModules (HeartBeat Telemetry Issue)
Enabling Hearbeat in App Services for .NET and .NET Core

Spring Integration: configure default errorChannel

when starting the spring boot integration project on which I’m working on, following Info log is shown:
No bean named 'errorChannel' has been explicitly defined. Therefore, a default PublishSubscribeChannel will be created.
Is there a way to configure the queue name for this default Bean using only yaml/json paramenters, without explicitly create the Bean?
No there is not; you explicity need to declare a MessageChannel bean named errorChannel to replace the default error channel and its configuration.

Change failover time for aws kcl

AWS recommends to increase failover time for KCL (kinesis), if apps with connectivity issues.
https://docs.aws.amazon.com/streams/latest/dev/troubleshooting-consumers.html
But I can’t find how failover time can be changed.
I’m looking for (one or all):
settings in AWS console
settings for the node.js kcl package
settings by Terraform
The failover time is a configuration option for the Kinesis Client Library. It is not a property on the stream. As a result, you cannot change it in the AWS console.
Configuring AWS Kinesis Client library for Node.js is done using property files. I assume you already have a property file otherwise you wouldn't be able to start up your consumer application. What you need to do is add this to your property file:
# Fail over time in milliseconds.
failoverTimeMillis = 10000
See this sample property file provided by the library:
https://github.com/awslabs/amazon-kinesis-client-nodejs/blob/master/samples/basic_sample/consumer/sample.properties#L38
Also see this documentation for more detail on how to change the property file:
https://docs.aws.amazon.com/streams/latest/dev/kinesis-record-processor-implementation-app-nodejs.html#kinesis-record-processor-initialization-nodejs

How to add properties via Spring TestExecutionListener

I created a TestExecutionListener to run a docker container for integration testing. I would like to be able to inject properties (eg container port) that can be used by #ConfigurationProperties annotated beans.
I thought I might be able to call TestPropertySourceUtils.addInlinedPropertiesToEnvironment(...) but when I try to get an application context object the context ends up fully loading before I can even attempt to inject any properties.
Is there any way to do this from a TestExecutionListener?
My workaround is to set the properties via System.setProperty(...) but that obviously does not permit any concurrency.
I'm running Spring Boot 2.1.1.RELEASE.

Create programatically message-driven-channel-adapter to process the messages on queue

I would like process the message programmatically using message-driven-channel-adapter. Here is scenario which I have to implement:
My application during the startup read the configuration from a service. The configuration provides information about the queues which will contain the messages. Hence I would like to create a message-driven-channel-adapter for each queue to listen to messages asynchronously.
Any example which initializes all the spring integration context programatically instead of using XML will be useful.
If you are going to do everything programmatically, I'd suggest you bypass Spring Integration magic and just use DefaultMessageListenerContainer directly.
Afterwards you can send messages to an existing MessageChannel directly from the MessageListener implementation or using Messaging Gateway.
Please, be careful with programmatic configuration with that do not miss important attributes like ApplicationContext or invocation for afterPropertiesSet().

Resources