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

doc: customized auto-instrumentation #762

Merged
merged 6 commits into from
Mar 15, 2022
Merged
Changes from 3 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
55 changes: 55 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,61 @@ The possible values for the annotation can be
* `"my-instrumentation"` - name of `Instrumentation` CR instance.
* `"false"` - do not inject

#### Use Customized Image for auto-instrumentation injection
Copy link
Member

Choose a reason for hiding this comment

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

Use customized or vendor instrumentation

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated


Although the default auto-instrumentation image can handle some mostly used libraries, it may still
Copy link
Member

Choose a reason for hiding this comment

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

By default, the operator uses upstream auto-instrumentation libraries. Custom auto-instrumentation can be configured by overriding the image field in a CR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated

miss the ones you need. In this case, you can tell the operator to use your own customized image.

```yaml
apiVersion: opentelemetry.io/v1alpha1
kind: Instrumentation
metadata:
name: my-instrumentation
spec:
Copy link
Member

Choose a reason for hiding this comment

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

could you please change the CR and keep only the image configuration?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated

exporter:
endpoint: http://otel-collector:4317
propagators:
- tracecontext
- baggage
- b3
sampler:
type: parentbased_traceidratio
argument: "0.25"
java:
image: your-customized-auto-instrumentation-image:java
nodejs:
image: your-customized-auto-instrumentation-image:nodejs
python:
image: your-customized-auto-instrumentation-image:python
```

To build your customized image, you can start by reusing the default dockerfiles. They are stored in the `autoinstrumentation`
Copy link
Member

@pavolloffay pavolloffay Mar 14, 2022

Choose a reason for hiding this comment

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

The Dockerfiles for auto-instrumentation can be found in [autoinstrumentation directory](./autoinstrumentation). Follow the instructions in the Dockerfiles on how to build a custom container image.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated

directory. In general, you should comply with the guidelines below.
- Python
Copy link
Member

Choose a reason for hiding this comment

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

I actually don't like to have this detailed information in the root readme.

Could we move this doc to auto-instrumentation dockefiles and describe there what to do if a custom image needs to be build?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

moved to dockerfiles

- Ensure the packages are installed in the `/autoinstrumentation` directory. This is required as when instrumenting the pod,
one init container will be created to copy all the content in `/autoinstrumentation` directory to your app's container. Then
update the `PYTHONPATH` environment variable accordingly. To achieve this, you can mimic the one in `autoinstrumentation/python/Dockerfile`
by using multi-stage builds. In the first stage, install all the required packages in one custom directory with `pip install --target`.
Then in the second stage, copy the directory to `/autoinstrumentation`.
- Ensure you have `opentelemetry-distro` and `opentelemetry-instrumentation` or your customized alternatives installed.
Those two packages are essential to Python auto-instrumentation.
- Grant the necessary access to `/autoinstrumentation` directory. `chmod -R go+r /autoinstrumentation`
- Node.js
- Ensure the packages are installed in the `/autoinstrumentation` directory. This is required as when instrumenting the pod,
one init container will be created to copy all the content in `/autoinstrumentation` directory to your app's container. Then
update the `NODE_OPTIONS` environment variable accordingly. To achieve this, you can mimic the one in `autoinstrumentation/nodejs/Dockerfile`
by using multi-stage builds. In the first stage, install all the required packages in one custom directory.
Then in the second stage, copy the directory to `/autoinstrumentation`.
- Ensure you have `@opentelemetry/api`, `@opentelemetry/auto-instrumentations-node`, and `@opentelemetry/sdk-node` or your customized
alternatives installed.
- Grant the necessary access to `/autoinstrumentation` directory. `chmod -R go+r /autoinstrumentation`
- Java
- Download your customized `javaagent.jar` to `/javaagent.jar`. This is required as when instrumenting the pod,
one init container will be created to copy the jar to your app's container.
- To customize the instrumentation library, you may need fork https://github.com/open-telemetry/opentelemetry-java-instrumentation/tree/main/javaagent
Copy link
Member

Choose a reason for hiding this comment

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

We can remove this line, there are different ways how the java agent can be modified or extended. Most users won't probably do it anyways.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed

and make changes accordingly.
- Grant the necessary access to the jar. `chmod -R go+r /javaagent.jar`

## Compatibility matrix

### OpenTelemetry Operator vs. OpenTelemetry Collector
Expand Down