Skip to content

Commit

Permalink
Merge branch 'newrelic:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
jcountsNR authored Oct 18, 2023
2 parents 5ed6393 + 83410ce commit fbfc331
Show file tree
Hide file tree
Showing 22 changed files with 110 additions and 48 deletions.
16 changes: 16 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1 +1,17 @@
# Global codeowners
* @newrelic/opentelemetry-community

getting-started-guides/ @reese-lee
getting-started-guides/dotnet/ @alanwest
getting-started-guides/go/ @utr1903
getting-started-guides/java/ @jack-berg
getting-started-guides/javascript @matewilk
getting-started-guides/python/ @pnvnd
getting-started-guides/ruby/ @kaylareopelle

other-examples/collector/ @jcountsNR
other-examples/dotnet/ @alanwest
other-examples/java/ @jack-berg
# TODO: find serverless codeowner
other-examples/serverless/

11 changes: 11 additions & 0 deletions .github/config/markdown-link-check-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"retryOn429": true,
"aliveStatusCodes": [
200,
403
],
"ignorePatterns": [
{ "pattern": "https:\\/\\/.*.nr-data\\.net.*" },
{ "pattern": "http:\\/\\/localhost:[0-9]*" }
]
}
17 changes: 17 additions & 0 deletions .github/scripts/markdown-link-check-with-retry.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash -e

# this script helps to reduce sporadic link check failures by retrying at a file-by-file level

retry_count=3

for file in "$@"; do
for i in $(seq 1 $retry_count); do
if markdown-link-check --config "$(dirname "$0")/../config/markdown-link-check-config.json" \
"$file"; then
break
elif [[ $i -eq $retry_count ]]; then
exit 1
fi
sleep 5
done
done
15 changes: 15 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,18 @@ jobs:
- name: Build getting-started-guides/java with Gradle
working-directory: getting-started-guides/java
run: ./gradlew build

markdown-link-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install markdown-link-check
# TODO(jack-berg): use latest when config file reading bug is fixed: https://github.com/tcort/markdown-link-check/issues/246
run: npm install -g [email protected]

- name: Run markdown-link-check
run: |
find . -type f \
-name '*.md' \
| xargs .github/scripts/markdown-link-check-with-retry.sh
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@ build/
# Python
venv
__pycache__

# Docker
.env
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# Contributing

Contributions are always welcome. Before contributing please read the
[code of conduct](https://github.com/newrelic/.github/blob/main/CODE_OF_CONDUCT.md) and [search the issue tracker](../../issues); your issue may have already been discussed or fixed in `main`. To contribute,
[code of conduct](https://github.com/newrelic/.github/blob/main/CODE_OF_CONDUCT.md) and [search the issue tracker](https://github.com/newrelic/newrelic-opentelemetry-examples/issues); your issue may have already been discussed or fixed in `main`. To contribute,
[fork](https://help.github.com/articles/fork-a-repo/) this repository, commit your changes, and [send a Pull Request](https://help.github.com/articles/using-pull-requests/).

Note that our [code of conduct](https://github.com/newrelic/.github/blob/main/CODE_OF_CONDUCT.md) applies to all platforms and venues related to this project; please follow it in all your interactions with the project and its participants.

## Feature Requests

Feature requests should be submitted in the [Issue tracker](../../issues), with a description of the expected behavior & use case, where they’ll remain closed until sufficient interest, [e.g. :+1: reactions](https://help.github.com/articles/about-discussions-in-issues-and-pull-requests/), has been [shown by the community](../../issues?q=label%3A%22votes+needed%22+sort%3Areactions-%2B1-desc).
Feature requests should be submitted in the [Issue tracker](https://github.com/newrelic/newrelic-opentelemetry-examples/issues), with a description of the expected behavior & use case, where they’ll remain closed until sufficient interest, [e.g. :+1: reactions](https://help.github.com/articles/about-discussions-in-issues-and-pull-requests/), has been [shown by the community](https://github.com/newrelic/newrelic-opentelemetry-examples/issues?q=label%3A%22votes+needed%22+sort%3Areactions-%2B1-desc).
Before submitting an Issue, please search for similar ones in the
[closed issues](../../issues?q=is%3Aissue+is%3Aclosed+label%3Aenhancement).
[closed issues](https://github.com/newrelic/newrelic-opentelemetry-examples/issues?q=is%3Aissue+is%3Aclosed+label%3Aenhancement).

## Pull Requests

Expand Down
46 changes: 23 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,28 +40,28 @@ See [Contribute](#contribute) for how to request OpenTelemetry/New Relic interac

## Examples Index

- Collector
- [OpenTelemetry Collector with OTLP Export to New Relic](./collector): Run the OpenTelemetry Collector with OTLP gRPC export to New Relic.
- Java
- [OpenTelemetry Agent New Relic Config](./java/agent-nr-config): A Java application with the OpenTelemetry Agent configured for New Relic.
- [Micrometer Shim with OTLP Export](./java/logs-in-context-log4j2): A Spring Boot Java application with micrometer installed, configured to use the OpenTelemetry micrometer shim and export to New Relic using OTLP.
- [Logs In Context With Log4j2](./java/logs-in-context-log4j2): A Java application configured to include OpenTelemetry trace context on Log4j2 structured logs.
- [OpenTelemetry SDK New Relic Config](./java/sdk-nr-config): A Java application with OpenTelemetry standalone library instrumentation as well as custom instrumentation, configured for New Relic via the SDK.
- [OTLP New Relic Mapping](./java/otlp-nr-mapping): Contains a variety of test cases demonstrating how OTLP payloads are mapped to records in NRDB upon ingest.
- .NET
- [OpenTelemetry SDK New Relic Config](./dotnet/aspnetcore/) Simple ASP.NET Core application demonstrating OpenTelemetry instrumentation.
- JavaScript
- [OpenTelemetry SDK New Relic Config](./javascript/simple-nodejs-app-http-exp): An express application demonstrating OpenTelemetry auto-instrumentation, configured for New Relic via the SDK.
- Python
- [OpenTelemetry SDK New Relic Config](./python): Two simple Python application demonstrating OpenTelemetry instrumentation, one with Flask auto-instrumentation and one without Flask. Configured for New Relic via the SDK.
- Go
- [OpenTelemetry SDK New Relic Config](./go): Simple Go applications demonstrating OpenTelemetry instrumentation.
- Ruby
- [OpenTelemetry SDK New Relic Config](./ruby): A Sinatra application with automatic and manual instrumentation.
- Serverless
- AWS Lambda
- [OpenTelemetry Lambda .NET New Relic Config](./serverless/aws-lambda/dotnet): An example AWS .NET Lambda function instrumented with OpenTelemetry.
- [OpenTelemetry Lambda Java New Relic Config](./serverless/aws-lambda/java): An example AWS Java Lambda function instrumented with OpenTelemetry.
- [Getting Started Guides](./getting-started-guides/README.md)
- .NET ([uninstrumented](./getting-started-guides/dotnet/Uninstrumented) / [instrumented](./getting-started-guides/dotnet/Instrumented))
- Go ([uninstrumented](./getting-started-guides/go/uninstrumented) / [instrumented](./getting-started-guides/go/instrumented))
- Java ([uninstrumented](./getting-started-guides/java/uninstrumented) / [instrumented](./getting-started-guides/java/instrumented))
- Javascript ([uninstrumented](./getting-started-guides/javascript/uninstrumented) / [instrumented](./getting-started-guides/javascript/instrumented))
- Python ([uninstrumented](./getting-started-guides/python/Uninstrumented) / [instrumented](./getting-started-guides/python/Instrumented))
- Ruby ([uninstrumented](./getting-started-guides/ruby/uninstrumented) / [instrumented](./getting-started-guides/ruby/instrumented))
- Other Examples
- Collector
- [OpenTelemetry Collector with OTLP Export to New Relic](./other-examples/collector): Run the OpenTelemetry Collector with OTLP gRPC export to New Relic.
- Java
- [OpenTelemetry Agent New Relic Config](./other-examples/java/agent-nr-config): A Java application with the OpenTelemetry Agent configured for New Relic.
- [Micrometer Shim with OTLP Export](./other-examples/java/micrometer-shim): A Spring Boot Java application with micrometer installed, configured to use the OpenTelemetry micrometer shim and export to New Relic using OTLP.
- [Logs In Context With Log4j2](./other-examples/java/logs-in-context-log4j2): A Java application configured to include OpenTelemetry trace context on Log4j2 structured logs.
- .NET
- [OpenTelemetry Agent With New Relic Config](./other-examples/dotnet/agent-nr-config) A simple .NET application running with the OpenTelemetry Automatic Instrumentation Agent.
- Serverless
- AWS Lambda
- [OpenTelemetry Lambda .NET New Relic Config](./other-examples/serverless/aws-lambda/dotnet): An example AWS .NET Lambda function instrumented with OpenTelemetry.
- [OpenTelemetry Lambda Java New Relic Config](./other-examples/serverless/aws-lambda/java): An example AWS Java Lambda function instrumented with OpenTelemetry.
- Azure Functions
- [OpenTelemetry Azure Functions Node New Relic Config](./other-examples/serverless/azure-functions/node/http-trigger-app): An example Azure Function App that includes an HTTP trigger Azure Function instrumented using Open Telemetry.

## Contribute

Expand All @@ -73,7 +73,7 @@ If you have any questions, or to execute our corporate CLA (which is required if

**A note about vulnerabilities**

As noted in our [security policy](../../security/policy), New Relic is committed to the privacy and security of our customers and their data. We believe that providing coordinated disclosure by security researchers and engaging with the security community are important means to achieve our security goals.
As noted in our [security policy](https://github.com/newrelic/newrelic-opentelemetry-examples/security/policy), New Relic is committed to the privacy and security of our customers and their data. We believe that providing coordinated disclosure by security researchers and engaging with the security community are important means to achieve our security goals.

If you believe you have found a security vulnerability in this project or any of New Relic's products or websites, we welcome and greatly appreciate you reporting it to New Relic through [HackerOne](https://hackerone.com/newrelic).

Expand Down
5 changes: 2 additions & 3 deletions getting-started-guides/java/instrumented/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,14 @@ dependencies {
implementation 'org.springframework.boot:spring-boot-starter-log4j2'

// OpenTelemetry core
implementation platform('io.opentelemetry:opentelemetry-bom:1.30.1')
implementation platform('io.opentelemetry:opentelemetry-bom-alpha:1.30.1-alpha')
implementation platform('io.opentelemetry:opentelemetry-bom:1.31.0')
implementation 'io.opentelemetry:opentelemetry-api'
implementation 'io.opentelemetry:opentelemetry-sdk'
implementation 'io.opentelemetry:opentelemetry-exporter-otlp'
implementation 'io.opentelemetry:opentelemetry-sdk-extension-autoconfigure'

// OpenTelemetry instrumentation
implementation platform('io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom-alpha:1.30.0-alpha')
implementation platform('io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom-alpha:1.31.0-alpha')
implementation 'io.opentelemetry.instrumentation:opentelemetry-runtime-telemetry-java8'
implementation 'io.opentelemetry.instrumentation:opentelemetry-log4j-appender-2.17'
implementation 'io.opentelemetry.instrumentation:opentelemetry-spring-webmvc-6.0'
Expand Down
Empty file modified getting-started-guides/java/uninstrumented/call-app.sh
100644 → 100755
Empty file.
Empty file modified getting-started-guides/java/uninstrumented/load-generator.sh
100644 → 100755
Empty file.
4 changes: 2 additions & 2 deletions getting-started-guides/javascript/instrumented/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ npm install
```bash
npm start
```
The above command will use [parcel]([https://](https://parceljs.org/)) to build the frontend and start the server.
The above command will use [parcel](https://parceljs.org/) to build the frontend and start the server.

2. Open your browser and navigate to [http://localhost:8080](http://localhost:8080) to access the app.

Expand Down Expand Up @@ -98,7 +98,7 @@ npm install @opentelemetry/api \
@opentelemetry/resources \
@opentelemetry/semantic-conventions
```
Refer to the [manual-otel-web.js](./src/public/custom-otel-web.js) file for the implementation details.
Refer to the [manual-otel-web.js](./src/public/manual-otel-web.js) file for the implementation details.

## Open Telemetry Auto Instrumentation for Backend (Node.js)

Expand Down
2 changes: 1 addition & 1 deletion getting-started-guides/javascript/uninstrumented/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ npm install
```bash
npm start
```
The above command will use [parcel]([https://](https://parceljs.org/)) to build the frontend and start the server.
The above command will use [parcel](https://parceljs.org/) to build the frontend and start the server.

2. Open your browser and navigate to [http://localhost:8080](http://localhost:8080) to access the app.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jar {

dependencies {
compileOnly 'io.opentelemetry:opentelemetry-sdk-extension-autoconfigure'
compileOnly 'io.opentelemetry:opentelemetry-semconv'
compileOnly 'io.opentelemetry.semconv:opentelemetry-semconv:1.21.0-alpha'

implementation "io.opentelemetry.contrib:opentelemetry-samplers:1.30.0-alpha"
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package com.newrelic.otel.extension;

import static io.opentelemetry.semconv.resource.attributes.ResourceAttributes.SERVICE_INSTANCE_ID;
import static io.opentelemetry.semconv.ResourceAttributes.SERVICE_INSTANCE_ID;

import io.opentelemetry.api.trace.SpanKind;
import io.opentelemetry.contrib.sampler.RuleBasedRoutingSampler;
import io.opentelemetry.sdk.autoconfigure.spi.AutoConfigurationCustomizer;
import io.opentelemetry.sdk.autoconfigure.spi.AutoConfigurationCustomizerProvider;
import io.opentelemetry.sdk.resources.Resource;
import io.opentelemetry.sdk.trace.samplers.Sampler;
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
import io.opentelemetry.semconv.SemanticAttributes;
import java.util.UUID;

/**
Expand All @@ -32,6 +32,8 @@ public void customize(AutoConfigurationCustomizer autoConfiguration) {
sdkTracerProviderBuilder.setSampler(
Sampler.parentBased(
RuleBasedRoutingSampler.builder(SpanKind.SERVER, Sampler.alwaysOn())
// TODO: Update to url.path when semconv 1.22.0 is published and 2.0 version
// of otel java agent available
.drop(SemanticAttributes.HTTP_TARGET, "/actuator.*")
.build())));
}
Expand Down
5 changes: 2 additions & 3 deletions other-examples/java/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,8 @@ subprojects {
}

dependencies {
implementation platform("io.opentelemetry:opentelemetry-bom:1.29.0")
implementation platform("io.opentelemetry:opentelemetry-bom-alpha:1.30.1-alpha")
implementation platform("io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom-alpha:1.30.0-alpha")
implementation platform("io.opentelemetry:opentelemetry-bom-alpha:1.31.0-alpha")
implementation platform("io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom-alpha:1.31.0-alpha")
}
}
}
4 changes: 2 additions & 2 deletions other-examples/java/logs-in-context-log4j2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

This project contains a Java application configured to use [Log4j2](https://logging.apache.org/log4j/2.x/) to write JSON structured logs that propagate OpenTelemetry trace context onto log messages. It also contains a [docker-compose.yaml](./docker-compose.yaml) which illustrates how to forward these logs to an OpenTelemetry Collector, and onto New Relic.

The [log4j2.xml](./src/main/resources/log4j2.xml) configures the application to log out to the console with a [JSON Template Layout](https://logging.apache.org/log4j/2.x/manual/json-template-layout.html) defined in [Log4j2EventLayout.json](./src/main/resources/Log4j2EventLayout.json).
The [log4j2.xml](./log4j2.xml) configures the application to log out to the console with a [JSON Template Layout](https://logging.apache.org/log4j/2.x/manual/json-template-layout.html) defined in [Log4j2EventLayout.json](./Log4j2EventLayout.json).

The application uses the [OpenTelemetry Log4j2 Integration](https://github.com/open-telemetry/opentelemetry-java-instrumentation/tree/main/instrumentation/log4j/log4j-context-data/log4j-context-data-2.17/library-autoconfigure) to inject trace context to Log4j2 [thread context](https://logging.apache.org/log4j/2.x/manual/thread-context.html).

Expand All @@ -23,7 +23,7 @@ The result is JSON structured logs, with one JSON object per line, which have th
}
```

The OpenTelemetry Log specification defines that when propagating [trace context in legacy formats](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/compatibility/logging_trace_context.md), `trace_id` and `span_id` should be used. However, [New Relic structured logging conventions](https://github.com/newrelic/newrelic-exporter-specs/tree/master/logging) expect trace context to be propagated as `trace.id` and `span.id`. The [transform](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/processor/transformprocessor) processor is defined in the collector config to replace `trace_id` => `trace.id`, and `span_id` => `span.id`. Alternatively, this mapping could be done in the [Log4j2 JSON layout](./src/main/resources/Log4j2EventLayout.json), which may be more performant.
The OpenTelemetry Log specification defines that when propagating [trace context in legacy formats](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/compatibility/logging_trace_context.md), `trace_id` and `span_id` should be used. However, [New Relic structured logging conventions](https://github.com/newrelic/newrelic-exporter-specs/tree/master/logging) expect trace context to be propagated as `trace.id` and `span.id`. The [transform](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/processor/transformprocessor) processor is defined in the collector config to replace `trace_id` => `trace.id`, and `span_id` => `span.id`. Alternatively, this mapping could be done in the [Log4j2 JSON layout](./Log4j2EventLayout.json), which may be more performant.

## Run

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ services:
OTEL_LOGS_EXPORTER: none
OTEL_EXPORTER_OTLP_ENDPOINT: 'http://collector:4317'
OTEL_EXPERIMENTAL_RESOURCE_DISABLED_KEYS: 'process.command_line,process.command_args'
OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE: 'delta'
OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT: 4095
ports:
- '8080:8080'
logging:
Expand Down
2 changes: 1 addition & 1 deletion other-examples/java/logs-in-context-log4j2/log4j2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Configuration status="WARN" monitorInterval="30">
<Appenders>
<Console name="ConsoleAppender" target="SYSTEM_OUT" follow="true">
<JsonTemplateLayout eventTemplateUri="classpath:Log4j2EventLayout.json" maxStringLength="1000"/>
<JsonTemplateLayout eventTemplateUri="classpath:Log4j2EventLayout.json"/>
</Console>
</Appenders>
<Loggers>
Expand Down
2 changes: 0 additions & 2 deletions other-examples/java/logs-in-context-log4j2/otel-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ processors:
# https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/logs/README.md#trace-context-in-legacy-formats
- replace_pattern(body, "\"trace_id\":", "\"trace.id\":")
- replace_pattern(body, "\"span_id\":", "\"span.id\":")
# Truncate log bodies to 4095 characters
- set(body, Substring(body, 0, 4095)) where Len(body) >= 4095
exporters:
logging:
verbosity: $LOG_EXPORTER_LOG_VERBOSITY
Expand Down
2 changes: 1 addition & 1 deletion other-examples/serverless/aws-lambda/dotnet/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ This example assumes you have the following:

* A New Relic account. If you don't have one, [create one for free](https://newrelic.com/signup).
* An AWS account. If you don't have one, [create one for free](https://aws.amazon.com/).
* A [New Relic license key](/docs/apis/intro-apis/new-relic-api-keys/#ingest-keys) from your New Relic account.
* A [New Relic license key](https://docs.newrelic.com/docs/apis/intro-apis/new-relic-api-keys/#ingest-keys) from your New Relic account.

It also assumes you have the following installed:

Expand Down
2 changes: 1 addition & 1 deletion other-examples/serverless/aws-lambda/java/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ This example assumes you have the following:

* A New Relic account. If you don't have one, [create one for free](https://newrelic.com/signup).
* An AWS account. If you don't have one, [create one for free](https://aws.amazon.com/).
* A [New Relic license key](/docs/apis/intro-apis/new-relic-api-keys/#ingest-keys) from your New Relic account.
* A [New Relic license key](https://docs.newrelic.com/docs/apis/intro-apis/new-relic-api-keys/#ingest-keys) from your New Relic account.

It also assumes you have the following installed:

Expand Down
Loading

0 comments on commit fbfc331

Please sign in to comment.