Basic tracing support for OpenShift (#11844)

Basic tracing support for OpenShift (#11844)
6.19.x
Sergii Kabashniuk 2018-11-09 14:42:52 +02:00 committed by GitHub
parent 410fe85414
commit 8a38002dd9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 517 additions and 2 deletions

View File

@ -59,6 +59,18 @@
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
</dependency>
<dependency>
<groupId>io.jaegertracing</groupId>
<artifactId>jaeger-client</artifactId>
</dependency>
<dependency>
<groupId>io.jaegertracing</groupId>
<artifactId>jaeger-core</artifactId>
</dependency>
<dependency>
<groupId>io.jaegertracing</groupId>
<artifactId>jaeger-tracerresolver</artifactId>
</dependency>
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
@ -221,6 +233,14 @@
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-sql-schema</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-tracing-core</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-tracing-web</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>wsagent</artifactId>

View File

@ -271,8 +271,11 @@ public class WsMasterModule extends AbstractModule {
}
bind(org.eclipse.che.api.user.server.AppStatesPreferenceCleaner.class);
MapBinder.newMapBinder(binder(), String.class, ChePluginsApplier.class);
if (Boolean.valueOf(System.getenv("CHE_TRACING_ENABLED"))) {
install(new org.eclipse.che.core.tracing.TracingModule());
}
}
private void configureSingleUserMode(Map<String, String> persistenceProperties) {

View File

@ -27,6 +27,11 @@ import org.everrest.guice.servlet.GuiceEverrestServlet;
public class WsMasterServletModule extends ServletModule {
@Override
protected void configureServlets() {
if (Boolean.valueOf(System.getenv("CHE_TRACING_ENABLED"))) {
install(new org.eclipse.che.core.tracing.web.TracingWebModule());
}
final Map<String, String> corsFilterParams = new HashMap<>();
corsFilterParams.put("cors.allowed.origins", "*");
corsFilterParams.put(

View File

@ -0,0 +1,50 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2012-2018 Red Hat, Inc.
This program and the accompanying materials are made
available under the terms of the Eclipse Public License 2.0
which is available at https://www.eclipse.org/legal/epl-2.0/
SPDX-License-Identifier: EPL-2.0
Contributors:
Red Hat, Inc. - initial API and implementation
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>che-core-parent</artifactId>
<groupId>org.eclipse.che.core</groupId>
<version>6.14.0-SNAPSHOT</version>
</parent>
<artifactId>che-core-tracing-core</artifactId>
<name>Che Core :: Tracing :: Core</name>
<dependencies>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
<dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
</dependency>
<dependency>
<groupId>io.opentracing</groupId>
<artifactId>opentracing-api</artifactId>
</dependency>
<dependency>
<groupId>io.opentracing</groupId>
<artifactId>opentracing-util</artifactId>
</dependency>
<dependency>
<groupId>io.opentracing.contrib</groupId>
<artifactId>opentracing-tracerresolver</artifactId>
</dependency>
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,40 @@
/*
* Copyright (c) 2012-2018 Red Hat, Inc.
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
package org.eclipse.che.core.tracing;
import com.google.common.annotations.Beta;
import io.opentracing.Tracer;
import io.opentracing.contrib.tracerresolver.TracerResolver;
import io.opentracing.util.GlobalTracer;
import javax.inject.Provider;
import javax.inject.Singleton;
/**
* Guice @{@link javax.inject.Provider} of @{@link io.opentracing.Tracer} objects. Register Tracer
* in @{@link io.opentracing.util.GlobalTracer} for future use by classes that has no access to
* container like datasources, etc.
*/
@Beta
@Singleton
public class TracerProvider implements Provider<Tracer> {
private final Tracer tracer;
public TracerProvider() {
this.tracer = TracerResolver.resolveTracer();
GlobalTracer.register(tracer);
}
@Override
public Tracer get() {
return tracer;
}
}

View File

@ -0,0 +1,24 @@
/*
* Copyright (c) 2012-2018 Red Hat, Inc.
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
package org.eclipse.che.core.tracing;
import com.google.common.annotations.Beta;
import com.google.inject.AbstractModule;
import io.opentracing.Tracer;
@Beta
public class TracingModule extends AbstractModule {
@Override
protected void configure() {
bind(Tracer.class).toProvider(TracerProvider.class);
}
}

View File

@ -0,0 +1,55 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2012-2018 Red Hat, Inc.
This program and the accompanying materials are made
available under the terms of the Eclipse Public License 2.0
which is available at https://www.eclipse.org/legal/epl-2.0/
SPDX-License-Identifier: EPL-2.0
Contributors:
Red Hat, Inc. - initial API and implementation
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>che-core-parent</artifactId>
<groupId>org.eclipse.che.core</groupId>
<version>6.14.0-SNAPSHOT</version>
</parent>
<artifactId>che-core-tracing-web</artifactId>
<name>Che Core :: Tracing :: Web</name>
<dependencies>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
<dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
</dependency>
<dependency>
<groupId>com.google.inject.extensions</groupId>
<artifactId>guice-servlet</artifactId>
</dependency>
<dependency>
<groupId>io.opentracing</groupId>
<artifactId>opentracing-api</artifactId>
</dependency>
<dependency>
<groupId>io.opentracing.contrib</groupId>
<artifactId>opentracing-web-servlet-filter</artifactId>
</dependency>
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,40 @@
/*
* Copyright (c) 2012-2018 Red Hat, Inc.
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
package org.eclipse.che.core.tracing.web;
import com.google.common.annotations.Beta;
import io.opentracing.Tracer;
import io.opentracing.contrib.web.servlet.filter.TracingFilter;
import javax.inject.Inject;
import javax.inject.Provider;
import javax.inject.Singleton;
/**
* Guice @{@link javax.inject.Provider} of @{@link
* io.opentracing.contrib.web.servlet.filter.TracingFilter} objects
*/
@Beta
@Singleton
public class TracingFilterProvider implements Provider<TracingFilter> {
private final TracingFilter filter;
@Inject
public TracingFilterProvider(Tracer tracer) {
filter = new TracingFilter(tracer);
}
@Override
public TracingFilter get() {
return filter;
}
}

View File

@ -0,0 +1,27 @@
/*
* Copyright (c) 2012-2018 Red Hat, Inc.
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
package org.eclipse.che.core.tracing.web;
import com.google.common.annotations.Beta;
import com.google.inject.servlet.ServletModule;
import io.opentracing.contrib.web.servlet.filter.TracingFilter;
import javax.inject.Singleton;
@Beta
public class TracingWebModule extends ServletModule {
@Override
protected void configureServlets() {
// tracing
bind(TracingFilter.class).toProvider(TracingFilterProvider.class).in(Singleton.class);
filter("/*").through(TracingFilter.class);
}
}

View File

@ -38,5 +38,7 @@
<module>che-core-db-vendor-h2</module>
<module>che-core-db-vendor-mysql</module>
<module>che-core-db-vendor-postgresql</module>
<module>che-core-tracing-core</module>
<module>che-core-tracing-web</module>
</modules>
</project>

View File

@ -161,6 +161,28 @@ export PLUGIN_REGISTRY_IMAGE_PULL_POLICY=${PLUGIN_REGISTRY_IMAGE_PULL_POLICY:-${
DEFAULT_PLUGIN__REGISTRY__URL="https://che-plugin-registry.openshift.io"
export PLUGIN__REGISTRY__URL=${PLUGIN__REGISTRY__URL:-${DEFAULT_PLUGIN__REGISTRY__URL}}
DEFAULT_CHE_TRACING_ENABLED="false"
export CHE_TRACING_ENABLED=${CHE_TRACING_ENABLED:-${DEFAULT_CHE_TRACING_ENABLED}}
DEFAULT_JAEGER_ENDPOINT="http://jaeger-collector:14268/api/traces"
export JAEGER_ENDPOINT=${JAEGER_ENDPOINT:-${DEFAULT_JAEGER_ENDPOINT}}
DEFAULT_JAEGER_SERVICE_NAME="che-server"
export JAEGER_SERVICE_NAME=${JAEGER_SERVICE_NAME:-${DEFAULT_JAEGER_SERVICE_NAME}}
DEFAULT_JAEGER_SAMPLER_MANAGER_HOST_PORT="jaeger:5778"
export JAEGER_SAMPLER_MANAGER_HOST_PORT=${JAEGER_SAMPLER_MANAGER_HOST_PORT:-${DEFAULT_JAEGER_SAMPLER_MANAGER_HOST_PORT}}
DEFAULT_JAEGER_SAMPLER_TYPE="const"
export JAEGER_SAMPLER_TYPE=${JAEGER_SAMPLER_TYPE:-${DEFAULT_JAEGER_SAMPLER_TYPE}}
DEFAULT_JAEGER_SAMPLER_PARAM="1"
export JAEGER_SAMPLER_PARAM=${JAEGER_SAMPLER_PARAM:-${DEFAULT_JAEGER_SAMPLER_PARAM}}
DEFAULT_JAEGER_REPORTER_MAX_QUEUE_SIZE="10000"
export JAEGER_REPORTER_MAX_QUEUE_SIZE=${JAEGER_REPORTER_MAX_QUEUE_SIZE:-${DEFAULT_JAEGER_REPORTER_MAX_QUEUE_SIZE}}
if [ "${ENABLE_SSL}" == "true" ]; then
HTTP_PROTOCOL="https"
WS_PROTOCOL="wss"
@ -375,9 +397,22 @@ if [ "${DEPLOY_CHE_PLUGIN_REGISTRY}" == "true" ]; then
fi
}
deployJaeger(){
if [ "${CHE_TRACING_ENABLED}" == "true" ]; then
echo "Deploying Jaeger..."
${OC_BINARY} new-app -f ${BASE_DIR}/templates/jaeger-all-in-one-template.yml
JAEGER_ROUTE=$($OC_BINARY get route/jaeger-query --namespace=${CHE_OPENSHIFT_PROJECT} -o=jsonpath={'.spec.host'})
echo "Jaeger deployment complete. $JAEGER_ROUTE"
fi
}
deployChe() {
CHE_VAR_ARRAY=$(env | grep "^CHE_.")
if [ "${CHE_TRACING_ENABLED}" == "true" ]; then
CHE_VAR_ARRAY=$(env | grep -e "^CHE_." -e "^JAEGER_.")
else
CHE_VAR_ARRAY=$(env | grep "^CHE_.")
fi
if [ ${#CHE_VAR_ARRAY[@]} -gt 0 ]; then
ENV="-e ${CHE_VAR_ARRAY}"
fi
@ -390,6 +425,7 @@ Image: ${CHE_IMAGE_REPO}
Pull policy: ${IMAGE_PULL_POLICY}
Update strategy: ${UPDATE_STRATEGY}
Setup OpenShift oAuth: ${SETUP_OCP_OAUTH}
Enable Jaeger based tracing: ${CHE_TRACING_ENABLED}
Environment variables:
${CHE_VAR_ARRAY}"
CHE_INFRA_OPENSHIFT_PROJECT=${CHE_OPENSHIFT_PROJECT}
@ -477,6 +513,7 @@ ${CHE_VAR_ARRAY}"
-p TLS=${TLS} \
-p CHE_WORKSPACE_PLUGIN__REGISTRY__URL=${PLUGIN__REGISTRY__URL} \
-p CHE_INFRA_KUBERNETES_SERVICE__ACCOUNT__NAME=${WORKSPACE_SERVICE_ACCOUNT_NAME} \
-p CHE_TRACING_ENABLED=${CHE_TRACING_ENABLED} \
${ENV}
if [ ${UPDATE_STRATEGY} == "Recreate" ]; then
@ -503,4 +540,5 @@ isLoggedIn
createNewProject
getRoutingSuffix
deployChePluginRegistry
deployJaeger
deployChe

View File

@ -261,6 +261,7 @@ parse_args() {
--remove-che - remove existing che project
--setup-ocp-oauth - register OCP oauth client and setup Keycloak and Che to use OpenShift Identity Provider
--deploy-che-plugin-registry - deploy Che plugin registry
--enable-tracing - Enable tracing and deploy Jaeger
===================================
ENV vars
CHE_IMAGE_TAG - set che-server image tag, default: nightly
@ -354,6 +355,10 @@ parse_args() {
export DEPLOY_CHE_PLUGIN_REGISTRY=true
shift
;;
--enable-tracing)
export CHE_TRACING_ENABLED=true
shift
;;
*)
echo "You've passed wrong arg '$i'."
echo -e "$HELP"

View File

@ -151,6 +151,8 @@ objects:
optional: true
- name: CHE_WORKSPACE_PLUGIN__REGISTRY__URL
value: "${CHE_WORKSPACE_PLUGIN__REGISTRY__URL}"
- name: CHE_TRACING_ENABLED
value: "${CHE_TRACING_ENABLED}"
image: ${IMAGE_CHE}:${CHE_VERSION}
imagePullPolicy: "${PULL_POLICY}"
livenessProbe:
@ -292,6 +294,10 @@ parameters:
displayName: Plugin sidecar default memory limit
description: Plugin sidecar default memory limit in megabytes
value: '128'
- name: CHE_TRACING_ENABLED
displayName: Eclipse Che tracing
description: Enable or disable tracing in Eclipse Che
value: 'false'
labels:
app: che
template: che

View File

@ -0,0 +1,190 @@
#
# Copyright 2017-2018 The Jaeger Authors
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
# in compliance with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software distributed under the License
# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
# or implied. See the License for the specific language governing permissions and limitations under
# the License.
#
parameters:
- description: The name of the Jaeger Service.
displayName: Jaeger Service Name
name: JAEGER_SERVICE_NAME
required: true
value: jaeger
- description: The Jaeger image version to use
displayName: Image version
name: IMAGE_VERSION
required: false
value: "latest"
- description: The name of the Jaeger Zipkin Service.
displayName: Jaeger Zipkin Service Name
name: JAEGER_ZIPKIN_SERVICE_NAME
required: true
value: zipkin
apiVersion: v1
kind: Template
labels:
template: jaeger-template-all-in-one
jaeger-infra: template-all-in-one
metadata:
name: jaeger-template-all-in-one
annotations:
description: Jaeger Distributed Tracing Server (all-in-one)
iconClass: icon-go-gopher
openshift.io/display-name: Jaeger (all-in-one)
tags: instant-app,tracing,opentracing,jaeger
labels:
name: jaeger-infra
jaeger-infra: jaeger-template-all-in-one
objects:
- apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: ${JAEGER_SERVICE_NAME}
labels:
app: jaeger
jaeger-infra: jaeger-deployment
spec:
replicas: 1
strategy:
type: Recreate
template:
metadata:
labels:
app: jaeger
jaeger-infra: jaeger-pod
annotations:
prometheus.io/scrape: "true"
prometheus.io/port: "16686"
spec:
containers:
- env:
- name: COLLECTOR_ZIPKIN_HTTP_PORT
value: "9411"
image: jaegertracing/all-in-one:${IMAGE_VERSION}
name: ${JAEGER_SERVICE_NAME}
ports:
- containerPort: 5775
protocol: UDP
- containerPort: 6831
protocol: UDP
- containerPort: 6832
protocol: UDP
- containerPort: 16686
protocol: TCP
- containerPort: 9411
protocol: TCP
- containerPort: 5778
protocol: TCP
readinessProbe:
httpGet:
path: "/"
port: 14269
initialDelaySeconds: 5
- apiVersion: v1
kind: Service
metadata:
name: ${JAEGER_SERVICE_NAME}-query
labels:
app: jaeger
jaeger-infra: jaeger-service
spec:
ports:
- name: query-http
port: 80
protocol: TCP
targetPort: 16686
selector:
jaeger-infra: jaeger-pod
type: LoadBalancer
- apiVersion: v1
kind: Service
metadata:
name: ${JAEGER_SERVICE_NAME}-collector
labels:
app: jaeger
jaeger-infra: collector-service
spec:
ports:
- name: jaeger-collector-tchannel
port: 14267
protocol: TCP
targetPort: 14267
- name: jaeger-collector-http
port: 14268
protocol: TCP
targetPort: 14268
- name: jaeger-collector-zipkin
port: 9411
protocol: TCP
targetPort: 9411
selector:
jaeger-infra: jaeger-pod
type: ClusterIP
- apiVersion: v1
kind: Service
metadata:
name: ${JAEGER_SERVICE_NAME}-agent
labels:
app: jaeger
jaeger-infra: agent-service
spec:
ports:
- name: agent-zipkin-thrift
port: 5775
protocol: UDP
targetPort: 5775
- name: agent-compact
port: 6831
protocol: UDP
targetPort: 6831
- name: agent-binary
port: 6832
protocol: UDP
targetPort: 6832
- name: agent-sampler-manager
port: 5778
protocol: TCP
targetPort: 5778
clusterIP: None
selector:
jaeger-infra: jaeger-pod
- apiVersion: v1
kind: Service
metadata:
name: ${JAEGER_ZIPKIN_SERVICE_NAME}
labels:
app: jaeger
jaeger-infra: zipkin-service
spec:
ports:
- name: jaeger-zipkin-http
port: 9411
protocol: TCP
targetPort: 9411
selector:
jaeger-infra: jaeger-pod
type: ClusterIP
- apiVersion: v1
kind: Route
metadata:
name: ${JAEGER_SERVICE_NAME}-query
labels:
jaeger-infra: query-route
spec:
to:
kind: Service
name: ${JAEGER_SERVICE_NAME}-query
port:
targetPort: query-http
tls:
termination: edge
insecureEdgeTerminationPolicy: Allow

10
pom.xml
View File

@ -754,6 +754,16 @@
<artifactId>che-core-sql-schema</artifactId>
<version>${che.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-tracing-core</artifactId>
<version>${che.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-tracing-web</artifactId>
<version>${che.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-workspace-activity-server</artifactId>