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

Test/release notes Breaking Change #13

Merged
merged 3 commits into from
Aug 5, 2022
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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
![inspectIT Ocelot ](https://inspectit.github.io/inspectit-ocelot/images/inspectit-ocelot.png)

## Test Release Notes

# inspectIT Ocelot

[![Release](https://jitpack.io/v/inspectit/inspectit-ocelot.svg)](https://jitpack.io/#inspectit/inspectit-ocelot)
Expand Down
6 changes: 4 additions & 2 deletions inspectit-ocelot-documentation/website/pages/en/versions.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ function Versions(props) {
</a>
</td>
<td>
<a href="">Release Notes</a>
<a href={`${repoUrl}/releases/tag/${latestVersion}`}>
Release Notes
</a>
</td>
</tr>
</tbody>
Expand Down Expand Up @@ -91,7 +93,7 @@ function Versions(props) {
</a>
</td>
<td>
<a href={`${repoUrl}/releases/tag/v${version}`}>
<a href={`${repoUrl}/releases/tag/${version}`}>
Release Notes
</a>
</td>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
---
id: version-2.1.0-configuration-sources
title: Configuration Sources
original_id: configuration-sources
---

inspectIT Ocelot tries to implement the zero-configuration approach but lets you externalize the configuration and influence every bit of its configuration if this is required.
Internally it uses the Spring-based `PropertySource` order to allow overriding of configuration values.
Configuration properties are considered in inspectIT Ocelot in the following order:

1. [Java Agent Arguments](#java-agent-arguments)
1. [Java System Properties](#java-system-properties)
1. [OS environment Variables](#os-environment-variables)
1. External Configuration Sources:
* [File-based Configuration](configuration/external-configuration-sources.md#file-based-configuration)
1. inspectIT Ocelot Defaults

When an invalid configuration is given to inspectIT on startup, the agent will use a fallback configuration.
In this fallback configuration, the agent is inactive with the exception of listening for configuration updates.

When giving an invalid configuration through a runtime update to the agent, the agent will simply retain the previous configuration.

## Available Configuration Sources

### Java Agent Arguments

You can pass a JSON object as string to the agent via its command line arguments.
For example, to override the service name used to identify your application reporting the performance data,
you can change the `inspectit.service-name` property as follows:

```bash
$ java -javaagent:/path/to/inspectit-ocelot-agent-2.1.0.jar="{ \"inspectit\": { \"service-name\": \"My Custom Service\" }}" -jar my-java-program.jar
```

Note that you have to escape the quotes within your JSON string. On linux you can just use the more readable single quotes notation:

```bash
$ java -javaagent:/path/to/inspectit-ocelot-agent-2.1.0.jar='{ "inspectit": { "service-name": "My Custom Service" }}' -jar my-java-program.jar
```

### Java System Properties

You can pass any configuration property as the Java System property to the Java command that you use to start your Java application.
Using this approach you can change the `inspectit.service-name` property as follows:

```bash
$ java -Dinspectit.service-name="My Custom Service" -javaagent:/path/to/inspectit-ocelot-agent-2.1.0.jar -jar my-java-program.jar
```

### OS Environment Variables

Similar to the Java System properties, inspectIT Ocelot will also consider all the available operating system environment variables.
Due to the relaxed bindings, you can use upper case format, which is recommended when using system environment variables.

```bash
$ INSPECTIT_SERVICE_NAME="My Custom Service" java -javaagent:/path/to/inspectit-ocelot-agent-2.1.0.jar -jar my-java-program.jar
```

## Relaxed Bindings

Note that due to the Spring-powered configuration approach, the inspectIT Ocelot agent uses Spring support for relaxed bindings.
This means that a property can be specified in different formats depending on the property source.
As suggested by Spring, the allowed formats are:

| Property | Note |
| --- | --- |
| `inspectit.service-name` | Kebab-case, which is recommended for use in `.properties` and `.yml` files. |
| `inspectit.serviceName` | Standard camelCase syntax. |
| `inspectit.service_name` | Underscore notation (snake_case), which is an alternative format for use in `.properties` and `.yml` files. |
| `INSPECTIT_SERVICE_NAME` | UPPER_CASE format, which is recommended when using system environment variables. |

The formats should be used in the following way, based on the type of property source:

| Property Source | Format |
| --- | --- |
| System properties | Camel case, kebab case, or underscore notation. |
| Environment Variables | Upper case format with the underscore as the delimiter. |
| Property files (`.properties`) | Camel case, kebab case, or underscore notation. |
| YAML files (`.yaml`, `.yml`) | Camel case, kebab case, or underscore notation. |

## Environment Information

Each agent stores the following information about its runtime environment:

| Property | Note |
| --- | --- |
| `inspectit.env.agent-dir` | Resolves to the path where the agent-jar is stored. |
| `inspectit.env.hostname` | The hostname where the agent is running. |
| `inspectit.env.pid` | The process id of the JVM process. |

They are used to define the default behavior when writing the configuration persistence file and will be sent
as attributes to the configuration server when fetching the configuration.

You can reference these properties within the configuration using e.g. `${inspectit.env.agent-dir}`
as shown in the default configuration for
[HTTP-based configuration](configuration/external-configuration-sources.md#http-based-configuration).
Referencing every other property follows the same schema.
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
id: version-2.1.0-open-census-configuration
title: Using OpenCensus Library with inspectIT Ocelot
sidebar_label: OpenCensus Configuration
original_id: open-census-configuration
---

If you plan to use the OpenCensus library in an application which will be instrumented later on with inspectIT Ocelot, some special rules do apply.
Following these rules will make sure that there are no run-time problems in your application.
Furthermore, a correct configuration will make it possible to combine metrics and traces that you manually collect using the OpenCensus instrumentation library with the ones collected by the inspectIT Ocelot agent.

1. Make sure you are using the same version of OpenCensus as inspectIT Ocelot.

The inspectIT Ocelot agent in version 2.1.0 internally uses OpenCensus in version 0.28.3. Please adapt any OpenCensus dependency in your application to this version to avoid run-time conflicts.
```XML
<dependency>
<groupId>io.opencensus</groupId>
<artifactId>opencensus-api</artifactId>
<version>0.28.3</version>
</dependency>
```

2. Set the JVM property `inspectit.publishOpenCensusToBootstrap` to `true`.

```
-Dinspectit.publishOpenCensusToBootstrap=true
```

Setting the above property to `true` tells inspectIT Ocelot that you plan to use the OpenCensus library in combination with the agent. Note that this property must be specified with this exact name. The flexibility offered for all other config options does not apply here. The inspectIT Ocelot agent will make sure that all OpenCensus classes are then loaded by the bootstrap class loader. This ensures that OpenCensus implementation is shared between your manual instrumentation and the agent instrumentation, making the combination of data possible.

3. Add the agent to the start of a JVM

In this scenario, it is required that you add the agent via [the `javaagent` JVM argument](getting-started/installation.md#adding-the-agent-to-a-jvm). If the agent is successfully added to the JVM, it will log that the OpenCensus classes pushed to the bootstrap classloader will be used.

It is important to state that the agent will *not* publish the OpenCensus classes to the bootstrap classloader if it is attached during runtime – even if the previously mentioned JVM argument is set! In this case, metrics and traces of *manual OpenCensus instrumentations* will *not* be collected by the inspectIT Ocelot agent.
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
id: version-2.1.0-open-telemetry-configuration
title: Using OpenTelemetry Library with inspectIT Ocelot
sidebar_label: OpenTelemetry Configuration
original_id: open-telemetry-configuration
---

><mark> TODO: finish the configuration documentation when the migration to OTEL (with the OTEL bridge) is finished, i.e., when all exporters (including OTLP exporters) are supported
</mark>
If you plan to use the OpenTelemetry library in an application which will be instrumented later on with inspectIT Ocelot, some special rules do apply.
Following these rules will make sure that there are no run-time problems in your application.
Furthermore, a correct configuration will make it possible to combine metrics and traces that you manually collect using the OpenTelemetry instrumentation library with the ones collected by the inspectIT Ocelot agent.

1. Make sure you are using the same version of OpenTelemetry as inspectIT Ocelot.

The inspectIT Ocelot agent in version 2.1.0 internally uses OpenTelemetry in version {opentelemetry-version}. Please adapt any OpenTelemetry dependency in your application to this version to avoid run-time conflicts.
```XML
<dependency>
<groupId>io.opentelemetry</groupId>
<artifactId>opentelemetry-api</artifactId>
<version>{opentelemetry-version}</version>
</dependency>
```

2. Set the JVM property `inspectit.publishOpenTelemetryToBootstrap` to `true`.

```
-Dinspectit.publishOpenTelemetryToBootstrap=true
```

Setting the above property to `true` tells inspectIT Ocelot that you plan to use the OpenTelemetry library in combination with the agent. Note that this property must be specified with this exact name. The flexibility offered for all other config options does not apply here. The inspectIT Ocelot agent will make sure that all OpenTelemetry classes are then loaded by the bootstrap class loader. This ensures that OpenTelemetry implementation is shared between your manual instrumentation and the agent instrumentation, making the combination of data possible.

3. Add the agent to the start of a JVM

In this scenario, it is required that you add the agent via [the `javaagent` JVM argument](getting-started/installation.md#adding-the-agent-to-a-jvm). If the agent is successfully added to the JVM, it will log that the OpenTelemetry classes pushed to the bootstrap classloader will be used.

It is important to state that the agent will *not* publish the OpenTelemetry classes to the bootstrap classloader if it is attached during runtime – even if the previously mentioned JVM argument is set! In this case, metrics and traces of *manual OpenTelemetry instrumentations* will *not* be collected by the inspectIT Ocelot agent.
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
---
id: version-2.1.0-installation
title: Installation
original_id: installation
---

This section describes the installation details for the inspectIT Ocelot agent.

## Supported Java Runtime Environments

The inspectIT Ocelot supports Java Runtime Environments in version 1.8.0 and above. You will not be able to use the agent with the lower Java versions.
The agent works with different JRE distributions including Oracle, openJDK, Azul, etc.

## Adding the Agent to a JVM

The best option for using the inspectIT Ocelot is to include it to the start of the JVM by using the `-javaagent` command-line option.
This way the agent will be initialized before your application starts.

```bash
$ java -javaagent:"/path/to/inspectit-ocelot-agent-2.1.0.jar" -jar my-java-program.jar
```

> Some application servers have dedicated scripts that are used to launch the actual JVM that runs the application. In such cases, you must alter the start-up scripts in order to instrument the correct JVM.

## Attaching the Agent to a Running JVM

inspectIT Ocelot also supports attaching the agent to an already running JVM.
In such a scenario the collection of metrics and traces will start from the point of the attachment.

The attaching can easily be done using the agent itself and executing the following command:

```bash
$ java -jar inspectit-ocelot-agent-2.1.0.jar <PID> [<AGENT_ARGUMENTS>]
```

In the following example, we are attaching the agent to the JVM process `1337` and passing some [additional arguments](configuration/configuration-sources.md#java-agent-arguments) to it:
```bash
$ java -jar inspectit-ocelot-agent-2.1.0.jar 1337 '{"inspectit":{"service-name":"my-agent"}}'
```

> The agent is internally using the utility [jattach](https://github.com/apangin/jattach) for attaching itself to a running JVM.

In order to find the process ID of a running JVM, you can use the `jcmd` to list all the running Java processes on your machine:

```bash
$ jcmd -l
```

### Attaching Using jattach

Another way of attaching the agent to a running JVM is to use the utility [jattach](https://github.com/apangin/jattach):

```bash
$ ./jattach.sh <PID> load instrument false /path/to/inspectit-ocelot-agent-2.1.0.jar='{"inspectit.service-name" : "MyService"}'
```
In this example we're also passing [JSON arguments](configuration/configuration-sources.md#java-agent-arguments) to the agent in order to configure its service name.

> Using the attach options has some limitations with respect to using the OpenCensus instrumentation library in combination with the inspectIT Ocelot agent. Please refer to [OpenCensus Configuration](configuration/open-census-configuration.md) section to understand these limitations.

## Using the Agent With a Security Manager

If a Java Security Manager is enabled, the agent needs to be granted additional permissions to work.
For this, add the following to your policy file:

```
grant codeBase "file:<absolute_path_to_inspectit-ocelot-agent.jar>" {
permission java.security.AllPermission;
};
```

The correct policy file location depends on different factors.
See the [official Java documentation](https://docs.oracle.com/en/java/javase/17/security/permissions-jdk1.html#GUID-789089CA-8557-4017-B8B0-6899AD3BA18D) for further information.

## Using the Agent with Kubernetes

There are several ways to use the agent in a Kubernetes cluster.
For example, you could integrate the agent directly into the application container images, but this requires customizing all images.

Another possibility is that the agent is automatically injected into the application containers using an **operator** and attached to the JVM processes.
For this purpose, the [OpenTelemetry K8s Operator](https://github.com/open-telemetry/opentelemetry-operator) can be used, with which it is possible to automatically roll out the inspectIT Ocelot Java Agent.
It is still under development, so it is not feature-complete, but depending on your needs the current version could already provide everything needed.

:::warning Up-to-dateness of the Documentation
Since the OpenTelemetry K8s operator is currently under heavy development, the installation steps described below **may be outdated**.
They may nevertheless be helpful in navigating the OpenTelemetry Operator installation documentation by showing you which parts you need.
:::

### Installing the Operator

Install the OpenTelemetry Operator as described in its [official readme file](https://github.com/open-telemetry/opentelemetry-operator#getting-started). This includes the following steps:

1. Install the [cert-manager](https://cert-manager.io/docs/installation/) in your cluster if you have not done it already.
2. Install the operator using the following command. Please note that this will install the latest version of it:

```shell
kubectl apply -f https://github.com/open-telemetry/opentelemetry-operator/releases/latest/download/opentelemetry-operator.yaml
```

By adjusting the URL to a different GitHub release, a specific version of the operator can be used:

```shell
kubectl apply -f https://github.com/open-telemetry/opentelemetry-operator/releases/download/v{version}/opentelemetry-operator.yaml
```

### Using the Operator

1. Create an `Instrumentation` object as shown below. Set the `spec.java.image` to the inspectIT Ocelot agent container image you would like to use:

:::note
Please note that only container images of the inspectIT Ocelot Agent starting from version `1.15.2` are compatible and work with the OpenTelemetry K8s Operator.
:::

```yaml
apiVersion: opentelemetry.io/v1alpha1
kind: Instrumentation
metadata:
name: my-instrumentation
spec:
java:
image: inspectit/inspectit-ocelot-agent:1.15.2
```

2. Annotate namespaces or containers that should receive the agent as described in the [official readme file](https://github.com/open-telemetry/opentelemetry-operator#getting-started). The possible values for the annotation can be:

- `true` - inject the `Instrumentation` resource from the namespace.
- `my-instrumentation` - name of Instrumentation CR instance.
- `false` - do not inject

The following annotation can be used for this:
```yaml
instrumentation.opentelemetry.io/inject-java: "true"
```

:::warning Ensure Correct Referencing
If the operator cannot find the instrumentation object, e.g. because none was created or the name was written incorrectly in the annotation, the containers will not be started!
:::

3. (Optional) Add environment variables to the containers to configure the agent. See the following section for using [environment variables to configure](configuration/configuration-sources.md#os-environment-variables) the inspectIT Ocelot agent.

For example, to set a service-name for the agent and connect it to a specific configuration-server, you could set the `INSPECTIT_CONFIG_HTTP_URL` and `INSPECTIT_SERVICE_NAME` environment variable like in the following:

```yaml
containers:
- image: my-app-image
name: my-app
env:
- name: INSPECTIT_CONFIG_HTTP_URL
value: http://my-ocelot-config-server:8090/api/v1/agent/configuration
- name: INSPECTIT_SERVICE_NAME
value: my-service-name
```

You can also take a look at the [deployment file](https://github.com/inspectIT/trading-demo-application/blob/main/k8s/deployment.yaml) of the [trading demo application](https://github.com/inspectIT/trading-demo-application) where exactly this is set up.

4. Start or restart the containers to trigger the injection and attachment of the agent.

Currently, the operator **will not automatically restart running containers** in case changes are made to the `Instrumentation` objects. However, there are plans to provide the ability to restart containers in order to roll out changes of the configurable `Instrumentation` objects automatically (see [issue #553](https://github.com/open-telemetry/opentelemetry-operator/issues/553)).
Loading