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-18943] Fix automated testing of OpenTelemetry QS under OpenShift #870

Closed
wants to merge 1 commit into from
Closed
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
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
6 changes: 6 additions & 0 deletions opentelemetry-tracing/charts/helm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,11 @@ build:
uri: https://github.com/wildfly/quickstart.git
ref: main
contextDir: opentelemetry-tracing
env:
Copy link
Contributor

Choose a reason for hiding this comment

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

Not needed, the openshift profile is used by default.

- name: MAVEN_ARGS_APPEND
value: "-Popenshift"
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
16 changes: 16 additions & 0 deletions opentelemetry-tracing/helm-install-prerequisites.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
=== 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. In your terminal, run the following command to configure the OpenTelemetry Collector as well as any external routes needed:
Copy link
Contributor

@emmartins emmartins Jan 30, 2024

Choose a reason for hiding this comment

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

IMHO we should not ask them to run the huge command first, here is my suggestion:

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
----


[source,options="nowrap",subs="+attributes"]
----
$ oc apply -f - <<EOF
include::charts/opentelemetry-collector.yaml[]
----

To make things simpler, you can find these commands in `charts/opentelemetry-collector.yaml`, and can apply them with this command:

[source]
----
$ oc apply -f charts/opentelemetry-collector.yaml
----
26 changes: 22 additions & 4 deletions 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 @@ -220,6 +230,9 @@
<layer>jaxrs-server</layer>
<layer>opentelemetry</layer>
</layers>
<plugin-options>
Copy link
Contributor

Choose a reason for hiding this comment

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

dupe, please remove this change

<jboss-fork-embedded>true</jboss-fork-embedded>
</plugin-options>
<cli-sessions>
<cli-session>
<script-files>
Expand Down Expand Up @@ -264,14 +277,19 @@
<layer>jaxrs-server</layer>
<layer>opentelemetry</layer>
</layers>
<filename>ROOT.war</filename>
<packaging-scripts>
<packaging-script>
<scripts>
<script>${basedir}/configure-opentelemetry.cli</script>
</scripts>
<commands>
Copy link
Contributor

Choose a reason for hiding this comment

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

IMHO it is preferable to use the cli script, since that is used also for baremetal config. I did some tests with Openshift Local and a modified branch of and the following worked fine:

                            <packaging-scripts>
                                <packaging-script>
                                    <scripts>
                                        <script>${basedir}/configure-opentelemetry.cli</script>
                                    </scripts>
                                    <resolve-expressions>false</resolve-expressions>
                                </packaging-script>
                            </packaging-scripts>

<command>/subsystem=opentelemetry:write-attribute(name=endpoint,value=http://\${OTEL_COLLECTOR_HOST}:4317)</command>
<command>/subsystem=opentelemetry:write-attribute(name=exporter-type,value=otlp)</command>
<command>/subsystem=opentelemetry:write-attribute(name=sampler-type,value=on)</command>
<command>/subsystem=opentelemetry:write-attribute(name=max-queue-size,value=1)</command>
<command>/subsystem=opentelemetry:write-attribute(name=max-export-batch-size,value=512)</command>
</commands>
<resolve-expressions>false</resolve-expressions>
</packaging-script>
</packaging-scripts>
<name>ROOT.war</name>
</configuration>
<executions>
<execution>
Expand Down