Skip to content
This repository was archived by the owner on Jan 9, 2023. It is now read-only.

Commit d71ea52

Browse files
authored
release 0.0.11 - bug fixes and enhancements (#63)
1 parent dae009b commit d71ea52

File tree

11 files changed

+82
-24
lines changed

11 files changed

+82
-24
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

88
## [Unreleased]
99

10+
## [0.0.11] - 2021-10-06
11+
12+
### Bugfixes
13+
- Fixed issue with AWS lambda logging dependencies not included if the wrapper is used as a direct dependency
14+
15+
### Enhancements
16+
- Added info message if logging exporter is installed for debug purposes
17+
- Default value of the configuration property `otel.lib.log.level` set to `INFO`
18+
1019
## [0.0.10] - 2021-10-05
1120

1221
### Bugfixes

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ template. For more information, see the [example](./examples/splunk-wrapper/READ
156156
OTEL_EXPORTER_JAEGER_ENDPOINT=http://127.0.0.1:9080/v1/trace
157157
SPLUNK_ACCESS_TOKEN="orgAccessToken"
158158
```
159-
You can also use the `jaeger-thrift-splunk' exporter to send spans directly to the Splunk Observability Cloud backend. You can update accomplish this by updating OTEL_EXPORTER_JAEGER_ENDPOINT to the ingest URL.
159+
You can also use the `jaeger-thrift-splunk` exporter to send spans directly to the Splunk Observability Cloud backend. You can accomplish this by updating OTEL_EXPORTER_JAEGER_ENDPOINT to the ingest URL.
160160

161161
```
162162
OTEL_TRACES_EXPORTER=jaeger-thrift-splunk

TROUBLESHOOTING.md

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
11
# Troubleshooting
22

33
A couple of notes what to consider in case of troubles:
4-
- wrapper needs to be configured - consult [examples](./examples)
5-
- wrapper will only wait configured (`OTEL_INSTRUMENTATION_AWS_LAMBDA_FLUSH_TIMEOUT`) number of milliseconds for backend
6-
to ingest spans
7-
- setting `OTEL_LAMBDA_LOG_LEVEL` to `debug` will install logging exporter along with the configured one
4+
1. Verifying configuration.
5+
6+
Each lambda needs to be configured - consult [examples](./examples).
7+
Pay attention to appropriate wrapper - depends on the handler type and trigger used (four different wrappers available).
8+
9+
2. Ensuring that traces are ingested.
10+
11+
Wrapper will only wait configured (`OTEL_INSTRUMENTATION_AWS_LAMBDA_FLUSH_TIMEOUT`) number of milliseconds for backend to ingest the spans. Increase the value if you don't see the spans in the APM.
12+
13+
3. Verifying traces in the APM.
14+
15+
Setting `OTEL_LAMBDA_LOG_LEVEL` to `DEBUG` will install logging exporter along with the configured one. Logging exporter will, in turn, log every span including traceId and spanId. TraceId can be then used in the APM to check if the trace was properly ingested.
16+
17+
The setting will also cause `jaeger-thrift-exporter` (if used) to log each trace sent to the APM along with the backend URL and token (masked) used by the operation.

wrapper/pom.xml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,13 +215,11 @@
215215
<groupId>com.amazonaws</groupId>
216216
<artifactId>aws-lambda-java-log4j2</artifactId>
217217
<version>1.2.0</version>
218-
<scope>runtime</scope>
219218
</dependency>
220219
<dependency>
221220
<groupId>org.apache.logging.log4j</groupId>
222221
<artifactId>log4j-slf4j18-impl</artifactId>
223222
<version>2.13.0</version>
224-
<scope>runtime</scope>
225223
</dependency>
226224
<dependency>
227225
<groupId>org.apache.logging.log4j</groupId>

wrapper/src/main/java/com/splunk/support/lambda/configuration/Config.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ private static boolean isConfigured(String name) {
3535
return (System.getProperty(name) != null || System.getenv(toEnvVarName(name)) != null);
3636
}
3737

38-
static String getValueOrDefault(String name) {
38+
static String getValue(String name) {
3939

4040
String result = System.getProperty(name);
4141
if (result == null) {

wrapper/src/main/java/com/splunk/support/lambda/configuration/ConfigValidator.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
package com.splunk.support.lambda.configuration;
1818

19-
import static com.splunk.support.lambda.configuration.Config.getValueOrDefault;
19+
import static com.splunk.support.lambda.configuration.Config.getValue;
2020

2121
import io.opentelemetry.semconv.resource.attributes.ResourceAttributes;
2222
import org.slf4j.Logger;
@@ -27,7 +27,7 @@ public class ConfigValidator {
2727
private static final Logger log = LoggerFactory.getLogger(ConfigValidator.class);
2828

2929
static void validate() {
30-
String resourceAttributes = getValueOrDefault("otel.resource.attributes");
30+
String resourceAttributes = getValue("otel.resource.attributes");
3131
if (!resourceAttributes.contains(ResourceAttributes.SERVICE_NAME.getKey())) {
3232
log.warn(
3333
"Resource attribute 'service.name' is not set: your service is unnamed and will be difficult to identify."

wrapper/src/main/java/com/splunk/support/lambda/configuration/DefaultConfiguration.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
package com.splunk.support.lambda.configuration;
1818

1919
import static com.splunk.support.lambda.configuration.Config.setDefaultValue;
20+
import static com.splunk.support.lambda.configuration.Names.OTEL_LIB_LOG_LEVEL;
21+
import static com.splunk.support.lambda.configuration.Names.OTEL_TRACES_EXPORTER;
2022

2123
public class DefaultConfiguration {
2224

@@ -36,12 +38,15 @@ static void applyDefaults() {
3638
setDefaultValue("otel.metrics.exporter", "none");
3739

3840
setDefaultValue("otel.propagators", "tracecontext,baggage");
39-
setDefaultValue("otel.traces.exporter", "otlp");
41+
setDefaultValue(OTEL_TRACES_EXPORTER, "otlp");
4042

4143
// sample ALL
4244
setDefaultValue("otel.traces.sampler", "always_on");
4345

4446
// disable non-lambda resource providers
4547
setDefaultValue("otel.java.disabled.resource.providers", DISABLED_RESOURCE_PROVIDERS);
48+
49+
// default info logging for otel libs
50+
setDefaultValue(OTEL_LIB_LOG_LEVEL, "INFO");
4651
}
4752
}

wrapper/src/main/java/com/splunk/support/lambda/configuration/JaegerThriftSpanExporterFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
package com.splunk.support.lambda.configuration;
1818

19-
import static com.splunk.support.lambda.configuration.SplunkConfiguration.SPLUNK_ACCESS_TOKEN;
19+
import static com.splunk.support.lambda.configuration.Names.SPLUNK_ACCESS_TOKEN;
2020
import static io.opentelemetry.api.internal.StringUtils.isNullOrEmpty;
2121

2222
import com.google.auto.service.AutoService;
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Copyright Splunk Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.splunk.support.lambda.configuration;
18+
19+
public final class Names {
20+
21+
public static final String SPLUNK_ACCESS_TOKEN = "splunk.access.token";
22+
23+
public static final String OTEL_LIB_LOG_LEVEL = "otel.lib.log.level";
24+
public static final String OTEL_TRACES_EXPORTER = "otel.traces.exporter";
25+
public static final String OTEL_EXPORTER_OTLP_HEADERS = "otel.exporter.otlp.headers";
26+
27+
private Names() {}
28+
}

wrapper/src/main/java/com/splunk/support/lambda/configuration/SplunkConfiguration.java

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,13 @@
1616

1717
package com.splunk.support.lambda.configuration;
1818

19-
import static com.splunk.support.lambda.configuration.Config.getValueOrDefault;
19+
import static com.splunk.support.lambda.configuration.Config.getValue;
20+
import static com.splunk.support.lambda.configuration.Names.OTEL_EXPORTER_OTLP_HEADERS;
21+
import static com.splunk.support.lambda.configuration.Names.OTEL_LIB_LOG_LEVEL;
22+
import static com.splunk.support.lambda.configuration.Names.OTEL_TRACES_EXPORTER;
23+
import static com.splunk.support.lambda.configuration.Names.SPLUNK_ACCESS_TOKEN;
2024

25+
import io.opentelemetry.api.internal.StringUtils;
2126
import java.util.logging.ConsoleHandler;
2227
import java.util.logging.Handler;
2328
import java.util.logging.Level;
@@ -29,9 +34,6 @@ public class SplunkConfiguration {
2934

3035
private static final Logger log = LoggerFactory.getLogger(SplunkConfiguration.class);
3136

32-
static final String OTEL_LIB_LOG_LEVEL = "OTEL_LIB_LOG_LEVEL";
33-
static final String SPLUNK_ACCESS_TOKEN = "splunk.access.token";
34-
3537
public static void configure() {
3638
ConfigValidator.validate();
3739
DefaultConfiguration.applyDefaults();
@@ -40,14 +42,14 @@ public static void configure() {
4042
}
4143

4244
private static void addSplunkAccessTokenToOtlpHeadersIfNeeded() {
43-
String accessToken = getValueOrDefault(SPLUNK_ACCESS_TOKEN);
44-
String tracesExporter = getValueOrDefault("otel.traces.exporter");
45+
String accessToken = getValue(SPLUNK_ACCESS_TOKEN);
46+
String tracesExporter = getValue(OTEL_TRACES_EXPORTER);
4547

4648
if ("otlp".equals(tracesExporter) && !accessToken.isEmpty()) {
47-
String userOtlpHeaders = getValueOrDefault("otel.exporter.otlp.headers");
49+
String userOtlpHeaders = getValue(OTEL_EXPORTER_OTLP_HEADERS);
4850
String otlpHeaders =
4951
(userOtlpHeaders.isEmpty() ? "" : userOtlpHeaders + ",") + "X-SF-TOKEN=" + accessToken;
50-
System.setProperty("otel.exporter.otlp.headers", otlpHeaders);
52+
System.setProperty(OTEL_EXPORTER_OTLP_HEADERS, otlpHeaders);
5153
}
5254
}
5355

@@ -66,8 +68,8 @@ private static void configureOtelLogging() {
6668
}
6769

6870
private static Level getOtelLibLogLevel() {
69-
String level = System.getenv(OTEL_LIB_LOG_LEVEL);
70-
if (level != null) {
71+
String level = Config.getValue(OTEL_LIB_LOG_LEVEL);
72+
if (!StringUtils.isNullOrEmpty(level)) {
7173
try {
7274
return Level.parse(level);
7375
} catch (IllegalArgumentException iae) {

0 commit comments

Comments
 (0)