Skip to content

Commit 777b427

Browse files
authored
Fix newlines (#1505)
* gitattributes * Fix newlines
1 parent 5a75d6d commit 777b427

File tree

19 files changed

+1792
-1789
lines changed

19 files changed

+1792
-1789
lines changed

.gitattributes

+4-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
*.sh text eol=lf
1+
* text=auto eol=lf
2+
3+
*.bat text eol=crlf
4+
*.cmd text eol=crlf
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,54 @@
1-
package com.microsoft.applicationinsights.agent.bootstrap.diagnostics;
2-
3-
import java.util.Arrays;
4-
import java.util.Iterator;
5-
6-
public class ApplicationMetadataFactory implements Iterable<DiagnosticsValueFinder> {
7-
8-
private final DiagnosticsValueFinder[] finders = new DiagnosticsValueFinder[] {
9-
new AgentExtensionVersionFinder(), // 0
10-
new InstrumentationKeyFinder(), // 1
11-
new MachineNameFinder(), // 2
12-
new PidFinder(), // 3
13-
new SiteNameFinder(), // 4
14-
new SubscriptionIdFinder(), // 5
15-
new SdkVersionFinder(), // 6
16-
};
17-
18-
19-
ApplicationMetadataFactory() {}
20-
21-
public DiagnosticsValueFinder getExtensionVersion() {
22-
return finders[0];
23-
}
24-
25-
public DiagnosticsValueFinder getInstrumentationKey() {
26-
return finders[1];
27-
}
28-
29-
public DiagnosticsValueFinder getMachineName() {
30-
return finders[2];
31-
}
32-
33-
public DiagnosticsValueFinder getPid() {
34-
return finders[3];
35-
}
36-
37-
public DiagnosticsValueFinder getSiteName() {
38-
return finders[4];
39-
}
40-
41-
public DiagnosticsValueFinder getSubscriptionId() {
42-
return finders[5];
43-
}
44-
45-
public DiagnosticsValueFinder getSdkVersion() {
46-
return finders[6];
47-
}
48-
49-
@Override
50-
public Iterator<DiagnosticsValueFinder> iterator() {
51-
return Arrays.asList(finders).iterator();
52-
}
53-
1+
package com.microsoft.applicationinsights.agent.bootstrap.diagnostics;
2+
3+
import java.util.Arrays;
4+
import java.util.Iterator;
5+
6+
public class ApplicationMetadataFactory implements Iterable<DiagnosticsValueFinder> {
7+
8+
private final DiagnosticsValueFinder[] finders = new DiagnosticsValueFinder[] {
9+
new AgentExtensionVersionFinder(), // 0
10+
new InstrumentationKeyFinder(), // 1
11+
new MachineNameFinder(), // 2
12+
new PidFinder(), // 3
13+
new SiteNameFinder(), // 4
14+
new SubscriptionIdFinder(), // 5
15+
new SdkVersionFinder(), // 6
16+
};
17+
18+
19+
ApplicationMetadataFactory() {}
20+
21+
public DiagnosticsValueFinder getExtensionVersion() {
22+
return finders[0];
23+
}
24+
25+
public DiagnosticsValueFinder getInstrumentationKey() {
26+
return finders[1];
27+
}
28+
29+
public DiagnosticsValueFinder getMachineName() {
30+
return finders[2];
31+
}
32+
33+
public DiagnosticsValueFinder getPid() {
34+
return finders[3];
35+
}
36+
37+
public DiagnosticsValueFinder getSiteName() {
38+
return finders[4];
39+
}
40+
41+
public DiagnosticsValueFinder getSubscriptionId() {
42+
return finders[5];
43+
}
44+
45+
public DiagnosticsValueFinder getSdkVersion() {
46+
return finders[6];
47+
}
48+
49+
@Override
50+
public Iterator<DiagnosticsValueFinder> iterator() {
51+
return Arrays.asList(finders).iterator();
52+
}
53+
5454
}
Original file line numberDiff line numberDiff line change
@@ -1,125 +1,125 @@
1-
/*
2-
* ApplicationInsights-Java
3-
* Copyright (c) Microsoft Corporation
4-
* All rights reserved.
5-
*
6-
* MIT License
7-
* Permission is hereby granted, free of charge, to any person obtaining a copy of this
8-
* software and associated documentation files (the ""Software""), to deal in the Software
9-
* without restriction, including without limitation the rights to use, copy, modify, merge,
10-
* publish, distribute, sublicense, and/or sell copies of the Software, and to permit
11-
* persons to whom the Software is furnished to do so, subject to the following conditions:
12-
* The above copyright notice and this permission notice shall be included in all copies or
13-
* substantial portions of the Software.
14-
* THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
15-
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
16-
* PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
17-
* FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
18-
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
19-
* DEALINGS IN THE SOFTWARE.
20-
*/
21-
package com.microsoft.applicationinsights.agent.bootstrap.diagnostics.etw;
22-
23-
import java.util.Map;
24-
25-
import com.microsoft.applicationinsights.agent.bootstrap.diagnostics.ApplicationMetadataFactory;
26-
import com.microsoft.applicationinsights.agent.bootstrap.diagnostics.DiagnosticsHelper;
27-
import com.microsoft.applicationinsights.agent.bootstrap.diagnostics.etw.events.IpaError;
28-
import com.microsoft.applicationinsights.agent.bootstrap.diagnostics.etw.events.IpaInfo;
29-
import com.microsoft.applicationinsights.agent.bootstrap.diagnostics.etw.events.IpaVerbose;
30-
import com.microsoft.applicationinsights.agent.bootstrap.diagnostics.etw.events.IpaWarn;
31-
import com.microsoft.applicationinsights.agent.bootstrap.diagnostics.etw.events.model.IpaEtwEventBase;
32-
import com.microsoft.applicationinsights.agent.bootstrap.diagnostics.status.StatusFile;
33-
34-
import org.slf4j.LoggerFactory;
35-
36-
import ch.qos.logback.classic.Level;
37-
import ch.qos.logback.classic.spi.ILoggingEvent;
38-
import ch.qos.logback.classic.spi.ThrowableProxyUtil;
39-
import ch.qos.logback.core.AppenderBase;
40-
41-
public class EtwAppender extends AppenderBase<ILoggingEvent> {
42-
private final EtwProvider etwProvider;
43-
private final IpaEtwEventBase proto;
44-
45-
public EtwAppender() {
46-
ApplicationMetadataFactory metadata = DiagnosticsHelper.getMetadataFactory();
47-
48-
proto = new IpaInfo();
49-
proto.setAppName(metadata.getSiteName().getValue());
50-
proto.setExtensionVersion(metadata.getSdkVersion().getValue());
51-
proto.setSubscriptionId(metadata.getSubscriptionId().getValue());
52-
53-
etwProvider = new EtwProvider(metadata.getSdkVersion().getValue());
54-
}
55-
56-
@Override
57-
public void start() {
58-
IpaVerbose event = new IpaVerbose(proto);
59-
event.setMessageFormat("EtwProvider initialized sucessfully.");
60-
try {
61-
this.etwProvider.writeEvent(event);
62-
} catch (LinkageError | ApplicationInsightsEtwException e) {
63-
final String message = "EtwProvider failed to initialize.";
64-
LoggerFactory.getLogger(DiagnosticsHelper.DIAGNOSTICS_LOGGER_NAME).error(message, e);
65-
addError(message, e);
66-
67-
StatusFile.putValue("EtwProviderInitialized", "false");
68-
StatusFile.putValue("EtwProviderError", e.getLocalizedMessage());
69-
StatusFile.write();
70-
71-
return; // appender fails to start
72-
}
73-
74-
StatusFile.putValueAndWrite("EtwProviderInitialized", "true");
75-
super.start();
76-
}
77-
78-
@Override
79-
protected void append(ILoggingEvent logEvent) {
80-
String logger = logEvent.getLoggerName();
81-
if (logger != null && logger.startsWith("com.microsoft.applicationinsights.agent.bootstrap.diagnostics.etw.")) {
82-
addWarn("Skipping attempt to log to "+logger);
83-
return;
84-
}
85-
86-
Level level = logEvent.getLevel();
87-
IpaEtwEventBase event;
88-
// empty if no throwable
89-
switch (level.levelInt) {
90-
case Level.ERROR_INT:
91-
IpaError error = new IpaError(proto);
92-
error.setStacktrace(ThrowableProxyUtil.asString(logEvent.getThrowableProxy()));
93-
event = error;
94-
break;
95-
case Level.WARN_INT:
96-
IpaWarn warn = new IpaWarn(proto);
97-
warn.setStacktrace(ThrowableProxyUtil.asString(logEvent.getThrowableProxy()));
98-
event = warn;
99-
break;
100-
case Level.INFO_INT:
101-
event = new IpaInfo(proto);
102-
break;
103-
default:
104-
addWarn("Unsupported log level: " + level.levelStr);
105-
return;
106-
}
107-
108-
Map<String, String> mdcPropertyMap = logEvent.getMDCPropertyMap();
109-
if (!mdcPropertyMap.isEmpty()) {
110-
String operation = mdcPropertyMap.get(DiagnosticsHelper.MDC_PROP_OPERATION);
111-
if (operation != null && !operation.isEmpty()) {
112-
event.setOperation(operation);
113-
}
114-
}
115-
event.setLogger(logger);
116-
event.setMessageFormat(logEvent.getMessage());
117-
event.setMessageArgs(logEvent.getArgumentArray());
118-
try {
119-
etwProvider.writeEvent(event);
120-
} catch (ApplicationInsightsEtwException e) {
121-
addError("Exception from EtwProvider: " + e.getLocalizedMessage(), e);
122-
}
123-
}
124-
1+
/*
2+
* ApplicationInsights-Java
3+
* Copyright (c) Microsoft Corporation
4+
* All rights reserved.
5+
*
6+
* MIT License
7+
* Permission is hereby granted, free of charge, to any person obtaining a copy of this
8+
* software and associated documentation files (the ""Software""), to deal in the Software
9+
* without restriction, including without limitation the rights to use, copy, modify, merge,
10+
* publish, distribute, sublicense, and/or sell copies of the Software, and to permit
11+
* persons to whom the Software is furnished to do so, subject to the following conditions:
12+
* The above copyright notice and this permission notice shall be included in all copies or
13+
* substantial portions of the Software.
14+
* THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
15+
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
16+
* PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
17+
* FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
18+
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
19+
* DEALINGS IN THE SOFTWARE.
20+
*/
21+
package com.microsoft.applicationinsights.agent.bootstrap.diagnostics.etw;
22+
23+
import java.util.Map;
24+
25+
import com.microsoft.applicationinsights.agent.bootstrap.diagnostics.ApplicationMetadataFactory;
26+
import com.microsoft.applicationinsights.agent.bootstrap.diagnostics.DiagnosticsHelper;
27+
import com.microsoft.applicationinsights.agent.bootstrap.diagnostics.etw.events.IpaError;
28+
import com.microsoft.applicationinsights.agent.bootstrap.diagnostics.etw.events.IpaInfo;
29+
import com.microsoft.applicationinsights.agent.bootstrap.diagnostics.etw.events.IpaVerbose;
30+
import com.microsoft.applicationinsights.agent.bootstrap.diagnostics.etw.events.IpaWarn;
31+
import com.microsoft.applicationinsights.agent.bootstrap.diagnostics.etw.events.model.IpaEtwEventBase;
32+
import com.microsoft.applicationinsights.agent.bootstrap.diagnostics.status.StatusFile;
33+
34+
import org.slf4j.LoggerFactory;
35+
36+
import ch.qos.logback.classic.Level;
37+
import ch.qos.logback.classic.spi.ILoggingEvent;
38+
import ch.qos.logback.classic.spi.ThrowableProxyUtil;
39+
import ch.qos.logback.core.AppenderBase;
40+
41+
public class EtwAppender extends AppenderBase<ILoggingEvent> {
42+
private final EtwProvider etwProvider;
43+
private final IpaEtwEventBase proto;
44+
45+
public EtwAppender() {
46+
ApplicationMetadataFactory metadata = DiagnosticsHelper.getMetadataFactory();
47+
48+
proto = new IpaInfo();
49+
proto.setAppName(metadata.getSiteName().getValue());
50+
proto.setExtensionVersion(metadata.getSdkVersion().getValue());
51+
proto.setSubscriptionId(metadata.getSubscriptionId().getValue());
52+
53+
etwProvider = new EtwProvider(metadata.getSdkVersion().getValue());
54+
}
55+
56+
@Override
57+
public void start() {
58+
IpaVerbose event = new IpaVerbose(proto);
59+
event.setMessageFormat("EtwProvider initialized sucessfully.");
60+
try {
61+
this.etwProvider.writeEvent(event);
62+
} catch (LinkageError | ApplicationInsightsEtwException e) {
63+
final String message = "EtwProvider failed to initialize.";
64+
LoggerFactory.getLogger(DiagnosticsHelper.DIAGNOSTICS_LOGGER_NAME).error(message, e);
65+
addError(message, e);
66+
67+
StatusFile.putValue("EtwProviderInitialized", "false");
68+
StatusFile.putValue("EtwProviderError", e.getLocalizedMessage());
69+
StatusFile.write();
70+
71+
return; // appender fails to start
72+
}
73+
74+
StatusFile.putValueAndWrite("EtwProviderInitialized", "true");
75+
super.start();
76+
}
77+
78+
@Override
79+
protected void append(ILoggingEvent logEvent) {
80+
String logger = logEvent.getLoggerName();
81+
if (logger != null && logger.startsWith("com.microsoft.applicationinsights.agent.bootstrap.diagnostics.etw.")) {
82+
addWarn("Skipping attempt to log to "+logger);
83+
return;
84+
}
85+
86+
Level level = logEvent.getLevel();
87+
IpaEtwEventBase event;
88+
// empty if no throwable
89+
switch (level.levelInt) {
90+
case Level.ERROR_INT:
91+
IpaError error = new IpaError(proto);
92+
error.setStacktrace(ThrowableProxyUtil.asString(logEvent.getThrowableProxy()));
93+
event = error;
94+
break;
95+
case Level.WARN_INT:
96+
IpaWarn warn = new IpaWarn(proto);
97+
warn.setStacktrace(ThrowableProxyUtil.asString(logEvent.getThrowableProxy()));
98+
event = warn;
99+
break;
100+
case Level.INFO_INT:
101+
event = new IpaInfo(proto);
102+
break;
103+
default:
104+
addWarn("Unsupported log level: " + level.levelStr);
105+
return;
106+
}
107+
108+
Map<String, String> mdcPropertyMap = logEvent.getMDCPropertyMap();
109+
if (!mdcPropertyMap.isEmpty()) {
110+
String operation = mdcPropertyMap.get(DiagnosticsHelper.MDC_PROP_OPERATION);
111+
if (operation != null && !operation.isEmpty()) {
112+
event.setOperation(operation);
113+
}
114+
}
115+
event.setLogger(logger);
116+
event.setMessageFormat(logEvent.getMessage());
117+
event.setMessageArgs(logEvent.getArgumentArray());
118+
try {
119+
etwProvider.writeEvent(event);
120+
} catch (ApplicationInsightsEtwException e) {
121+
addError("Exception from EtwProvider: " + e.getLocalizedMessage(), e);
122+
}
123+
}
124+
125125
}

0 commit comments

Comments
 (0)