Skip to content

Commit

Permalink
Collect perf counters using Oshi (#1482)
Browse files Browse the repository at this point in the history
* Collect system.disk.io and total processor time using oshi java library

* Send old perf using JNI for testing purpose

* Address comments

* Use process io instead of disk.io

* Address feedback

* Use milliseconds to track elapsed seconds instead of nanoSeconds, which might end up negative values

* Fix total CPU processor time big diff from JNI

* Compute perf counter values during class startup

* Update oshi version

* Use system cpu

* Remove old windows jni perf counters

* Replace unix perf counters also

* Remove old unix counters

* Remove unused constants

* Unify windows and unix code

* Merge conflicts

Co-authored-by: Trask Stalnaker <trask.stalnaker@gmail.com>
  • Loading branch information
heyams and trask authored Mar 22, 2021
1 parent e5c8ce0 commit 457f4e2
Show file tree
Hide file tree
Showing 34 changed files with 144 additions and 1,994 deletions.
20 changes: 1 addition & 19 deletions .pipelines/pipeline.user.windows.buddy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,10 @@ version:
system: 'custom'
build:
commands:
- !!buildcommand
name: 'Assemble Perf Counters DLL'
command: '.scripts/gradle.cmd'
arguments: ':core:windowsSharedLibrary'
artifacts:
- from: 'core/build/libs/windows/shared'
include:
- '**/*'
exclude:
- '**/*.pdb'
signing_options:
profile: external_distribution
sign_inline: true
logs:
- to: 'PerfCounters DLL Build Logs'
from: 'core/build/tmp'
include:
- '*WindowsCpp/*'
- !!buildcommand
name: 'Assemble ApplicationInsights-Java JARs'
command: '.scripts/gradle.cmd'
arguments: 'assemble -Pcore.native.artifacts.prebuilt=true'
arguments: 'assemble'
artifacts:
- to: 'Artifacts'
include:
Expand Down
20 changes: 1 addition & 19 deletions .pipelines/pipeline.user.windows.official.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,10 @@ version:
system: 'custom'
build:
commands:
- !!buildcommand
name: 'Assemble Perf Counters DLL'
command: '.scripts/gradle.cmd'
arguments: ':core:windowsSharedLibrary'
artifacts:
- from: 'core/build/libs/windows/shared'
include:
- '**/*'
exclude:
- '**/*.pdb'
signing_options:
profile: external_distribution
sign_inline: true
logs:
- to: 'PerfCounters DLL Build Logs'
from: 'core/build/tmp'
include:
- '*WindowsCpp/*'
- !!buildcommand
name: 'Assemble ApplicationInsights-Java JARs'
command: '.scripts/gradle.cmd'
arguments: 'assemble -Pcore.native.artifacts.prebuilt=true -DisRelease=true -Pai.etw.native.build=release'
arguments: 'assemble -DisRelease=true -Pai.etw.native.build=release'
artifacts:
- to: 'Artifacts'
include:
Expand Down
8 changes: 0 additions & 8 deletions .pipelines/pipeline.user.windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,6 @@ static_analysis_options:
fail_on_error: true
restore:
commands:
- !!defaultcommand
name: 'Install Windows 8.1 SDK'
command: '.scripts/installWindows81Sdk.cmd'
logs:
- from: 'WinSdkInstall'
to: 'WinSdkInstall'
include:
- '**/*.log'
- !!defaultcommand
name: 'Install Windows 10 SDK'
command: '.scripts/installWindows10Sdk.cmd'
Expand Down
26 changes: 0 additions & 26 deletions .scripts/installWindows81Sdk.cmd

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ ch.qos.logback.contrib:logback-json-classic:0.1.5
ch.qos.logback.contrib:logback-json-core:0.1.5
ch.qos.logback:logback-classic:1.2.3
ch.qos.logback:logback-core:1.2.3
com.github.oshi:oshi-core:5.6.0
com.google.code.findbugs:jsr305:3.0.2
com.google.code.gson:gson:2.8.2
com.google.errorprone:error_prone_annotations:2.2.0
Expand Down Expand Up @@ -35,6 +36,8 @@ io.opentelemetry:opentelemetry-sdk-trace:1.0.0
io.opentelemetry:opentelemetry-sdk:1.0.0
io.opentelemetry:opentelemetry-semconv:1.0.1-alpha
net.bytebuddy:byte-buddy:1.10.10
net.java.dev.jna:jna-platform:5.7.0
net.java.dev.jna:jna:5.7.0
org.apache.commons:commons-lang3:3.11
org.apache.commons:commons-text:1.9
org.apache.httpcomponents:httpclient:4.5.13
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# Manual edits can break the build and are not advised.
# This file is expected to be part of source control.
com.blogspot.mydailyjava:weak-lock-free:0.15
com.github.oshi:oshi-core:5.6.0
com.google.auto.service:auto-service-annotations:1.0-rc7
com.google.auto.service:auto-service:1.0-rc7
com.google.auto:auto-common:0.10
Expand Down Expand Up @@ -43,6 +44,8 @@ io.prometheus:simpleclient_common:0.9.0
io.prometheus:simpleclient_httpserver:0.9.0
net.bytebuddy:byte-buddy-agent:1.10.18
net.bytebuddy:byte-buddy:1.10.18
net.java.dev.jna:jna-platform:5.7.0
net.java.dev.jna:jna:5.7.0
org.apache.commons:commons-lang3:3.11
org.apache.commons:commons-text:1.9
org.apache.httpcomponents:httpclient:4.5.13
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# This is a Gradle generated file for dependency locking.
# Manual edits can break the build and are not advised.
# This file is expected to be part of source control.
com.github.oshi:oshi-core:5.6.0
com.google.code.findbugs:jsr305:3.0.2
com.google.code.gson:gson:2.8.2
com.google.errorprone:error_prone_annotations:2.2.0
Expand All @@ -22,10 +23,12 @@ io.opentelemetry:opentelemetry-sdk-common:1.0.0
io.opentelemetry:opentelemetry-sdk-trace:1.0.0
io.opentelemetry:opentelemetry-sdk:1.0.0
io.opentelemetry:opentelemetry-semconv:1.0.1-alpha
net.java.dev.jna:jna-platform:5.7.0
net.java.dev.jna:jna:5.7.0
org.apache.commons:commons-lang3:3.11
org.apache.commons:commons-text:1.9
org.apache.httpcomponents:httpclient:4.5.13
org.apache.httpcomponents:httpcore:4.4.13
org.checkerframework:checker-compat-qual:2.5.2
org.codehaus.mojo:animal-sniffer-annotations:1.17
org.slf4j:slf4j-api:1.7.26
org.slf4j:slf4j-api:1.7.30
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# This is a Gradle generated file for dependency locking.
# Manual edits can break the build and are not advised.
# This file is expected to be part of source control.
com.github.oshi:oshi-core:5.6.0
com.google.code.findbugs:jsr305:3.0.2
com.google.code.gson:gson:2.8.2
com.google.errorprone:error_prone_annotations:2.2.0
Expand All @@ -21,10 +22,12 @@ io.opentelemetry:opentelemetry-sdk-common:1.0.0
io.opentelemetry:opentelemetry-sdk-trace:1.0.0
io.opentelemetry:opentelemetry-sdk:1.0.0
io.opentelemetry:opentelemetry-semconv:1.0.0-alpha
net.java.dev.jna:jna-platform:5.7.0
net.java.dev.jna:jna:5.7.0
org.apache.commons:commons-lang3:3.11
org.apache.commons:commons-text:1.9
org.apache.httpcomponents:httpclient:4.5.13
org.apache.httpcomponents:httpcore:4.4.13
org.checkerframework:checker-compat-qual:2.5.2
org.codehaus.mojo:animal-sniffer-annotations:1.17
org.slf4j:slf4j-api:1.7.26
org.slf4j:slf4j-api:1.7.30
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# This is a Gradle generated file for dependency locking.
# Manual edits can break the build and are not advised.
# This file is expected to be part of source control.
com.github.oshi:oshi-core:5.6.0
com.google.code.findbugs:jsr305:3.0.2
com.google.code.gson:gson:2.8.2
com.google.errorprone:error_prone_annotations:2.2.0
Expand Down Expand Up @@ -85,6 +86,8 @@ io.opentelemetry:opentelemetry-sdk-trace:1.0.0
io.opentelemetry:opentelemetry-sdk:1.0.0
io.opentelemetry:opentelemetry-semconv:1.0.1-alpha
net.bytebuddy:byte-buddy:1.10.10
net.java.dev.jna:jna-platform:5.7.0
net.java.dev.jna:jna:5.7.0
org.apache.commons:commons-lang3:3.11
org.apache.commons:commons-text:1.9
org.apache.httpcomponents:httpclient:4.5.13
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# Manual edits can break the build and are not advised.
# This file is expected to be part of source control.
com.blogspot.mydailyjava:weak-lock-free:0.15
com.github.oshi:oshi-core:5.6.0
com.google.auto.service:auto-service-annotations:1.0-rc7
com.google.auto.service:auto-service:1.0-rc7
com.google.auto:auto-common:0.10
Expand Down Expand Up @@ -104,6 +105,8 @@ io.prometheus:simpleclient_common:0.9.0
io.prometheus:simpleclient_httpserver:0.9.0
net.bytebuddy:byte-buddy-agent:1.10.18
net.bytebuddy:byte-buddy:1.10.18
net.java.dev.jna:jna-platform:5.7.0
net.java.dev.jna:jna:5.7.0
org.apache.commons:commons-lang3:3.11
org.apache.commons:commons-text:1.9
org.apache.httpcomponents:httpclient:4.5.13
Expand Down
32 changes: 1 addition & 31 deletions core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,37 +32,6 @@ sourceSets {
}
}

clean {
delete "${System.properties['java.io.tmpdir']}/AISDK/native" // see JniPCConnector.java for jni directory
}

// CURRENTLY the DLL being built on CI is not working, leading to this error on startup:
//
// ERROR c.m.a.i.perfcounter.JniPCConnector - Unexpected error initializing JNI Performance Counter library. Windows performance counters will not be used
// java.lang.UnsatisfiedLinkError: C:\Users\trstalna\AppData\Local\Temp\AISDK\native\3.0.0-PREVIEW.7-SNAPSHOT\applicationinsights-core-native-win64.dll: Can't find dependent libraries
//
// and native windows perf counters do not get collected
//
// so instead of building the DLLs, we are currently just copying the previously built DLLs from 2.6.2 which work fine
// (see copyTheDLL task below)

import org.apache.tools.ant.taskdefs.condition.Os

boolean skipWinNative = (System.properties['skipWinNative'] ?: 'false').toBoolean()
if (skipWinNative) {
logger.warn 'Windows native components will not be built: skipWinNative=true'
if (isRelease) {
logger.error 'skipWinNative=true and isRelease=true'
throw new GradleException('Cannot use skipWinNative=true and isRelease=true')
}
} else {
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
apply from: "native.gradle"
} else {
logger.warn("Native binaries build is only supported on Windows systems; native components will not be built.")
}
}

import com.microsoft.applicationinsights.build.tasks.PropsFileGen

archivesBaseName = 'applicationinsights-core'
Expand All @@ -83,6 +52,7 @@ dependencies {
compile ([group: 'com.google.code.gson', name: 'gson', version: '2.8.2'])
// update transitive dependency version
compile ([group: 'com.google.guava', name: 'guava', version: '27.1-android'])
compile ([group: 'com.github.oshi', name:'oshi-core',version:'5.6.0'])
compile 'org.slf4j:slf4j-api:1.7.26'
testCompile group: 'org.hamcrest', name:'hamcrest-core', version:'1.3'
testCompile group: 'org.hamcrest', name:'hamcrest-library', version:'1.3'
Expand Down
5 changes: 4 additions & 1 deletion core/gradle/dependency-locks/compileClasspath.lockfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# This is a Gradle generated file for dependency locking.
# Manual edits can break the build and are not advised.
# This file is expected to be part of source control.
com.github.oshi:oshi-core:5.6.0
com.google.code.findbugs:jsr305:3.0.2
com.google.code.gson:gson:2.8.2
com.google.errorprone:error_prone_annotations:2.2.0
Expand All @@ -14,10 +15,12 @@ commons-codec:commons-codec:1.11
commons-io:commons-io:2.6
commons-logging:commons-logging:1.2
eu.infomas:annotation-detector:3.0.5
net.java.dev.jna:jna-platform:5.7.0
net.java.dev.jna:jna:5.7.0
org.apache.commons:commons-lang3:3.11
org.apache.commons:commons-text:1.9
org.apache.httpcomponents:httpclient:4.5.13
org.apache.httpcomponents:httpcore:4.4.13
org.checkerframework:checker-compat-qual:2.5.2
org.codehaus.mojo:animal-sniffer-annotations:1.17
org.slf4j:slf4j-api:1.7.26
org.slf4j:slf4j-api:1.7.30
5 changes: 4 additions & 1 deletion core/gradle/dependency-locks/runtimeClasspath.lockfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# This is a Gradle generated file for dependency locking.
# Manual edits can break the build and are not advised.
# This file is expected to be part of source control.
com.github.oshi:oshi-core:5.6.0
com.google.code.findbugs:jsr305:3.0.2
com.google.code.gson:gson:2.8.2
com.google.errorprone:error_prone_annotations:2.2.0
Expand All @@ -14,10 +15,12 @@ commons-codec:commons-codec:1.11
commons-io:commons-io:2.6
commons-logging:commons-logging:1.2
eu.infomas:annotation-detector:3.0.5
net.java.dev.jna:jna-platform:5.7.0
net.java.dev.jna:jna:5.7.0
org.apache.commons:commons-lang3:3.11
org.apache.commons:commons-text:1.9
org.apache.httpcomponents:httpclient:4.5.13
org.apache.httpcomponents:httpcore:4.4.13
org.checkerframework:checker-compat-qual:2.5.2
org.codehaus.mojo:animal-sniffer-annotations:1.17
org.slf4j:slf4j-api:1.7.26
org.slf4j:slf4j-api:1.7.30
Loading

0 comments on commit 457f4e2

Please sign in to comment.