AppInsight java agent add invalid character to Operation Id - azure-application-insights

There are two micro services A, B. When A calls REST API in B, A uses the header "request-id" to pass down the correlation id. The value of request id is like SA8802b6851efb05. Service A uses application insight java agent to send Telemetry to application insight. Service A doesn't have any custom app insight code. For some reason, Application Insight generates an operation id like "SA8802b6851efb05,|e7cce3c908fa6c9e1a87c3e8967486cf". The additional ",|e6cce3c908fa6c9e1a86c3e8967486cf" is unexpected.
We use applicationinsights-agent 3.0.0.
How can we configure app insight to just use the original value in request-id as operation id? We will prefer to not add custom code and just rely on json configuration if possible.
We don't have any custom code related to app insight. All we do is run our jar file with app insight agent like this.
export APPLICATIONINSIGHTS_CONNECTION_STRING=keyhere
java -javaagent:applicationinsights-agent-3.0.0.jar -jar service.jar.
We bundle a config file like below.
<ApplicationInsights xmlns="http://schemas.microsoft.com/ApplicationInsights/2013/Settings" schemaVersion="2014-05-30">
<!-- The key from the portal: -->
<!--InstrumentationKey>key should be passed as env variable APPLICATION_INSIGHTS_IKEY</InstrumentationKey-->
<!-- HTTP request component (not required for bare API) -->
<TelemetryModules>
<Add type="com.microsoft.applicationinsights.web.extensibility.modules.WebRequestTrackingTelemetryModule"/>
<Add type="com.microsoft.applicationinsights.web.extensibility.modules.WebSessionTrackingTelemetryModule"/>
<Add type="com.microsoft.applicationinsights.web.extensibility.modules.WebUserTrackingTelemetryModule"/>
</TelemetryModules>
<!-- Events correlation (not required for bare API) -->
<!-- These initializers add context data to each event -->
<TelemetryInitializers>
<Add type="com.microsoft.applicationinsights.web.extensibility.initializers.WebOperationIdTelemetryInitializer"/>
<Add type="com.microsoft.applicationinsights.web.extensibility.initializers.WebOperationNameTelemetryInitializer"/>
<Add type="com.microsoft.applicationinsights.web.extensibility.initializers.WebSessionTelemetryInitializer"/>
<Add type="com.microsoft.applicationinsights.web.extensibility.initializers.WebUserTelemetryInitializer"/>
<Add type="com.microsoft.applicationinsights.web.extensibility.initializers.WebUserAgentTelemetryInitializer"/>
<Add type="com.microsoft.applicationinsights.web.extensibility.initializers.WebSyntheticRequestTelemetryInitializer"/>
</TelemetryInitializers>
</ApplicationInsights>

Related

Is it possible to log windows events to application insights?

We're running Application Insights on some of our sites and we want to aggregate logs from the windows event log. We are running on windows server 2016.
I know that other log-shippers like elastic has the possibility to send logs from the windows event log. Is it possible from Application Insights?
Edit 22.10.2018
After #cijothomas's comment I tried adding the EtwCollector nuget package from Microsoft and added a few providers to the config.
<Add ProviderName="Microsoft-Windows-Crashdump" Level="Warning"/>
<Add ProviderName=".NET Common Language Runtime" Level="Warning" />
<Add ProviderName="ASP.NET Events" Level="Warning" />
<Add ProviderName="Microsoft-Windows-IIS-IISReset" Level="Warning" />
<Add ProviderName="Microsoft-Windows-HttpLog" Level="Warning" />
In Application Insights, I now get a trace from the application.
AI: Failed to enable provider for the EtwTelemetryModule. Access Denied.
and for example for the Microsoft-Windows-IIS-IISReset provider.
AI: Failed to enable provider Microsoft-Windows-IIS-IISReset for the EtwTelemetryModule.
I've added the applications user process to the "Performance Log Users" group in windows. Is it any other setting that I need to add to allow the logs to be shipped from this provider?
Did you mean ETW events? if yes, then Application Insights has an adapter to send ETW events as Application Insights Traces.
https://learn.microsoft.com/en-us/azure/application-insights/app-insights-asp-net-trace-logs#using-etw-events
Alternately, you can always do manual TrackTrace() method to send any traces to Application Insights.
https://learn.microsoft.com/en-us/azure/application-insights/app-insights-api-custom-events-metrics#tracktrace

Sending JSON between localhost ports

I had an ASP.NET MVC app running on port 8799 that posted JSON data via an XMLHttpRequest to an MVC controller handler. This pipeline was working perfectly fine.
I recently spun up a second app, this time an Express app running on port 8080, that again posts JSON in the same way (same exact code, using again an XMLHttpRequest), to the same MVC controller running on port 8799. This time, however, it appears as though while the request is received by the controller, there is no data on it.
I'm wondering if this is because I am making a cross-origin request between these two ports. Going off of this hypothesis, I added the following custom headers to my web.config file:
<customHeaders>
<add name="Access-Control-Allow-Origin" value="http://localhost" />
<add name="Access-Control-Allow-Headers" value="X-AspNet-Version,X-Powered-By,Date,Server,Accept,Accept-Encoding,Accept-Language,Cache-Control,Connection,Content-Length,Content-Type,Host,Origin,Pragma,Referer,User-Agent" />
<add name="Access-Control-Allow-Methods" value="GET, PUT, POST, DELETE, OPTIONS" />
<add name="Access-Control-Max-Age" value="1000" />
</customHeaders>
This does not seem to solve the issue. How can I debug this problem, I don't seem to be throwing any particularly useful exceptions?
The issue did turn out to be CORS. For whatever reason the web.config file was not being used by my .NET application. Thus, I setup CORS setting in my Startup.cs file instead, using services.AddCors() in my Configure() call.

ASP.NET Profile Properties returning another users results

I am using ASP.NET profile properties in .NET framework 2.0 application.
Hosting: On Amanzon server
Operating System: Windows Server 2012
Sql Server : 2012
IIS: 8.5
Profile Properties are anonymous users
What is happening with the end users (not able to replicate myself) that the end users are seeing the profile properties of another user
Example Say i have country USA set in my profile property
Next time i visit the webpage it may show some another Country which may be set by another user.
In IIS currently User Mode caching and Kerner Mode Caching enable.
Additionally:
I recently change the hosting means moved to another server so is that anything to do
with properties of anonymous users or do i need to clean all of the current profile users
data which i am scare of
Code:
<profile enabled="true" defaultProvider="AspNetSqlProfileProvider">
<properties>
<add name="ActionRemember" allowAnonymous="true" />
<add name="ActionName" allowAnonymous="true" />
/// huge list of properties .......
</properties>
<providers>
<remove name="AspNetSqlProfileProvider" />
<add name="AspNetSqlProfileProvider" connectionStringName="LocalSql2005Server" applicationName="/" type="System.Web.Profile.SqlProfileProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</providers>
</profile>
Open to give you more details..
Update: I disabled Kernel Caching for the aspx page and the error still persists
Static variables retain their values across user sessions.
You will run in concurrency issues as more than one thread servicing a request can modify the value of the variable.
What happens if there are 2 users simultaneously logged in from two
computers, User 1 sets the value as 100, then User 2 sets the value as
200. after that user 1 invokes the Get Value button.
What will he see as the value?
The user will see 200 afterwards.
I added a link for additional information here

I set up my SDL Tridion 2011 instance to run with multiple host headers and now the Core Service doesn't work. How do I fix it?

I recently configured my SDL Tridion 2011 CME to use multiple host headers. To enable the CME to load I set WCF.RedirectTo in the appropriate web.config. However, my Core Service no longer works. I get the following error:
WebHost failed to process a request.
Sender Information: System.ServiceModel.ServiceHostingEnvironment+HostingManager/63835064
Exception: System.ServiceModel.ServiceActivationException: The service '/webservices/CoreService.svc' cannot be activated due to an exception during compilation. The exception message is: This collection already contains an address with scheme http. There can be at most one address per scheme in this collection. If your service is being hosted in IIS you can fix the problem by setting 'system.serviceModel/serviceHostingEnvironment/multipleSiteBindingsEnabled' to true or specifying 'system.serviceModel/serviceHostingEnvironment/baseAddressPrefixFilters'.
Parameter name: item. ---> System.ArgumentException: This collection already contains an address with scheme http. There can be at most one address per scheme in this collection. If your service is being hosted in IIS you can fix the problem by setting 'system.serviceModel/serviceHostingEnvironment/multipleSiteBindingsEnabled' to true or specifying 'system.serviceModel/serviceHostingEnvironment/baseAddressPrefixFilters'.
How do I fix this?
You can enabled the multiple site bindings by editing the web.config for the Tridion UI and the Core Service:
Open the web.config in [Tridion Install Folder]\web\WebUI\WebRoot\
Find the serviceHostingEnvironment section Add a new attribute to that node for multipleSiteBindingsEnabled="true"
This should then look like <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true">
Save the file
Open the web.config in [Tridion Install Folder]\webservices\
Find the serviceHostingEnvironment section
Add a new attribute to that node for multipleSiteBindingsEnabled="true" This should then look like <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true">
Save the file
If you don't want to enable it for all URL's you can enable it for specific ones like:
<system.serviceModel>
<serviceHostingEnvironment>
<baseAddressPrefixFilters>
<add prefix="http://test1.tridion.com"/>
<add prefix="http://test2.tridion.com"/>
</baseAddressPrefixFilters>
</serviceHostingEnvironment>
</system.serviceModel>

Encrypting custom configuration settings

I'm having some troubles encrypting a configuration section. We use a package from an external supplier and the web.config is structured in the following way:
web.config
<appSettings file="customSettings.config">
<add key="generic_setting" value="true"/>
<add key="another_generic_setting" value="false"/>
</appSettings>
customSettings.config
<appSettings>
<add key="company_db_username" value="sa"/>
<add key="company_db_password" value="secret"/>
</appSettings>
We use WiX to create an installation package (msi) so we can deploy this in our organization. One custom action we execute is the encryption of the appSettings section. In the situation depicted above it unfortunately only encrypts the section in the web.config file and leaves the customSettings.config untouched.
I did notice that the configSource attribute works a bit better with encryption than the file attribute, but it doesn't support merging elements from both files. Now I could programmatically merge the elements of the customSettings.config into web.config before I encrypt everything in the custom action, but I was wondering if there is a cleaner solution to this.
Based on your example, where the information you're encrypting is a DB username and password, one alternative is to use Windows Authentication to connect to your DB the first time. The initial user would have very restricted rights.
Use that connection to obtain the credentials / connection string for a higher-privilege account, which you have previously stored using item-level DB encryption (see OPEN SYMMETRIC KEY and ENCRYPTBYKEY).

Resources