Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WFLY-15849] OpenTelemetry QS on OpenShift #872

Merged
merged 2 commits into from
Feb 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@
# One per line with no trailing spaces, and make sure to have a newline at the end
# microprofile-reactive-messaging-kafka
micrometer
opentelemetry-tracing

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
function runPostHelmInstallCommands() {
echo "Applying all OpenTelemetry Collector resources"
oc apply -f charts/opentelemetry-collector.yaml
}

function cleanPrerequisites() {
echo "Deleting all OpenTelemetry Collector resources"
oc delete -f charts/opentelemetry-collector.yaml
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this step should as additional step in undeploy

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The proper solution for this requires an additional extension point for shared-docs, similar to helm-install-prerequisites, and that will affect all QS so I have created https://issues.redhat.com/browse/WFLY-18986 to deliver it (and more general shared improvements). For now the uninstall is referenced as a note at https://github.com/wildfly/quickstart/pull/872/files#diff-437f0901bdbc94e992d4b6b75f355240a557c4879683f47d27dad1c51f27dc4aR19

}
1 change: 1 addition & 0 deletions opentelemetry-tracing/README-source.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ The `opentelemetry-tracing` quickstart demonstrates the use of the OpenTelemetry
:archiveType: war
:archiveName: {artifactId}
:restoreScriptName: restore-configuration.cli
:helm-install-prerequisites: ../opentelemetry-tracing/helm-install-prerequisites.adoc


== What is it?
Expand Down
3 changes: 3 additions & 0 deletions opentelemetry-tracing/charts/helm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ build:
contextDir: opentelemetry-tracing
deploy:
replicas: 1
env:
- name: OTEL_COLLECTOR_HOST
value: "opentelemetrycollector"
104 changes: 104 additions & 0 deletions opentelemetry-tracing/charts/opentelemetry-collector.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
---
apiVersion: v1
kind: ConfigMap
metadata:
name: collector-config
data:
collector.yml: |
receivers:
otlp:
protocols:
grpc:
http:
processors:
exporters:
logging:
verbosity: detailed
service:
pipelines:
traces:
receivers: [otlp]
processors: []
exporters: [logging]
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: opentelemetrycollector
spec:
replicas: 1
selector:
matchLabels:
app.kubernetes.io/name: opentelemetrycollector
template:
metadata:
labels:
app.kubernetes.io/name: opentelemetrycollector
spec:
containers:
- name: otelcol
args:
- --config=/conf/collector.yml
image: otel/opentelemetry-collector:0.89.0
volumeMounts:
- mountPath: /conf
name: collector-config
volumes:
- configMap:
items:
- key: collector.yml
path: collector.yml
name: collector-config
name: collector-config
---
apiVersion: v1
kind: Service
metadata:
name: opentelemetrycollector
spec:
ports:
- name: otlp-grpc
port: 4317
protocol: TCP
targetPort: 4317
- name: otlp-http
port: 4318
protocol: TCP
targetPort: 4318
selector:
app.kubernetes.io/name: opentelemetrycollector
type: ClusterIP
---
apiVersion: route.openshift.io/v1
kind: Route
metadata:
name: otelcol-otlp-grpc
labels:
app.kubernetes.io/name: microprofile
spec:
port:
targetPort: otlp-grpc
to:
kind: Service
name: opentelemetrycollector
tls:
termination: edge
insecureEdgeTerminationPolicy: Redirect
wildcardPolicy: None
---
apiVersion: route.openshift.io/v1
kind: Route
metadata:
name: otelcol-otlp-http
labels:
app.kubernetes.io/name: microprofile
spec:
port:
targetPort: otlp-http
to:
kind: Service
name: opentelemetrycollector
tls:
termination: edge
insecureEdgeTerminationPolicy: Redirect
wildcardPolicy: None
2 changes: 1 addition & 1 deletion opentelemetry-tracing/configure-opentelemetry.cli
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ if (outcome != success) of /extension=org.wildfly.extension.opentelemetry:read-r
/subsystem=opentelemetry:add()
end-if

/subsystem=opentelemetry:write-attribute(name=endpoint,value=http://localhost:4317)
/subsystem=opentelemetry:write-attribute(name=endpoint,value=http://${OTEL_COLLECTOR_HOST:localhost}:4317)
/subsystem=opentelemetry:write-attribute(name=exporter-type,value=otlp)
/subsystem=opentelemetry:write-attribute(name=sampler-type,value=on)
/subsystem=opentelemetry:write-attribute(name=max-queue-size,value=1)
Expand Down
25 changes: 25 additions & 0 deletions opentelemetry-tracing/helm-install-prerequisites.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
=== Install OpenTelemetry Collector on OpenShift

The functionality of this quickstart depends on a running instance of the https://opentelemetry.io/docs/collector/[OpenTelemetry Collector].

To deploy and configure the OpenTelemetry Collector, you will need to apply a set of configurations to your OpenShift cluster, to configure the OpenTelemetry Collector as well as any external routes needed:

[source,options="nowrap",subs="+attributes"]
----
include::charts/opentelemetry-collector.yaml[]
----

To make things simpler, you can find these commands in `charts/opentelemetry-collector.yaml`, and to apply them run the following command in your terminal:

[source]
----
$ oc apply -f charts/opentelemetry-collector.yaml
----

[NOTE]
====
When done with the quickstart, the `oc delete -f charts/opentelemetry-collector.yaml` command may be used to revert the applied changes.
====



13 changes: 12 additions & 1 deletion opentelemetry-tracing/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,16 @@
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>11</source>
<target>11</target>
</configuration>
</plugin>
</plugins>
</build>

<profiles>
Expand Down Expand Up @@ -264,14 +274,15 @@
<layer>jaxrs-server</layer>
<layer>opentelemetry</layer>
</layers>
<filename>ROOT.war</filename>
<packaging-scripts>
<packaging-script>
<scripts>
<script>${basedir}/configure-opentelemetry.cli</script>
</scripts>
<resolve-expressions>false</resolve-expressions>
</packaging-script>
</packaging-scripts>
<name>ROOT.war</name>
</configuration>
<executions>
<execution>
Expand Down
5 changes: 3 additions & 2 deletions shared-doc/build-and-run-the-quickstart-with-openshift.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ ifndef::helm-app-name[]
:helm-app-name: {artifactId}
endif::helm-app-name[]



[[build_and_run_the_quickstart_on_openshift]]
= Building and running the quickstart application with OpenShift
// The openshift profile
Expand All @@ -22,3 +20,6 @@ include::../shared-doc/helm-deploy-project.adoc[leveloffset=+1]

// Testing on Openshift
include::../shared-doc/run-integration-tests-with-openshift.adoc[leveloffset=+1]

//Prepare Helm for Quickstart Deployment
include::../shared-doc/helm-undeploy-project.adoc[leveloffset=+1]
10 changes: 0 additions & 10 deletions shared-doc/helm-deploy-project.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,3 @@ The Maven profile named `openshift` is used by the Helm chart to provision the s
ifdef::post-helm-install-actions[]
include::{post-helm-install-actions}[leveloffset=+1]
endif::post-helm-install-actions[]


[[undeploy_helm]]
== Undeploy the {ProductShortName} Source-to-Image (S2I) Quickstart from OpenShift with Helm Charts


[source,options="nowrap",subs="+attributes"]
----
$ helm uninstall {helm-app-name}
----
7 changes: 7 additions & 0 deletions shared-doc/helm-undeploy-project.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[[undeploy_helm]]
== Undeploy the {ProductShortName} Source-to-Image (S2I) Quickstart from OpenShift with Helm Charts

[source,options="nowrap",subs="+attributes"]
----
$ helm uninstall {helm-app-name}
----