-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add dotnet Dockerfile * Add go Dockerfile * Add javascript Dockerfile * Add ruby Dockerfile * Put it all together with docker compose * Remove dead link
- Loading branch information
Showing
15 changed files
with
325 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Include any files or directories that you don't want to be copied to your | ||
# container here (e.g., local build artifacts, temporary files, etc.). | ||
# | ||
# For more help, visit the .dockerignore file reference guide at | ||
# https://docs.docker.com/go/build-context-dockerignore/ | ||
|
||
**/.classpath | ||
**/.dockerignore | ||
**/.env | ||
**/.git | ||
**/.gitignore | ||
**/.project | ||
**/.settings | ||
**/.toolstarget | ||
**/.vs | ||
**/.vscode | ||
**/.next | ||
**/.cache | ||
**/*.*proj.user | ||
**/*.dbmdl | ||
**/*.jfm | ||
**/charts | ||
**/docker-compose* | ||
**/compose.y*ml | ||
**/Dockerfile* | ||
**/node_modules | ||
**/npm-debug.log | ||
**/obj | ||
**/secrets.dev.yaml | ||
**/values.dev.yaml | ||
**/build | ||
**/dist | ||
LICENSE | ||
README.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
OTEL_EXPORTER_OTLP_ENDPOINT=https://otlp.nr-data.net | ||
OTEL_EXPORTER_OTLP_HEADERS="api-key=YOUR_API_KEY_HERE" | ||
|
||
OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT=4095 | ||
OTEL_EXPORTER_OTLP_COMPRESSION=gzip | ||
OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf | ||
OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE=DELTA |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,26 @@ | ||
# Getting Started Guides | ||
# Getting Started with New Relic using OpenTelemetry | ||
|
||
This repo holds the source code for the demo applications used in the [Getting Started Guides](https://docs.newrelic.com/docs/more-integrations/open-source-telemetry-integrations/opentelemetry/get-started/opentelemetry-get-started-intro/). | ||
The examples within this directory demonstrate how to send data to New Relic | ||
using OpenTelemetry. | ||
|
||
Each language directory illustrates how to add OpenTelemetry instrumentation to a simple web application, and configure OpenTelemetry for an optimal New Relic experience. This includes exporting over OTLP, limiting attributes according to New Relic ingest limits, and more. | ||
Each language directory illustrates how to add OpenTelemetry instrumentation to | ||
a simple web application and configure OpenTelemetry for an optimal New Relic | ||
experience. This includes exporting over OTLP, limiting attributes according to | ||
New Relic ingest limits, and more. | ||
|
||
In order to provide some degree of uniformity, each sample app is written to comply with the [demo app specification](./demo-app-specification.md). Each language contains the following sub-directories: | ||
To get started quickly, you can use Docker Compose to spin up all the example | ||
applications. | ||
|
||
* **Uninstrumented:** Contains the uninstrumented version of the app. | ||
* **Instrumented:** Contains the instrumented versions of the app. The uninstrumented app is enhanced with OpenTelemetry based instrumentation to generate metrics, logs, and traces, and SDK configuration aligned with New Relic [best practices](https://docs.newrelic.com/docs/more-integrations/open-source-telemetry-integrations/opentelemetry/best-practices/opentelemetry-best-practices-overview/) to export telemetry to New Relic. | ||
1. First, open the [.env](./.env) file and configure your New Relic API key. | ||
If necessary, also change the | ||
[New Relic OTLP endpoint](https://docs.newrelic.com/docs/more-integrations/open-source-telemetry-integrations/opentelemetry/best-practices/opentelemetry-otlp/#configure-endpoint-port-protocol) | ||
to match your region and needs. | ||
|
||
To run, please see the [Getting Started Guides](https://docs.newrelic.com/docs/more-integrations/open-source-telemetry-integrations/opentelemetry/get-started/opentelemetry-get-started-intro/) documentation and follow the instructions in the README of the root of each respective sample app. | ||
2. Then, run Docker Compose | ||
|
||
```shell | ||
docker compose up --build | ||
``` | ||
|
||
3. Lastly, go view your data in New Relic. Running using Docker Compose also | ||
starts a simple load generator, so data should be flowing. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
services: | ||
dotnet: | ||
build: dotnet | ||
environment: | ||
- OTEL_SERVICE_NAME=getting-started-dotnet | ||
- OTEL_EXPORTER_OTLP_ENDPOINT | ||
- OTEL_EXPORTER_OTLP_HEADERS | ||
- OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT=4095 | ||
- OTEL_RESOURCE_ATTRIBUTES=service.instance.id=123 | ||
ports: | ||
- 8080 | ||
go: | ||
build: go | ||
environment: | ||
- OTEL_SERVICE_NAME=getting-started-go | ||
- OTEL_EXPORTER_OTLP_ENDPOINT | ||
- OTEL_EXPORTER_OTLP_HEADERS | ||
- OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT=4095 | ||
- OTEL_RESOURCE_ATTRIBUTES=service.instance.id=123 | ||
ports: | ||
- 8080 | ||
javascript: | ||
build: javascript | ||
environment: | ||
- OTEL_SERVICE_NAME=getting-started-javascript | ||
- OTEL_EXPORTER_OTLP_ENDPOINT | ||
- OTEL_EXPORTER_OTLP_HEADERS | ||
- OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT=4095 | ||
- OTEL_RESOURCE_ATTRIBUTES=service.instance.id=123 | ||
ports: | ||
- 8080 | ||
ruby: | ||
build: ruby | ||
environment: | ||
- OTEL_SERVICE_NAME=getting-started-ruby | ||
- OTEL_EXPORTER_OTLP_ENDPOINT | ||
- OTEL_EXPORTER_OTLP_HEADERS | ||
- OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT=4095 | ||
- OTEL_RESOURCE_ATTRIBUTES=service.instance.id=123 | ||
ports: | ||
- 8080 | ||
envoy: | ||
image: envoyproxy/envoy:v1.29.4 | ||
ports: | ||
- "8080:8080" | ||
volumes: | ||
- ./supporting-files/envoy.yaml:/etc/envoy/envoy.yaml | ||
loadgenerator: | ||
image: python:3.12.3 | ||
command: ["python", "/loadgenerator.py"] | ||
volumes: | ||
- ./supporting-files/loadgenerator.py:/loadgenerator.py | ||
depends_on: | ||
- dotnet | ||
- go | ||
- javascript | ||
- ruby |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# syntax=docker/dockerfile:1 | ||
|
||
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0-alpine AS build | ||
|
||
COPY . /source | ||
|
||
WORKDIR /source | ||
|
||
ARG TARGETARCH | ||
|
||
# Build the application. | ||
# Leverage a cache mount to /root/.nuget/packages so that subsequent builds don't have to re-download packages. | ||
# If TARGETARCH is "amd64", replace it with "x64" - "x64" is .NET's canonical name for this and "amd64" doesn't | ||
# work in .NET 6.0. | ||
RUN --mount=type=cache,id=nuget,target=/root/.nuget/packages \ | ||
dotnet publish -a ${TARGETARCH/amd64/x64} --use-current-runtime --self-contained false -o /app | ||
|
||
FROM mcr.microsoft.com/dotnet/aspnet:8.0-alpine AS final | ||
|
||
WORKDIR /app | ||
|
||
COPY --from=build /app . | ||
|
||
USER $APP_UID | ||
|
||
EXPOSE 8080 | ||
|
||
ENTRYPOINT ["dotnet", "dotnet.dll"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# syntax=docker/dockerfile:1 | ||
|
||
ARG GO_VERSION=1.20 | ||
FROM --platform=$BUILDPLATFORM golang:${GO_VERSION} AS build | ||
WORKDIR /src | ||
|
||
RUN --mount=type=cache,target=/go/pkg/mod/ \ | ||
--mount=type=bind,source=go.sum,target=go.sum \ | ||
--mount=type=bind,source=go.mod,target=go.mod \ | ||
go mod download -x | ||
|
||
ARG TARGETARCH | ||
|
||
RUN --mount=type=cache,target=/go/pkg/mod/ \ | ||
--mount=type=bind,target=. \ | ||
CGO_ENABLED=0 GOARCH=$TARGETARCH go build -o /bin/server . | ||
|
||
FROM alpine:latest AS final | ||
|
||
RUN --mount=type=cache,target=/var/cache/apk \ | ||
apk --update add \ | ||
ca-certificates \ | ||
tzdata \ | ||
&& \ | ||
update-ca-certificates | ||
|
||
ARG UID=10001 | ||
RUN adduser \ | ||
--disabled-password \ | ||
--gecos "" \ | ||
--home "/nonexistent" \ | ||
--shell "/sbin/nologin" \ | ||
--no-create-home \ | ||
--uid "${UID}" \ | ||
appuser | ||
USER appuser | ||
|
||
COPY --from=build /bin/server /bin/ | ||
|
||
EXPOSE 8080 | ||
|
||
ENTRYPOINT [ "/bin/server" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# syntax=docker/dockerfile:1 | ||
|
||
ARG NODE_VERSION=20.10.0 | ||
|
||
FROM node:${NODE_VERSION}-alpine | ||
|
||
ENV NODE_ENV production | ||
|
||
WORKDIR /usr/src/app | ||
|
||
RUN --mount=type=bind,source=package.json,target=package.json \ | ||
--mount=type=bind,source=package-lock.json,target=package-lock.json \ | ||
--mount=type=cache,target=/root/.npm \ | ||
npm ci --omit=dev | ||
|
||
USER node | ||
|
||
COPY . . | ||
|
||
EXPOSE 8080 | ||
|
||
CMD npm start |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# syntax=docker/dockerfile:1 | ||
|
||
FROM ruby:3.2.2 as base | ||
|
||
WORKDIR /usr/src/app | ||
|
||
COPY . . | ||
|
||
RUN bundle install | ||
|
||
EXPOSE 8080 | ||
|
||
CMD bundle exec rackup |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.