Skip to content

Commit e99fb8a

Browse files
Adjust Documentation for Cloud-Logging
Add references to the `cloud-logging`exporter to the documentation. Describe the new config properties to control the extension. Signed-off-by: Karsten Schnitter <[email protected]>
1 parent 9ded83d commit e99fb8a

File tree

2 files changed

+78
-16
lines changed

2 files changed

+78
-16
lines changed

cf-java-logging-support-opentelemetry-agent-extension/README.md

+77-15
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
# OpenTelemetry Java Agent Extension for SAP Cloud Logging
22

33
This module provides an extension for the [OpenTelemetry Java Agent](https://opentelemetry.io/docs/instrumentation/java/automatic/).
4-
The extension scans the service bindings of an application for SAP Cloud Logging.
4+
The extension scans the service bindings of an application for [SAP Cloud Logging](https://discovery-center.cloud.sap/serviceCatalog/cloud-logging).
55
If such a binding is found, the OpenTelemetry Java Agent is configured to ship observability data to that service.
66
Thus, this extension provides a convenient auto-instrumentation for Java applications running on SAP BTP.
77

8-
The extension provides two main features:
8+
The extension provides the following main features:
99

10-
* auto-configuration of the OpenTelemetry connection to SAP Cloud Logging
11-
* adding resource attributes to describe the CF application
10+
* additional exporters for logs, metrics and traces for [SAP Cloud Logging](https://discovery-center.cloud.sap/serviceCatalog/cloud-logging)
11+
* auto-configuration of the generic OpenTelemetry connection to [SAP Cloud Logging](https://discovery-center.cloud.sap/serviceCatalog/cloud-logging)
12+
* adding resource attributes describing the CF application
1213

1314
See the section on [configuration](#configuration) for further details.
1415

@@ -18,7 +19,7 @@ Any Java application can be instrumented with the OpenTelemetry Java Agent and t
1819

1920
```sh
2021
java -javaagent:/path/to/opentelemetry-javaagent-<version>.jar \
21-
-Dotel.javaagent-extensions=/path/to/cf-java-logging-support-opentelemetry-agent-extension-<versions>.jar \
22+
-Dotel.javaagent-extensions=/path/to/cf-java-logging-support-opentelemetry-agent-extension-<version>.jar \
2223
# your Java application command
2324
```
2425

@@ -37,27 +38,76 @@ java -javaagent:BOOT-INF/lib/opentelemetry-javaagent-<version>.jar \
3738
3839
See the [example manifest](../sample-spring-boot/manifest-otel-javaagent.yml), how this translates into a deployment description.
3940

40-
For the instrumentation to send observability data to SAP Cloud Logging, the application needs to be bound to a corresponding service instance.
41-
The service instance can be either managed or [user-provided](#using-user-provided-service-instances).
41+
Once the agent is attached to the JVM with the ectension in place, there are two ways, which can be used to send data to [SAP Cloud Logging](https://discovery-center.cloud.sap/serviceCatalog/cloud-logging):
42+
43+
1. Use the `cloud-logging` exporters explicitly as provided by the extension.
44+
This can be achieved via system properties or environment variables:
45+
```sh
46+
-Dotel.logs.exporter=cloud-logging \
47+
-Dotel.metrics.exporter=cloud-logging \
48+
-Dotel.traces.exporter=cloud-logging
49+
50+
#or
51+
52+
export OTEL_LOGS_EXPORTER=cloud-logging
53+
export OTEL_METRICS_EXPORTER=cloud-logging
54+
export OTEL_TRACES_EXPORTER=cloud-logging
55+
java #...
56+
```
57+
58+
2. Use the default `otlp` exporter with the provided default configuration from the extension:
59+
60+
```sh
61+
-Dotel.logs.exporter=otlp \
62+
-Dotel.metrics.exporter=otlp # default value \
63+
-Dotel.traces.exporter=otlp # default value
64+
65+
#or
4266

43-
Note, that the OpenTelemetry Java Agent currently only sends traces and metrics by default.
44-
To enable logs, the additional property `-Dotel.logs.exporter=otlp` is required.
67+
export OTEL_LOGS_EXPORTER=otlp
68+
export OTEL_METRICS_EXPORTER=otlp # default value
69+
export OTEL_TRACES_EXPORTER=otlp # default value
70+
java #...
71+
```
72+
73+
Note, that the OpenTelemetry Java Agent currently sends traces and metrics by default using the `otlp` exporter.
74+
That means, without any configuration the agent with the extension will forward metrics and traces to [SAP Cloud Logging](https://discovery-center.cloud.sap/serviceCatalog/cloud-logging).
75+
See TODO for the difference between `cloud-logging` and `otlp` exporters.
76+
The benefit of the `cloud-logging` exporter is, that it can be combined with a different configuration of the `otlp` exporter.
77+
78+
For the instrumentation to send observability data to [SAP Cloud Logging](https://discovery-center.cloud.sap/serviceCatalog/cloud-logging), the application needs to be bound to a corresponding service instance.
79+
The service instance can be either managed or [user-provided](#using-user-provided-service-instances).
4580

4681
## Configuration
4782

4883
The OpenTelemetry Java Agent supports a wide variety of [configuration options](https://opentelemetry.io/docs/instrumentation/java/automatic/agent-config/).
4984
As the extension provides configuration via SPI, all its configuration takes lower precedence than other configuration options for OpenTelemetry.
5085
Users can easily overwrite any setting using environment variables or system properties.
5186

87+
### Using the Extension
88+
89+
The extension needs to be started with the OpenTelemetry Java Agent as outlined in the [Quick Start Guide](#quickstart-guide).
90+
You need to enable shipping data either by using the `cloud-logging` exporters or relying on the `otlp` exporters for each signal type.
91+
Multiple different exporters can be configured with comma separation.
92+
Using the custom `cloud-logging` exporter will enable you, to use the default `otlp` exporter for different services.
93+
The extension will configure a default endpoint and credentials for the `otlp` endpoints, so no further configuration is required.
94+
95+
Note, that the `cloud-logging` exporter is just a facade for the `otlp` exporter to allow configuration of multiple data sinks.
96+
There is no custom network client provided by this extension.
97+
5298
### Configuring the Extension
5399

54100
The extension itself can be configured by specifying the following system properties:
55101

56102
| Property | Default Value | Comment |
57103
|----------|---------------|---------|
58-
| `com.sap.otel.extension.cloud-logging.label` | `cloud-logging` | The label of the managed service binding to bind to. |
59-
| `com.sap.otel.extension.cloud-logging.tag` | `Cloud Logging` | The tag of any service binding (managed or user-provided) to bind to. |
60-
| `otel.javaagent.extension.sap.cf.resource.enabled` or `env(OTEL_JAVAAGENT_EXTENSION_SAP_CF_RESOURCE_ENABLED)` | `true` | Whether to add CF resource attributes to all events. |
104+
| `otel.javaagent.extension.sap.cf.binding.cloud-logging.label` or `com.sap.otel.extension.cloud-logging.label` | `cloud-logging` | The label of the managed service binding to bind to. |
105+
| `otel.javaagent.extension.sap.cf.binding.cloud-logging.tag` or `com.sap.otel.extension.cloud-logging.tag` | `Cloud Logging` | The tag of any service binding (managed or user-provided) to bind to. |
106+
| `otel.javaagent.extension.sap.cf.binding.user-provided.label` | `user-provided` | The label of a user-provided service binding to bind to. Note, this label is defined by the Cloud Foundry instance. |
107+
| `otel.javaagent.extension.sap.cf.resource.enabled` | `true` | Whether to add CF resource attributes to all events. |
108+
109+
> The `otel.javaagent.extension.sap.*` properties are preferred over the `com.sap.otel.extension.*` properties, which are kept for compatibility.
110+
Each `otel.javaagent.extension.sap.*` property can also be provided as environment variable `OTEL_JAVAAGENT_EXTENSION_SAP_*`.
61111

62112
The extension will scan the environment variable `VCAP_SERVICES` for CF service bindings.
63113
User-provided bindings will take precedence over managed bindings of the configured label ("cloud-logging" by default).
@@ -90,7 +140,7 @@ The [OpenTelemetry Java Instrumentation project](https://github.com/open-telemet
90140

91141
## Using User-Provided Service Instances
92142

93-
The extension provides support not only for managed service instance of SAP Cloud Logging but also for user-provided service instances.
143+
The extension provides support not only for managed service instance of [SAP Cloud Logging](https://discovery-center.cloud.sap/serviceCatalog/cloud-logging) but also for user-provided service instances.
94144
This helps to fine-tune the configuration, e.g. leave out or reconfigure the syslog drain.
95145
Furthermore, this helps on sharing service instances across CF orgs or landscapes.
96146

@@ -103,7 +153,7 @@ The extension requires four fields in the user-provided service credentials and
103153
| `ingest-otlp-cert`| The mTLS client certificate in PEM format matching the client key. Line breaks as `\n`. |
104154
| `server-ca` | The trusted mTLS server certificate in PEM format. Line breaks as `\n`. |
105155

106-
If you have a SAP Cloud Logging service key, you can generate the required JSON file with jq:
156+
If you have a [SAP Cloud Logging](https://discovery-center.cloud.sap/serviceCatalog/cloud-logging) service key, you can generate the required JSON file with jq:
107157

108158
```bash
109159
cf service-key cls test \
@@ -119,5 +169,17 @@ Using this file, you can create the required user-provided service:
119169
```
120170

121171
Note, that you can easily feed arbitrary credentials to the extension.
122-
It does not need to be SAP Cloud Logging.
172+
It does not need to be [SAP Cloud Logging](https://discovery-center.cloud.sap/serviceCatalog/cloud-logging).
123173
You can even change the tag using the configuration parameters of the extension.
174+
175+
## Implementation Differences between Cloud-Logging and OTLP Exporter
176+
177+
The `cloud-logging` exporter provided by this extension is a facade for the `OtlpGrpcExporter` provided by the OpenTelemetry Java Agent, just like the `otlp` exporter.
178+
The difference is just during the bootstrapping phase.
179+
The main differences are:
180+
181+
* The `cloud-logging` exporter will send data to all found bindings to SAP Cloud Logging.
182+
The auto-instrumentation of the `otlp` exporter will just configure the first binding it finds priotizing user-provided services.
183+
* The `otlp` configuration will write the required certificates and keys to temporary files, which are deleted when the JVM is shut down. The `cloud-logging` exporter will keep the secrets in memory.
184+
* Since the `otlp` exporter is the default for traces and metrics, just attaching the extension and binding to Cloud Logging will result in metrics and traces being forwarded.
185+
The `cloud-logging` exporter needs to be configured explictly as does the `otlp` exporter for logs.

sample-spring-boot/manifest-otel-javaagent.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ applications:
1515
LOG_REFERER: false
1616
JBP_CONFIG_COMPONENTS: "jres: ['com.sap.xs.java.buildpack.jre.SAPMachineJRE']"
1717
JBP_CONFIG_SAP_MACHINE_JRE: '{ use_offline_repository: false, version: 17.+ }'
18-
JBP_CONFIG_JAVA_OPTS: '[from_environment: false, java_opts: ''-javaagent:BOOT-INF/lib/opentelemetry-javaagent-1.31.0.jar -Dotel.javaagent.extensions=BOOT-INF/lib/cf-java-logging-support-opentelemetry-agent-extension-3.8.0.jar -Dotel.logs.exporter=otlp -Dotel.instrumentation.logback-appender.experimental.capture-mdc-attributes=* -Dotel.instrumentation.logback-appender.experimental.capture-key-value-pair-attributes=true -Dotel.instrumentation.logback-appender.experimental.capture-code-attributes=true -Dotel.instrumentation.logback-appender.experimental-log-attributes=true -Dotel.experimental.resource.disabled-keys=process.command_line,process.command_args,process.executable.path'']'
18+
JBP_CONFIG_JAVA_OPTS: '[from_environment: false, java_opts: ''-javaagent:BOOT-INF/lib/opentelemetry-javaagent-1.31.0.jar -Dotel.javaagent.extensions=BOOT-INF/lib/cf-java-logging-support-opentelemetry-agent-extension-3.8.0.jar -Dotel.logs.exporter=cloud-logging,otlp -Dotel.instrumentation.logback-appender.experimental.capture-mdc-attributes=* -Dotel.instrumentation.logback-appender.experimental.capture-key-value-pair-attributes=true -Dotel.instrumentation.logback-appender.experimental.capture-code-attributes=true -Dotel.instrumentation.logback-appender.experimental-log-attributes=true -Dotel.experimental.resource.disabled-keys=process.command_line,process.command_args,process.executable.path'']'
1919
services:
2020
- cls
2121

0 commit comments

Comments
 (0)