Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into application-metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
felixbarny committed Dec 13, 2018
1 parent 37a551b commit 93d1e42
Show file tree
Hide file tree
Showing 36 changed files with 1,053 additions and 217 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ dependency-reduced-pom.xml
*.iml
.DS_Store
html_docs
docs/html/
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# next

## Features
* Added `capture_headers` configuration option.
Set to `false` to disable capturing request and response headers.
This will reduce the allocation rate of the agent and can save you network bandwidth and disk space.
* Makes the API methods `addTag`, `setName`, `setType`, `setUser` and `setResult` fluent, so that calls can be chained.

## Bug Fixes

Expand Down
296 changes: 296 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,296 @@
#!/usr/bin/env groovy

pipeline {
agent none
environment {
BASE_DIR="src/github.com/elastic/apm-agent-java"
}
options {
timeout(time: 1, unit: 'HOURS')
buildDiscarder(logRotator(numToKeepStr: '20', artifactNumToKeepStr: '20', daysToKeepStr: '30'))
timestamps()
ansiColor('xterm')
disableResume()
durabilityHint('PERFORMANCE_OPTIMIZED')
}
parameters {
string(name: 'MAVEN_CONFIG', defaultValue: "-B -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn", description: "Additional maven options.")
booleanParam(name: 'Run_As_Master_Branch', defaultValue: false, description: 'Allow to run any steps on a PR, some steps normally only run on master branch.')
booleanParam(name: 'test_ci', defaultValue: true, description: 'Enable test')
booleanParam(name: 'smoketests_ci', defaultValue: true, description: 'Enable Smoke tests')
booleanParam(name: 'bench_ci', defaultValue: true, description: 'Enable benchmarks')
booleanParam(name: 'doc_ci', defaultValue: true, description: 'Enable build documentation')
}

stages {
stage('Initializing'){
agent { label 'linux && immutable' }
options { skipDefaultCheckout() }
environment {
HOME = "${env.WORKSPACE}"
JAVA_HOME = "${env.HUDSON_HOME}/.java/java10"
PATH = "${env.JAVA_HOME}/bin:${env.PATH}"
MAVEN_CONFIG = "${params.MAVEN_CONFIG}"
}
stages(){
/**
Checkout the code and stash it, to use it on other stages.
*/
stage('Checkout') {
steps {
gitCheckout(basedir: "${BASE_DIR}")
stash allowEmpty: true, name: 'source', useDefaultExcludes: false
}
}
/**
Build on a linux environment.
*/
stage('build') {
steps {
withEnvWrapper() {
unstash 'source'
dir("${BASE_DIR}"){
sh """#!/bin/bash
set -euxo pipefail
./mvnw clean package -DskipTests=true -Dmaven.javadoc.skip=true
"""
}
stash allowEmpty: true, name: 'build', useDefaultExcludes: false
}
}
}
}
}
stage('Tests') {
failFast true
parallel {
/**
Run only unit test.
*/
stage('Unit Tests') {
agent { label 'linux && immutable' }
options { skipDefaultCheckout() }
environment {
HOME = "${env.WORKSPACE}"
JAVA_HOME = "${env.HUDSON_HOME}/.java/java10"
PATH = "${env.JAVA_HOME}/bin:${env.PATH}"
}
when {
beforeAgent true
expression { return params.test_ci }
}
steps {
withEnvWrapper() {
unstash 'build'
dir("${BASE_DIR}"){
sh """#!/bin/bash
set -euxo pipefail
./mvnw test
"""
}
}
}
post {
always {
junit(allowEmptyResults: true,
keepLongStdio: true,
testResults: "${BASE_DIR}/**/junit-*.xml,${BASE_DIR}/**/TEST-*.xml")
codecov(repo: 'apm-agent-java', basedir: "${BASE_DIR}")
}
}
}
/**
Run smoke tests for different servers and databases.
*/
stage('Smoke Tests 01') {
agent { label 'linux && immutable' }
options { skipDefaultCheckout() }
environment {
HOME = "${env.WORKSPACE}"
JAVA_HOME = "${env.HUDSON_HOME}/.java/java10"
PATH = "${env.JAVA_HOME}/bin:${env.PATH}"
}
when {
beforeAgent true
expression { return params.smoketests_ci }
}
steps {
withEnvWrapper() {
unstash 'build'
dir("${BASE_DIR}"){
sh './scripts/jenkins/smoketests-01.sh'
}
}
}
post {
always {
junit(allowEmptyResults: true,
keepLongStdio: true,
testResults: "${BASE_DIR}/**/junit-*.xml,${BASE_DIR}/**/TEST-*.xml")
codecov(repo: 'apm-agent-java', basedir: "${BASE_DIR}")
}
}
}
/**
Run smoke tests for different servers and databases.
*/
stage('Smoke Tests 02') {
agent { label 'linux && immutable' }
options { skipDefaultCheckout() }
environment {
HOME = "${env.WORKSPACE}"
JAVA_HOME = "${env.HUDSON_HOME}/.java/java10"
PATH = "${env.JAVA_HOME}/bin:${env.PATH}"
}
when {
beforeAgent true
expression { return params.smoketests_ci }
}
steps {
withEnvWrapper() {
unstash 'build'
dir("${BASE_DIR}"){
sh './scripts/jenkins/smoketests-02.sh'
}
}
}
post {
always {
junit(allowEmptyResults: true,
keepLongStdio: true,
testResults: "${BASE_DIR}/**/junit-*.xml,${BASE_DIR}/**/TEST-*.xml")
codecov(repo: 'apm-agent-java', basedir: "${BASE_DIR}")
}
}
}
/**
Run the benchmarks and store the results on ES.
The result JSON files are also archive into Jenkins.
*/
stage('Benchmarks') {
agent { label 'metal' }
options { skipDefaultCheckout() }
environment {
HOME = "${env.WORKSPACE}"
JAVA_HOME = "${env.HUDSON_HOME}/.java/java10"
PATH = "${env.JAVA_HOME}/bin:${env.PATH}"
NO_BUILD = "true"
}
when {
beforeAgent true
allOf {
anyOf {
not {
changeRequest()
}
branch 'master'
branch "\\d+\\.\\d+"
branch "v\\d?"
tag "v\\d+\\.\\d+\\.\\d+*"
expression { return params.Run_As_Master_Branch }
}
expression { return params.bench_ci }
}
}
steps {
withEnvWrapper() {
unstash 'build'
dir("${BASE_DIR}"){
script {
env.COMMIT_ISO_8601 = sh(script: 'git log -1 -s --format=%cI', returnStdout: true).trim()
env.NOW_ISO_8601 = sh(script: 'date -u "+%Y-%m-%dT%H%M%SZ"', returnStdout: true).trim()
env.RESULT_FILE = "apm-agent-benchmark-results-${env.COMMIT_ISO_8601}.json"
env.BULK_UPLOAD_FILE = "apm-agent-bulk-${env.NOW_ISO_8601}.json"
}
sh './scripts/jenkins/run-benchmarks.sh'
}
}
}
post {
always {
archiveArtifacts(allowEmptyArchive: true,
artifacts: "${BASE_DIR}/${RESULT_FILE}",
onlyIfSuccessful: false)
sendBenchmarks(file: "${BASE_DIR}/${BULK_UPLOAD_FILE}", index: "benchmark-java")
}
}
}
/**
Build javadoc files.
*/
stage('Javadoc') {
agent { label 'linux && immutable' }
options { skipDefaultCheckout() }
environment {
HOME = "${env.WORKSPACE}"
JAVA_HOME = "${env.HUDSON_HOME}/.java/java10"
PATH = "${env.JAVA_HOME}/bin:${env.PATH}"
}
when {
beforeAgent true
expression { return params.doc_ci }
}
steps {
withEnvWrapper() {
unstash 'build'
dir("${BASE_DIR}"){
sh """#!/bin/bash
set -euxo pipefail
./mvnw compile javadoc:javadoc
"""
}
}
}
}
}
}
/**
Build the documentation.
*/
stage('Documentation') {
options { skipDefaultCheckout() }
environment {
HOME = "${env.WORKSPACE}"
JAVA_HOME = "${env.HUDSON_HOME}/.java/java10"
PATH = "${env.JAVA_HOME}/bin:${env.PATH}"
ELASTIC_DOCS = "${env.WORKSPACE}/elastic/docs"
}
when {
beforeAgent true
allOf {
branch 'master'
expression { return params.doc_ci }
}
}
steps {
withEnvWrapper() {
unstash 'source'
checkoutElasticDocsTools(basedir: "${ELASTIC_DOCS}")
dir("${BASE_DIR}"){
sh './scripts/jenkins/docs.sh'
}
}
}
post{
success {
tar(file: "doc-files.tgz", archive: true, dir: "html", pathPrefix: "${BASE_DIR}/docs")
}
}
}
}
post {
success {
echoColor(text: '[SUCCESS]', colorfg: 'green', colorbg: 'default')
}
aborted {
echoColor(text: '[ABORTED]', colorfg: 'magenta', colorbg: 'default')
}
failure {
echoColor(text: '[FAILURE]', colorfg: 'red', colorbg: 'default')
//step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${NOTIFY_TO}", sendToIndividuals: false])
}
unstable {
echoColor(text: '[UNSTABLE]', colorfg: 'yellow', colorbg: 'default')
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
package co.elastic.apm.api;

import javax.annotation.Nonnull;

public abstract class AbstractSpanImpl implements Span {
@Nonnull
// co.elastic.apm.impl.transaction.AbstractSpan
protected final Object span;

AbstractSpanImpl(@Nonnull Object span) {
this.span = span;
}

@Nonnull
@Override
public Span createSpan() {
Object span = doCreateSpan();
return span != null ? new SpanImpl(span) : NoopSpan.INSTANCE;
}

private Object doCreateSpan() {
// co.elastic.apm.agent.plugin.api.AbstractSpanInstrumentation$DoCreateSpanInstrumentation.doCreateSpan
return null;
}

void doSetName(String name) {
// co.elastic.apm.agent.plugin.api.AbstractSpanInstrumentation$SetNameInstrumentation.doSetName
}

void doSetType(String type) {
// co.elastic.apm.agent.plugin.api.AbstractSpanInstrumentation$SetTypeInstrumentation.doSetType
}

void doAddTag(String key, String value) {
// co.elastic.apm.agent.plugin.api.AbstractSpanInstrumentation$AddTagInstrumentation.doAddTag
}

@Override
public void end() {
// co.elastic.apm.agent.plugin.api.AbstractSpanInstrumentation$EndInstrumentation.end
}

@Override
public void captureException(Throwable throwable) {
// co.elastic.apm.agent.plugin.api.AbstractSpanInstrumentation.CaptureExceptionInstrumentation
}

@Nonnull
@Override
public String getId() {
// co.elastic.apm.agent.plugin.api.AbstractSpanInstrumentation.GetIdInstrumentation
return "";
}

@Nonnull
@Override
public String getTraceId() {
// co.elastic.apm.agent.plugin.api.AbstractSpanInstrumentation.GetTraceIdInstrumentation
return "";
}

@Override
public Scope activate() {
// co.elastic.apm.agent.plugin.api.AbstractSpanInstrumentation.ActivateInstrumentation
return new ScopeImpl(span);
}

@Override
public boolean isSampled() {
// co.elastic.apm.agent.plugin.api.AbstractSpanInstrumentation.IsSampledInstrumentation
return false;
}
}
Loading

0 comments on commit 93d1e42

Please sign in to comment.